1 |
/* using http://sourceforge.net/projects/libserial/ |
/* using http://sourceforge.net/projects/libserial/ |
2 |
|
* |
3 |
*/ |
*/ |
4 |
|
|
5 |
|
|
6 |
#include <string> |
#include <string> |
7 |
#include <iostream> |
#include <iostream> |
8 |
|
#include <vector> |
9 |
#include "SerialPort.h" |
#include "SerialPort.h" |
10 |
|
|
11 |
#include "GsmModem.h" |
#include "GsmModem.h" |
12 |
#include "Sms.h" |
#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; |
using namespace std; |
20 |
|
|
21 |
|
|
22 |
int main() |
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; |
SMS sms; |
79 |
|
|
80 |
sms.message = "Test test2 teste3 test4"; |
sms.message = "Test test2 teste3 test4"; |
108 |
{ |
{ |
109 |
modem.SendSms("22337617","Test"); |
modem.SendSms("22337617","Test"); |
110 |
} |
} |
111 |
|
*/ |
112 |
return 0; |
return 0; |
113 |
} |
} |