📄 adgsm.pas
字号:
CmdIndex := High(GSMConfigAvail); {!!.PDU}
end; {!!.PDU}
if Copy(STemp, 1, 6) = '+CSMP=' then begin {!!.06}
if NotifyOnNewMessage then {!!.06}
STemp := '+CSMP= 32' + {!!.06}
Copy(STemp, 7, Length(STemp)) {!!.06}
else {!!.06}
STemp := '+CSMP= 17' + {!!.06}
Copy(STemp, 7, Length(STemp)); {!!.06}
end; {!!.06}
FComPort.Output := 'AT' + STemp + #13;
end;
end;
gsSend: begin
inc(CmdIndex);
if CmdIndex > High(GSMSendMessageResponse) then begin
// Sent message - see if another message is ready
if Assigned(FOnNextMessage) then begin
MsgRdy := False;
FOnNextMessage(Self, FErrorCode, MsgRdy);
if MsgRdy then begin
{ Will inc(CmdIndex) and start with the CSCA setting }
CmdIndex := 0; // start sending over {!!.06}
PostMessage(FHandle, ApdGSMResponse, 2,0); {!!.06}
end;
end;
// generate the OnComplete event, we're done
if Assigned(FOnGSMComplete) then begin
FOnGSMComplete(Self, FGSMState, FErrorCode);
end;
FGSMState := gsNone;
ResponseStr := ''; {!!.02}
end else begin
if CmdIndex = High(GSMSendMessageCommands) - 1 then begin
// send the next command
ResponsePacket.StartString :=
GSMSendMessageResponse[CmdIndex];
ResponsePacket.EndString := '>'#32;
ResponsePacket.Enabled := True;
if FPDUMode then begin {!!.PDU}
BuildPDUMessage; {!!.PDU}
STemp := IntToStr(PDULength); {!!.PDU}
end else begin {!!.PDU}
//DelayTicks(4, True); {!!.04}
STemp := SMSAddress;
if STemp = '' then begin {!!.02}
DoFail(secBadOperation,-8302); {!!.02}
Exit; {!!.02}
end; {!!.02}
if STemp[1] <> '"' then {begin} {!!.01} {!!.06}
STemp := '"' + STemp + '"'; {!!.01} {!!.06}
//else {!!.01}
//if S[2] <> '+' then {!!.01}
//S := '"+' + S + '"'; {!!.01}
//end; {!!.01}
STemp := STemp + #13#10;
end;
FComPort.Output := 'AT' + GSMSendMessageCommands[CmdIndex]
+ STemp + #13; {!!.06}
end else begin
if CmdIndex = High(GSMSendMessageCommands) then begin
ResponsePacket.StartString :=
GSMSendMessageResponse[CmdIndex];
ResponsePacket.EndString := #13#10;
ResponsePacket.Enabled := True;
//DelayTicks(4, True); {!!.04}
if FPDUMode then begin {!!.PDU}
STemp := FTempWriteMess; {!!.PDU}
end else {!!.PDU}
STemp := FMessage;
if STemp[Length(STemp)] <> #26 then
STemp := STemp + #26;
FComPort.Output := STemp;
end else begin
ResponsePacket.StartString :=
GSMSendMessageResponse[CmdIndex];
ResponsePacket.Enabled := True;
//DelayTicks(4, True); {!!.04}
if GSMSendMessageCommands[CmdIndex] = '+CSCA=' then begin
if (FSMSCenter <> '') and
(GSMSendMessageCommands[CmdIndex]='+CSCA=') then begin
if FSMSCenter[1] = '"' then {begin} {!!.01}
FSMSCenter := copy(FSMSCenter, 2, Length(FSMSCenter));
{*if FSMSCenter[2] = '+' then
{FSMSCenter := copy(FSMSCenter, 3,
{Length(FSMSCenter));*} {!!.01}
if FSMSCenter[Length(FSMSCenter)] = '"' then {!!.01}
FSMSCenter := copy(FSMSCenter, 1, {!!.01}
Length(FSMSCenter)-1); {!!.01}
//end; {!!.01}
FComport.Output := 'AT' +
GSMSendMessageCommands[CmdIndex]+'"' {!!.01}
+ FSMSCenter + '"' + #13
end else begin
inc(CmdIndex);
ResponsePacket.StartString :=
GSMSendMessageResponse[CmdIndex];
ResponsePacket.EndString := '>'#32;
ResponsePacket.Enabled := True;
//DelayTicks(4, True); {!!.04}
if FPDUMode then begin {!!.PDU}
BuildPDUMessage; {!!.PDU}
S := IntToStr(PDULength); {!!.PDU}
end else begin {!!.PDU}
S := SMSAddress;
if S = '' then begin {!!.02}
DoFail(secBadOperation,-8302); {!!.02}
Exit; {!!.02}
end; {!!.02}
if S[1] <> '"' then {begin} {!!.01}
S := '"' + S + '"'; {!!.01}
//else {!!.01}
//if S[2] <> '+' then {!!.01}
//S := '"+' + S + '"'; {!!.01}
//end; {!!.01}
end; {!!.PDU}
S := S + #13;
FComPort.Output := 'AT' +
GSMSendMessageCommands[CmdIndex] + S;
end
end else
FComPort.Output := 'AT' + STemp + #13;
end
end
end;
STemp := '';
end;
gsListAll : begin
// Just sent +CMGL, successful so far, send the next command
S := ResponseStr;
if Length(S) > 8 then begin {!!.02}
if FGSMMode = gmPDU then begin {!!.06}
while ParseAPDUMessage do {!!.06}
DelayTicks(1, True); {!!.06}
end else {!!.06}
while ParseAMessage do {!!.02}
DelayTicks(1, True); {!!.02}
end;
if FNeedNewMessage > 0 then begin {!!.04}
if Assigned(FOnNewMessage) then {!!.04}
FOnNewMessage
(Self, FNeedNewMessage, FRecNewMess); {!!.06}
FNeedNewMessage := 0; {!!.04}
FRecNewMess := ''; {!!.06}
end else begin {!!.04}
if Assigned(FOnMessageList) then
FOnMessageList(Self);
if Assigned(FOnGSMComplete) and not FConfigList then {!!.02}
FOnGSMComplete(Self, FGSMState, FErrorCode);
end;
ResponsePacket.IncludeStrings := False;
ResponsePacket.StartCond := scString; {!!.02}
FGSMState := gsNone;
ResponseStr := ''; {!!.02}
end;
gsSendFStore : begin
//Just sent +CMSS, successful so far, send the next command
inc(CmdIndex);
if CmdIndex > High(GSMSendMessFromStorage) then begin
// generate the OnComplete event, we're done
//FMessageStore.ClearStore; {!!.06}
//Synchronize; {!!.06}
if Assigned(FOnMessageList) then
FOnMessageList(Self);
if Assigned(FOnGSMComplete) then
FOnGSMComplete(Self, FGSMState, FErrorCode);
FGSMState := gsNone;
ResponseStr := ''; {!!.02}
end else
// send the next command if there is one
FComPort.Output := 'AT' +
GSMSendMessFromStorage[CmdIndex] + #13;
end;
gsWrite : begin
// Just sent +CMGW, successful so far, send the next command
inc(CmdIndex);
if CmdIndex > High(GSMWriteToMemoryCommands) then begin
//FMessageStore.ClearStore; {!!.06}
//Synchronize; {!!.06}
if Assigned(FOnMessageList) then
FOnMessageList(Self);
// generate the OnComplete event, we're done configuring
if Assigned(FOnGSMComplete) then
FOnGSMComplete(Self, FGSMState, FErrorCode);
// PostMessage will synchronize and list all messages
PostMessage(FHandle, ApdGSMResponse, 1,0); {!!.06}
FGSMState := gsNone; {!!.02}
ResponseStr := ''; {!!.02}
end else
if (CmdIndex < High(GSMWriteToMemoryCommands)) then begin
BuildPDUMessage; {!!.PDU}
STemp := IntToStr(PDULength); {!!.PDU}
inc(CmdIndex); {!!.PDU}
FComPort.Output := 'AT' +
GSMWriteToMemoryCommands[CmdIndex] + STemp + #13;
end else begin
// send the next command
ResponsePacket.StartString :=
GSMWriteToMemoryResponse[CmdIndex];
ResponsePacket.EndString := #13#10;
ResponsePacket.Enabled := True;
if FTempWriteMess[Length(FTempWriteMess)] <> #26 then
FTempWriteMess := FTempWriteMess + #26;
FComPort.Output := FTempWriteMess;
end;
end;
gsDelete : begin
{ Just sent +CMGD=,successful so far, send the next command}
inc(CmdIndex);
if CmdIndex > High(GSMDeleteAMessageCommand) then begin
// generate the OnComplete event, we're done
//ResponsePacket.IncludeStrings := False; {!!.01}
//FMessageStore.ClearStore; {!!.06}
//Synchronize; {!!.06}
if Assigned(FOnMessageList) then
FOnMessageList(Self);
if Assigned(FOnGSMComplete) then
FOnGSMComplete(Self, FGSMState, FErrorCode);
// State set to gsNone in PostMessage below
//FGSMState := gsNone; {!!.02}{!!.06}
ResponseStr := ''; {!!.02}
// PostMessage will synchronize and list all messages
PostMessage(FHandle, ApdGSMResponse, 1,0); {!!.06}
end else
// send the next command
FComPort.Output := 'AT' + GSMDeleteAMessageCommand[CmdIndex]
+ #13;
end;
end; // End Case
end;
{ issues +CMGW to write message secified by FMessage and DestAddr to the phone
memory, memory location returned as function result }
procedure TApdCustomGSMPhone.WriteToMemory(const Dest, Msg: string);
var
S : string;
Res : Integer;
ET : EventTimer;
begin
if FGSMState > gsNone then begin
DoFail(secSMSBusy,-8100);
Exit;
end;
if not FConnected then begin
{ Do connection/configuration stuff }
FQuickConnect := False;
Connect;
repeat
Res := SafeYield;
until (FGSMState = gsNone) or (Res = wm_Quit);
end;
SetState(gsWrite);
ResponsePacket.StartString := GSMWriteToMemoryResponse[CmdIndex];
ResponsePacket.EndString := '>'#32;
ResponsePacket.Enabled := True;
//DelayTicks(4, True); {!!.04}
S := Dest;
if S[1] <> '"' then begin
if S[1] = '+' then
S := '"' + S + '"';
end;
if FGSMMode = gmPDU then begin {!!.PDU}
FSMSAddress := Dest; {!!.PDU}
FMessage := Msg; {!!.PDU}
PostMessage(FHandle, ApdGSMResponse, 0,0); {!!.PDU}
CmdIndex := CmdIndex - 2; {!!.PDU}
end else begin
FComPort.Output := 'AT' + GSMWriteToMemoryCommands[CmdIndex] + S + #13;
NewTimer(ET, 1080); // 60 second timer
repeat
Res := SafeYield;
until (FGSMState = gsNone) or (Res = wm_Quit) or TimerExpired(ET);
if TimerExpired(ET) then begin
DoFail(secSMSTimedOut,-8101);
Exit;
end;
end;
end;
procedure TApdCustomGSMPhone.WndProc(var Message: TMessage);
begin
with Message do begin
if Msg = ApdGSMResponse then begin
Message.Result := 1; {!!.06}
case WParam of {!!.04}
0 : ProcessResponse;
1 : begin {!!.04}
SetState(gsNone); {!!.06}
DelayTicks(1, True); {!!.06}
ListAllMessages; {!!.04}
end; {!!.04}
{Begin !!.06}
2 : begin
SetState(gsNone);
DelayTicks(1, True);
{$IFDEF AproBCB}
SendSMSMessage;
{$ELSE}
SendMessage;
{$ENDIF}
end;
{End !!.06}
end; // End Case
end else
Result := DefWindowP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -