1 |
/* using http://sourceforge.net/projects/libserial/ |
2 |
*/ |
3 |
|
4 |
|
5 |
#include <string> |
6 |
#include <iostream> |
7 |
#include <vector> |
8 |
/*#include "SerialPort.h" |
9 |
*/ |
10 |
#include "GsmModem.h" |
11 |
#include "Sms.h" |
12 |
#include "TogPlugin.h" |
13 |
#include "util.h" |
14 |
|
15 |
|
16 |
using namespace std; |
17 |
|
18 |
|
19 |
int main() |
20 |
{ |
21 |
SMS sms; |
22 |
sms.sender = "12345678"; |
23 |
sms.message = "Tog bj"; |
24 |
DebugGsmModem modem; |
25 |
TogPlugin plugin; |
26 |
|
27 |
plugin.Execute(modem, sms); |
28 |
|
29 |
|
30 |
string msg = Util::str_gsm2latin(modem.GetMessage()); |
31 |
|
32 |
cout << "---- " << msg.length() << " ----" << endl; |
33 |
cout << msg << endl; |
34 |
|
35 |
/* |
36 |
vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro"); |
37 |
|
38 |
for (unsigned i=0; i<trains.size(); ++i) |
39 |
{ |
40 |
TrainInfo& train = trains[i]; |
41 |
cout << "-------------------------------------" << endl; |
42 |
cout << "Time: {" << train.time << "}" << endl; |
43 |
cout << "Update: {" << train.update << "}" << endl; |
44 |
cout << "Type: {" << train.type << "}" << endl; |
45 |
cout << "Destination:{" << train.destination << "}" << endl; |
46 |
cout << "Origin: {" << train.origin << "}" << endl; |
47 |
cout << "Current: {" << train.current << "}" << endl; |
48 |
cout << "Status: {" << train.status << "}" << endl; |
49 |
cout << "Note: {" << train.note << "}" << endl; |
50 |
} |
51 |
*/ |
52 |
/* |
53 |
SMS sms; |
54 |
|
55 |
sms.message = "Test test2 teste3 test4"; |
56 |
|
57 |
cout << "|" << GetSmsCommand(sms) << "|" << GetSmsData(sms) << "|" << endl; |
58 |
|
59 |
return 0; |
60 |
|
61 |
|
62 |
SerialPort port("/dev/ttyS1" ); |
63 |
port.Open(); |
64 |
GsmModem modem(port); |
65 |
|
66 |
//modem.SendSms("22337617", "Hello, sir!"); |
67 |
// |
68 |
vector<SMS> res = modem.ReadSms(); |
69 |
|
70 |
|
71 |
for (unsigned i=0; i<res.size(); ++i) |
72 |
{ |
73 |
cout << "--- SMS Recieved ---" << endl; |
74 |
cout << "Index: " << res[i].sms_index << endl; |
75 |
cout << "From: " << res[i].sender << endl; |
76 |
cout << "Time: " << res[i].timestamp << endl; |
77 |
cout << "Message:>" << res[i].message << "<" << endl; |
78 |
cout << endl; |
79 |
modem.DeleteSms(res[i].sms_index); |
80 |
} |
81 |
|
82 |
for (int j=0; j<5; j++) |
83 |
{ |
84 |
modem.SendSms("22337617","Test"); |
85 |
} |
86 |
*/ |
87 |
return 0; |
88 |
} |