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