opc0de
opc0de

Reputation: 11768

Send sms through AT Command acts weird

I am using ComPort component to send SMS messages via a modem the problem is that sometimes i get sms sometimes not sometimes i get the at commands in the body of the text message.

Here is my code:

procedure SendSmsCosmote(numar,text : string);
const
  buf : Byte = 26;
begin
  Form1.ComPort1.WriteStr('AT+CMGF=1'+#13#10);
  Form1.ComPort1.WriteStr('AT+CMGS="'+ numar + '"'+#13);
  Form1.ComPort1.WriteStr(text);
  Form1.ComPort1.Write(buf,1);
end;

What am I doing wrong? And why when I read from the modem I get what I sent on the tx line?

Upvotes: 6

Views: 3576

Answers (1)

Harriv
Harriv

Reputation: 6137

Try adding slight delay between commands (or wait for modem reply, "OK" usually).

Upvotes: 1

Related Questions