1 |
torben |
26 |
/* using http://sourceforge.net/projects/libserial/ |
2 |
|
|
*/ |
3 |
|
|
|
4 |
|
|
|
5 |
|
|
#include <string> |
6 |
|
|
#include <iostream> |
7 |
|
|
#include "SerialPort.h" |
8 |
|
|
#include "GsmModem.h" |
9 |
|
|
#include "Sms.h" |
10 |
|
|
|
11 |
|
|
using namespace std; |
12 |
|
|
|
13 |
|
|
|
14 |
|
|
int main() |
15 |
|
|
{ |
16 |
|
|
|
17 |
|
|
SMS sms; |
18 |
|
|
|
19 |
|
|
sms.message = "Test test2 teste3 test4"; |
20 |
|
|
|
21 |
|
|
cout << "|" << GetSmsCommand(sms) << "|" << GetSmsData(sms) << "|" << endl; |
22 |
|
|
|
23 |
|
|
return 0; |
24 |
|
|
|
25 |
|
|
|
26 |
|
|
SerialPort port("/dev/ttyS1" ); |
27 |
|
|
port.Open(); |
28 |
|
|
GsmModem modem(port); |
29 |
|
|
|
30 |
|
|
//modem.SendSms("22337617", "Hello, sir!"); |
31 |
|
|
// |
32 |
|
|
vector<SMS> res = modem.ReadSms(); |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
for (unsigned i=0; i<res.size(); ++i) |
36 |
|
|
{ |
37 |
|
|
cout << "--- SMS Recieved ---" << endl; |
38 |
|
|
cout << "Index: " << res[i].sms_index << endl; |
39 |
|
|
cout << "From: " << res[i].sender << endl; |
40 |
|
|
cout << "Time: " << res[i].timestamp << endl; |
41 |
|
|
cout << "Message:>" << res[i].message << "<" << endl; |
42 |
|
|
cout << endl; |
43 |
|
|
modem.DeleteSms(res[i].sms_index); |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
for (int j=0; j<5; j++) |
47 |
|
|
{ |
48 |
|
|
modem.SendSms("22337617","Test"); |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
return 0; |
52 |
|
|
} |