/
ReceiveSMS.ino
61 lines (48 loc) · 1.2 KB
/
ReceiveSMS.ino
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <WioLTEforArduino.h>
#define INTERVAL (1000)
WioCellular Wio;
void setup() {
delay(200);
SerialUSB.begin(115200);
SerialUSB.println("");
SerialUSB.println("--- START ---------------------------------------------------");
SerialUSB.println("### I/O Initialize.");
Wio.Init();
SerialUSB.println("### Power supply ON.");
Wio.PowerSupplyCellular(true);
delay(500);
SerialUSB.println("### Turn on or reset.");
if (!Wio.TurnOnOrReset()) {
SerialUSB.println("### ERROR! ###");
return;
}
delay(3000);
SerialUSB.println("### Get phone number.");
char str[100];
if (Wio.GetPhoneNumber(str, sizeof (str)) <= 0) {
SerialUSB.println("### ERROR! ###");
return;
}
SerialUSB.println(str);
SerialUSB.println("### Setup completed.");
}
void loop() {
SerialUSB.print(".");
while (true) {
char str[200];
int strLen = Wio.ReceiveSMS(str, sizeof (str));
if (strLen < 0) {
SerialUSB.println("### ERROR! ###");
goto err;
}
if (strLen == 0) break;
SerialUSB.println("");
SerialUSB.println(str);
if (!Wio.DeleteReceivedSMS()) {
SerialUSB.println("### ERROR! ###");
goto err;
}
}
err:
delay(INTERVAL);
}