Unable to send SMS using AT Commands

后端 未结 1 557
逝去的感伤
逝去的感伤 2020-12-02 03:01

I am using QextSerialPort to access ports

#include 
#include 
#include 



int main(int         


        
相关标签:
1条回答
  • 2020-12-02 03:29

    Your problem is the following:

    port->write("AT+CFUN=1");
    port->write("AT+CMGF=1 ");
    port->write("AT+CMGS=1234567");
    port->write("Hello Test SMS");
    

    Always after sending a AT command line to the modem, you MUST wait for the final result code (e.g. typically OKor ERROR although there are some more, and you must be prepared to handle all of them. For an example of how to wait for final result codes, you can look at the source code of atinout, which is a tiny program for reading a list of AT commands, send them to the modem and print the responses).

    Because without waiting the following command will abort the currently executing command. Abortion of AT commands is defined in section "5.6.1 Aborting commands" in V.250. If you have little experience with handling AT commands, that specification is a must read. Also you would do well in reading 27.005 for the +CMG... commands you use. You find links to the specifications on the at-command tag information.

    For AT+CMGS specifically you must also wait for "\r\n> " before sending the text, see my other answer.

    0 讨论(0)
提交回复
热议问题