短信通知不适用于带有GSM模块的Arduino Nano



我想使用Arduino Nano来监控GSM模块的短信流量。我可以阅读和发送短信,但通知系统不工作:当我发送短信(到GSM模块中的SIM卡(时,串行端口中没有新的数据可用。知道为什么或如何调试以找到问题吗?

通信通过Arduino的引脚9和10以及GSM模块(Quectel EC25(的RX和TX完成。我使用的代码:

#include <SoftwareSerial.h>
#define DEBUG Serial
SoftwareSerial EC25(10,9); // RX, TX - 9600 baud rate
// pin 8 of raspi -> pin 9 of arduino nano 
// pin 10 of raspi -> pin 10 of arduino nano
#define AT_RESPONSE_LEN 100
#define TIMEOUT 1000
void setup() {
// put your setup code here, to run once:
EC25.begin(9600);
DEBUG.begin(9600);
// some AT commands just to see if the coms are ok
sendATComm("AT","OKrn");
sendATComm("AT+IPR?","OKrn");
sendATComm("AT+CGSN","OKrn");
sendATComm("AT+CNMI=2,1,0,0,0","OKrn");
DEBUG.println("listennig");
}
void loop() {
// put your main code here, to run repeatedly:
if (EC25.available()){
DEBUG.println("Notification received!");
}
}

// function for sending at command.
const char* sendATComm(const char *command, const char *desired_reponse)
{
uint32_t timer;
char response[AT_RESPONSE_LEN]; // module response for AT commands.
memset(response, 0 , AT_RESPONSE_LEN);
EC25.flush();
sendATCommOnce(command);
timer = millis();
while(true){
if(millis()-timer > TIMEOUT){
sendATCommOnce(command);
timer = millis();
}
char c;
int i = 0;
while(EC25.available()){
c = EC25.read();
DEBUG.write(c);
response[i++]=c;
delay(2);
}
if(strstr(response, desired_reponse)){
return response;
memset(response, 0 , strlen(response));
break;
}
}
}
// send at comamand to module
void sendATCommOnce(const char *comm)
{
EC25.print(comm);
EC25.print("r");
delay(100);
}

因此,我必须定义URC的输出端口才能使用UART通信(不将其用作默认值(。

默认配置设置为usbatusbmodem,这意味着我正在等待的通知信息被发送到其中一个串行端口。但我正在收听UART(通过RX和TX品脱(,因此我没有收到任何通知。

AT命令QURCCFG可以用来设置URC信号应该发送到哪个端口。在这种情况下,我希望它们发送到UART:

AT+QURCCFG="urcport","uart1"

最新更新