接收来自特定号码的短信
Receiving a sms from a specific number
本文关键字:号码 更新时间:2023-10-16
我正在做一个项目,我的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=1r"); // set SMS mode to text
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0r");
// 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 只接收 从特定数字。
您是否希望阻止GSM接收来自未知号码的SMS,还是要在满足条件时输出为串行?
如果是前者,您可能需要与您的网络提供商交谈,并考虑这种方法中的体系结构陷阱。
一旦邮件不满足 条件
在相同的 if 条件下,如果不是从 numXXX 发送,则丢弃短信,添加一个
else{
SIM900.print("AT+CNMI=2,2,0,0,0r");
Serial.println("AUTOMATIC asd");
SIM900.println("AT+CMGD=1,4");
// or write high to led pin if that's what you want.......
}
当然,如果我们能看到那张草图会有所帮助......
相关文章:
- 程序不断发送垃圾邮件号码?
- 在C++中使用线程查找友好号码比单个线程花费更多时间
- 插入号码后C++崩溃
- C++ 电话号码字母拨号程序 - 语法错别字?还是非 ASCII 字符?
- 确定第一个可用号码
- 电脑从1-1000猜你的号码(必须在10次尝试中)
- 如何让程序只运行用户输入的号码?
- 如何为代码包含负值?号码系统转换
- 使用 Firebase 从C++获取用户的电话号码
- 实现 =, - =, *=, /=运算符(复杂号码控制器计算器)
- 为什么 NodeMCU 发送带有不需要的号码的数据?
- C++控制台 - 按特定号码搜索客户端
- 在文本文件中搜索int号码
- 如何让计算机在 7 个问题中正确猜测用户的号码
- 文本文件中的电话号码查找
- C 映射类成号码
- 仅使用char将八分音号码转换为十进制数字
- 打印号码模式
- QT 5.12 Mac OS X版本号码错误
- 用IO操纵器在十六进制中打印一个8位号码