forked from DFRobot/DFRobot_SIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DFRobot_SIMsms.cpp
47 lines (44 loc) · 1.02 KB
/
DFRobot_SIMsms.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "DFRobot_SIMsms.h"
bool DFRobot_SIMsms::beginSMS(const char* to)
{
if(SIMcore.check_send_cmd("AT+CMGF=1\r\n","OK")){
delay(100);
}else{
SIMcore.closeCommand();
return false;
}
SIMcore.send_cmd("AT+CMGS=\"");
SIMcore.send_cmd(to);
if(SIMcore.check_send_cmd("\"\r\n",">")){
delay(100);
SIMcore.setCommandCounter(2);
return true;
}else{
SIMcore.closeCommand();
return false;
}
}
void DFRobot_SIMsms::editSMS(const char* c)
{
if(SIMcore.getCommandCounter() == 2){
SIMcore.send_cmd(c);
SIMcore.setCommandCounter(3);
}else{
SIMcore.closeCommand();
}
}
bool DFRobot_SIMsms::sendSMS(void)
{
if(SIMcore.getCommandCounter() == 3){
if(SIMcore.check_send_cmd("","+CMGS")){
SIMcore.closeCommand();
return true;
}else{
SIMcore.closeCommand();
return false;
}
}else{
SIMcore.closeCommand();
return false;
}
}