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?
AT commands are instructions used to control a modem. AT is the abbreviation of ATtention. Every command line starts with "AT" or "at". That's why modem commands are called AT commands.
The AT commands are used to control the operation of your modem. They are called AT commands because the characters AT must precede each command to get the ATtention of the modem. AT commands can be issued only when the modem is in command mode or online command mode.
Many of the commands that are used to control wired dial-up modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and ATO (Return to online data state), are also supported by GSM/GPRS modems and mobile phones.
Try adding slight delay between commands (or wait for modem reply, "OK" usually).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With