Qt:向AT调制解调器发送AT命令

时间:2014-07-02 15:00:30

标签: c++ qt modem gprs qtserialport

我有一个带有GPRS屏蔽的Arduino板。我可以使用Arduino的IDE发送和接收短信,但我现在即将使用Wavecom GPRS调制解调器。

我可以连接并从Qt发送字符串到Arduino板,这样当Arduino从Qt收到一个特殊字符串时,它会发送一条短信。请参阅下面的代码。

但是现在,我被卡住了......不知道如何直接从Qt发送AT命令,而不仅仅是发送Arduino等待发送短信的字符串......

现在有人可以从Qt向GPRS调制解调器发送AT命令吗?

Arduino代码:

void  loop()
{
    //Check if available
    if (Serial.available())
    {
        // read the incoming byte:
        incomingByte = Serial.read();

       //Just to show how it works
       if(incomingByte == 'X')
       {
        AT commands to send an sms
        }    
   }
    else
        delay(5); // there is nothing to read, so wait a few msec's
}

1 个答案:

答案 0 :(得分:1)

AT命令通常通过串口发送,该串口将由GPRS调制解调器上的控制器软件处理。因此,您只需要在Qt应用程序中处理发送方。

因此,您只需通过QtSerialPort模块使用QIODevice::write()接口:

mySerialPort->write("My AT command");
相关问题