AT+CMGF=1 选择PDU编码,0为文本模式
AT+CMGL=0 列出SIM卡中短消息,0-未读,1-已读,2-待发,3-已发
AT+CMGR=1 读取指定编号的短消息
AT+CMGD=1 删除短消息
AT+CMGS="13958138454" 发送短消息,CTRL+Z结束
>Good Morning! ^Z
PDU英文编码:
function EncodeEnglish(var s:String): String;
var
i,j, Cur: Integer;
t:String;
begin
Result := '';
i := 1; j := 0;
while i <= Length(s) do
begin
if i < Length(s) then
Cur := (ord(s) shr j) or ((ord(s[i+1]) shl (7-j)) and $ff)
else
Cur:=(ord(s) shr j) and $7f;
FmtStr(t,‘%2.2X’,[cur]);
Result := Result + t;
inc(i);
j := (j+1) mod 7;
if j = 0 then
inc(i);
end;
end;
中文编码:
function EncodeChinese(var s:WideString): String;
var
i, Cur: Integer;
t: String;
begin
Result := '';
i := 1;
while i <= Length(s) do
begin
Cur:=ord(s);
FmtStr(t,'%4.4X',[Cur]);
Result := Result + t;
inc(i);
end;
end;