Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从特定号码接收sms_C++_Arduino_Gsm - Fatal编程技术网

C++ 从特定号码接收sms

C++ 从特定号码接收sms,c++,arduino,gsm,C++,Arduino,Gsm,我正在进行一个项目,在该项目中,我的Arduino ATMEGA328与SIM900 GSM Shield接口,将收到来自特定号码的短信 我能够收到这个消息。但我希望我的GSM只接收特定号码。例如,我只想接收来自+639123456789的号码。+639111112222和+639998887777等数字以及其他数字将被丢弃。有人能帮我吗 编辑:这是我的代码 #include <SoftwareSerial.h> #include <string.h>

我正在进行一个项目,在该项目中,我的Arduino ATMEGA328与SIM900 GSM Shield接口,将收到来自特定号码的短信

我能够收到这个消息。但我希望我的GSM只接收特定号码。例如,我只想接收来自+639123456789的号码。+639111112222和+639998887777等数字以及其他数字将被丢弃。有人能帮我吗

编辑:这是我的代码

    #include <SoftwareSerial.h> 
    #include <string.h>

    char inchar; // Will hold the incoming character from the GSM shield
    String s = "";
    SoftwareSerial SIM900(2, 3);
    void setup()
    {
      Serial.begin(9600);

      // wake up the GSM shield
      SIM900power(); 
      SIM900.begin(9600);
      delay(20000);  // give time to log on to network.
      SIM900.print("AT+CMGF=1\r");  // set SMS mode to text
      delay(100);
      SIM900.print("AT+CNMI=2,2,0,0,0\r"); 
      // blurt out contents of new SMS upon receipt to the GSM shield's serial out
      delay(100);
      Serial.println("Ready...");
    }

    void SIM900power()
    // software equivalent of pressing the GSM shield "power" button
    {
      digitalWrite(9, HIGH);
      delay(1000);
      digitalWrite(9, LOW);
      delay(7000);
    }

    void loop() 
    {

    if(SIM900.available() > 0)
{
if(SIM900.find("+639123456789 ") && SIM900.find("AUTO"))
{

Serial.println("AUTOMATIC asd");
SIM900.println("AT+CMGD=1,4");
}
}
    }
#包括
#包括
字符英寸;//将保留来自GSM屏蔽的输入字符
字符串s=“”;
软件串行SIM900(2,3);
无效设置()
{
Serial.begin(9600);
//唤醒GSM屏蔽
SIM900power();
SIM900.begin(9600);
延迟(20000);//给时间登录到网络。
SIM900.print(“AT+CMGF=1\r”);//将SMS模式设置为文本
延迟(100);
SIM900.print(“AT+CNMI=2,2,0,0,0\r”);
//在收到GSM shield的串行输出后脱口而出新短信的内容
延迟(100);
Serial.println(“就绪…”);
}
void SIM900power()
//软件相当于按下GSM屏蔽“电源”按钮
{
数字写入(9,高);
延迟(1000);
数字写入(9,低);
延迟(7000);
}
void循环()
{
如果(SIM900.available()>0)
{
if(SIM900.find(“+639123456789”)和&SIM900.find(“AUTO”))
{
Serial.println(“自动asd”);
SIM900.println(“AT+CMGD=1,4”);
}
}
}
我能够收到这个消息。但我希望我的GSM只接收 从一个特定的数字

您希望停止GSM接收来自未知号码的短信,还是希望在满足条件时输出到串行

如果是前者,您可能想与您的网络提供商交谈,并考虑该方法中的架构缺陷。

一旦消息不满足要求,它将立即删除该消息 状况

在相同的if条件下,如果不是从numXXX发送,则丢弃sms, 添加


当然,如果我们能看到那张草图会有帮助…

先收到它,然后检查数字,如果不匹配就什么也不做?在收到之前丢弃它是不起作用的。@deviantfan我正在寻找正确的语法格式。我尝试了SoftwareSerial.find(“+639123456789”),但它不起作用。你有其他方法检测发送者号码吗?DeviceFan是对的,这与GSM无关。发布一小部分C++代码,试图过滤掉这个数字,人们可以指出你错了。请随意编辑。:)@冯妮:你的问题不清楚。那条评论听起来像是你在挣扎于
如果这是那么那是
逻辑。但是你已经在代码中写了一个
if
语句,在你的生活中可能有几千条。这个有什么特别的问题?
else{
SIM900.print("AT+CNMI=2,2,0,0,0\r");
Serial.println("AUTOMATIC asd");
SIM900.println("AT+CMGD=1,4");
// or write high to led pin if that's what you want.......
}