说明
flush() 在发送完所有传出字符后清除任何已发送消息的调制解调器内存。 flush() 继承自 Stream 实用程序类。
用法
SMS.flush()
参数
空
返回
空
示例
// libraries
#include <MKRGSM.h>
// PIN Number
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;
char remoteNumber[20]; // Holds the emitting number
void setup()
{
// initialize serial communications
Serial.begin(9600);
Serial.println("SMS Messages Receiver");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop()
{
char c;
// If there are any SMSs available()
if (sms.available())
{
Serial.println("Message received from:");
// Get remote number
sms.remoteNumber(remoteNumber, 20);
Serial.println(remoteNumber);
// This is just an example of message disposal
// Messages starting with # should be discarded
if(sms.peek()=='#')
{
Serial.println("Discarded SMS");
sms.flush();
}
// Read message bytes and print them
while(c=sms.read())
Serial.print(c);
Serial.println("\nEND OF MESSAGE");
// delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}
delay(1000);
}
相关用法
- Arduino MKRGSM - sms.read()用法及代码示例
- Arduino MKRGSM - sms.print()用法及代码示例
- Arduino MKRGSM - sms.write()用法及代码示例
- Arduino MKRGSM - sms.available()用法及代码示例
- Arduino MKRGSM - sms.endSMS()用法及代码示例
- Arduino MKRGSM - sms.peek()用法及代码示例
- Arduino MKRGSM - sms.beginSMS()用法及代码示例
- Arduino MKRGSM - sms.remoteNumber()用法及代码示例
- Arduino MKRGSM - gprs.attachGPRS()用法及代码示例
- Arduino MKRGSM - client.connected()用法及代码示例
- Arduino MKRGSM - voice.answerCall()用法及代码示例
- Arduino MKRGSM - voice.hangCall()用法及代码示例
- Arduino MKRGSM - gsm.shutdown()用法及代码示例
- Arduino MKRGSM - modem.getIMEI()用法及代码示例
- Arduino MKRGSM - client.available()用法及代码示例
- Arduino MKRGSM - client.stop()用法及代码示例
- Arduino MKRGSM - voice.voiceCall()用法及代码示例
- Arduino MKRGSM - GSM构造函数用法及代码示例
- Arduino MKRGSM - gsm.begin()用法及代码示例
- Arduino MKRGSM - grps.ping()用法及代码示例
- Arduino MKRGSM - voice.retrieveCallingNumber()用法及代码示例
- Arduino MKRGSM - client.connect()用法及代码示例
- Arduino MKRGSM - client.read()用法及代码示例
- Arduino MKRGSM - voice.getVoiceCallStatus()用法及代码示例
- Arduino MKRNB - getCurrentCarrier()用法及代码示例
注:本文由纯净天空筛选整理自arduino.cc大神的英文原创作品 MKRGSM - sms.flush()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。