......
function GetPDUData(SMSC, DATel, SDU: String; var len: String): String;
......
Function TPhoneMessage.GetPDUData(SMSC,DATel,SDU:String;var len:String):String;
var
i:Byte;
Data:String;
SMSC_Len,DATel_Len:Byte;
begin
SMSC:=PDUSMSC(SMSC,SMSC_Len);
DATel:=PDUTel('86'+DATel,DATel_Len);
SDU:=PDUFmtStr(SDU);
i:=Length(SDU) div 2;
Data:='';
Data:=Data+'3100';
Data:=Data+DATel;
Data:=Data+'00';
Data:=Data+'08';
Data:=Data+'A7';
Data:=Data+IntToHex(i,2);
Data:=Data+SDU;
len:=IntToStr(2+DATel_Len+4+i);
Result:=SMSC+Data;
end;
.......
function TPhoneMessage.senderMessage(msg: string;toPhone:string): boolean;
var
tmp,len:string;
temp:STring;
lrc:longword;
s:String;
begin
result:=false;
Data:=GetPDUData(msgCenterCode,tophone,msg,Len);
temp:=format('%s=1',[at.ATCSMS])+#13;
writefile(hcomm,pchar(temp)^,length(temp),lrc,nil);
sleep(50);
s:=readcom;
// temp:=format('%s=2,1,0,0,0',[at.ATCNMI])+#13;
temp:=format('%s=2,2,0,1,1',[at.ATCNMI])+#13;
writefile(hcomm,pchar(temp)^,length(temp),lrc,nil);
sleep(50);
s:=readcom;
temp:=format('%s=0',[at.ATCMGF])+#13;
writefile(hcomm,pchar(temp)^,length(temp),lrc,nil);
sleep(50);
s:=readcom;
temp:=format('%s=%s',[at.senderAT,len])+#13;
writefile(hcomm,pchar(temp)^,length(temp),lrc,nil);
sleep(50);
s:=readcom;
temp:=Data+#26;
writefile(hcomm,pchar(temp)^,length(temp),lrc,nil);
sleep(100);
s:=readcom;
sleep(6000);
s:=readcom;
if pos('OK',Uppercase(s))>0 then
Result:=true;
//if s<>'' then result:=true;
end;