1 |
/* using http://sourceforge.net/projects/libserial/ |
/* using http://sourceforge.net/projects/libserial/ |
2 |
|
|
3 |
* |
* |
4 |
*/ |
*/ |
5 |
|
|
30 |
string msg = Util::str_formatint(len); |
string msg = Util::str_formatint(len); |
31 |
msg.append(1, ' '); |
msg.append(1, ' '); |
32 |
msg.append(len - msg.length(), 'a'); |
msg.append(len - msg.length(), 'a'); |
33 |
|
|
34 |
vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("22337617", msg, true); |
vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("22337617", msg, true); |
35 |
|
|
36 |
for (unsigned int i=0; i<pdu.size(); ++i) |
for (unsigned int i=0; i<pdu.size(); ++i) |
46 |
|
|
47 |
int main() |
int main() |
48 |
{ |
{ |
49 |
/* |
/* |
50 |
int shift = 6; |
int shift = 6; |
51 |
string start = "Hej med dig"; |
string start = "Hej med dig"; |
52 |
string end = SmsPdu::Decode8to7bit(SmsPdu::Encode7to8bit(start,shift), shift ); |
string end = SmsPdu::Decode8to7bit(SmsPdu::Encode7to8bit(start,shift), shift ); |
53 |
|
|
54 |
|
cout << start << endl; |
55 |
|
cout << end << endl; |
56 |
|
return 0; |
57 |
|
*/ |
58 |
|
|
59 |
cout << start << endl; |
std::vector<TrainInfo> info = GetTrainInfo( 10 ); |
60 |
cout << end << endl; |
|
61 |
return 0; |
for (unsigned int i=0; i<info.size(); ++i) |
62 |
*/ |
{ |
63 |
|
TrainInfo ti = info[i]; |
64 |
|
|
65 |
|
cout << ti.time << ":" << ti.update << ":" << ti.destination << endl; |
66 |
|
} |
67 |
|
|
68 |
|
/* |
69 |
DebugTransceiver trans(true); |
DebugTransceiver trans(true); |
70 |
WeatherPlugin pl; |
WeatherPlugin pl; |
71 |
|
|
86 |
|
|
87 |
|
|
88 |
return 0; |
return 0; |
|
|
|
|
/* |
|
|
SerialPort port("/dev/ttyS1" ); |
|
|
port.Open( SerialPort::BAUD_9600, |
|
|
SerialPort::CHAR_SIZE_8, |
|
|
SerialPort::PARITY_NONE, |
|
|
SerialPort::STOP_BITS_1, |
|
|
SerialPort::FLOW_CONTROL_HARD ); |
|
|
|
|
|
ModemTransceiver modem(port); |
|
|
modem.Init(); |
|
|
|
|
|
|
|
|
test_sms(modem, 100); |
|
|
return 0; |
|
|
|
|
|
|
|
|
vector<SMS> res = modem.ReadSms(true); |
|
|
|
|
|
for (unsigned int i = 0; i<res.size(); ++i) |
|
|
{ |
|
|
SMS& sms = res[i]; |
|
|
string cmd = GetSmsCommand(sms); |
|
|
string data = GetSmsData(sms); |
|
|
cout << "------------------------------" << endl; |
|
|
cout << "Index " << sms.sms_index << endl; |
|
|
cout << "Sender: " << sms.sender << endl; |
|
|
cout << "Time: " << sms.timestamp << endl; |
|
|
cout << "Message: >" << sms.message << "<" << endl; |
|
|
cout << "Cmd: >" << cmd << "<" << endl; |
|
|
cout << "Data >" << data << "<" << endl; |
|
|
|
|
|
Util::str_dump(sms.message); |
|
|
//modem.SendSms(sms.sender, sms.message, false); |
|
|
|
|
|
} |
|
|
|
|
|
*/ |
|
|
/* |
|
|
vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true); |
|
|
cout << "Len: " << pdu[0].len << endl; |
|
|
cout << "Pdu: " << pdu[0].pdu << endl; |
|
|
|
|
|
modem.SendSmsPdu(pdu[0].pdu, pdu[0].len); |
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
SMS sms; |
|
|
sms.sender = "12345678"; |
|
|
sms.message = "Tog list"; |
|
|
DebugModemTransceiver modem; |
|
|
TogPlugin plugin; |
|
|
|
|
|
plugin.Execute(modem, sms); |
|
|
|
|
|
|
|
|
string msg = Util::str_gsm2latin(modem.GetMessage()); |
|
|
|
|
|
cout << "---- " << msg.length() << " ----" << endl; |
|
|
cout << msg << endl; |
|
|
*/ |
|
|
/* |
|
|
vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro"); |
|
|
|
|
|
for (unsigned i=0; i<trains.size(); ++i) |
|
|
{ |
|
|
TrainInfo& train = trains[i]; |
|
|
cout << "-------------------------------------" << endl; |
|
|
cout << "Time: {" << train.time << "}" << endl; |
|
|
cout << "Update: {" << train.update << "}" << endl; |
|
|
cout << "Type: {" << train.type << "}" << endl; |
|
|
cout << "Destination:{" << train.destination << "}" << endl; |
|
|
cout << "Origin: {" << train.origin << "}" << endl; |
|
|
cout << "Current: {" << train.current << "}" << endl; |
|
|
cout << "Status: {" << train.status << "}" << endl; |
|
|
cout << "Note: {" << train.note << "}" << endl; |
|
|
} |
|
|
*/ |
|
|
/* |
|
|
SMS sms; |
|
|
|
|
|
sms.message = "Test test2 teste3 test4"; |
|
|
|
|
|
cout << "|" << GetSmsCommand(sms) << "|" << GetSmsData(sms) << "|" << endl; |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
SerialPort port("/dev/ttyS1" ); |
|
|
port.Open(); |
|
|
ModemTransceiver modem(port); |
|
|
|
|
|
//modem.SendSms("22337617", "Hello, sir!"); |
|
|
// |
|
|
vector<SMS> res = modem.ReadSms(); |
|
|
|
|
|
|
|
|
for (unsigned i=0; i<res.size(); ++i) |
|
|
{ |
|
|
cout << "--- SMS Recieved ---" << endl; |
|
|
cout << "Index: " << res[i].sms_index << endl; |
|
|
cout << "From: " << res[i].sender << endl; |
|
|
cout << "Time: " << res[i].timestamp << endl; |
|
|
cout << "Message:>" << res[i].message << "<" << endl; |
|
|
cout << endl; |
|
|
modem.DeleteSms(res[i].sms_index); |
|
|
} |
|
|
|
|
|
for (int j=0; j<5; j++) |
|
|
{ |
|
|
modem.SendSms("22337617","Test"); |
|
|
} |
|
89 |
*/ |
*/ |
90 |
|
/* |
91 |
|
SerialPort port("/dev/ttyS1" ); |
92 |
|
port.Open( SerialPort::BAUD_9600, |
93 |
|
SerialPort::CHAR_SIZE_8, |
94 |
|
SerialPort::PARITY_NONE, |
95 |
|
SerialPort::STOP_BITS_1, |
96 |
|
SerialPort::FLOW_CONTROL_HARD ); |
97 |
|
|
98 |
|
ModemTransceiver modem(port); |
99 |
|
modem.Init(); |
100 |
|
|
101 |
|
|
102 |
|
test_sms(modem, 100); |
103 |
|
return 0; |
104 |
|
|
105 |
|
|
106 |
|
vector<SMS> res = modem.ReadSms(true); |
107 |
|
|
108 |
|
for (unsigned int i = 0; i<res.size(); ++i) |
109 |
|
{ |
110 |
|
SMS& sms = res[i]; |
111 |
|
string cmd = GetSmsCommand(sms); |
112 |
|
string data = GetSmsData(sms); |
113 |
|
cout << "------------------------------" << endl; |
114 |
|
cout << "Index " << sms.sms_index << endl; |
115 |
|
cout << "Sender: " << sms.sender << endl; |
116 |
|
cout << "Time: " << sms.timestamp << endl; |
117 |
|
cout << "Message: >" << sms.message << "<" << endl; |
118 |
|
cout << "Cmd: >" << cmd << "<" << endl; |
119 |
|
cout << "Data >" << data << "<" << endl; |
120 |
|
|
121 |
|
Util::str_dump(sms.message); |
122 |
|
//modem.SendSms(sms.sender, sms.message, false); |
123 |
|
|
124 |
|
} |
125 |
|
|
126 |
|
*/ |
127 |
|
/* |
128 |
|
vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true); |
129 |
|
cout << "Len: " << pdu[0].len << endl; |
130 |
|
cout << "Pdu: " << pdu[0].pdu << endl; |
131 |
|
|
132 |
|
modem.SendSmsPdu(pdu[0].pdu, pdu[0].len); |
133 |
|
*/ |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
/* |
138 |
|
SMS sms; |
139 |
|
sms.sender = "12345678"; |
140 |
|
sms.message = "Tog list"; |
141 |
|
DebugModemTransceiver modem; |
142 |
|
TogPlugin plugin; |
143 |
|
|
144 |
|
plugin.Execute(modem, sms); |
145 |
|
|
146 |
|
|
147 |
|
string msg = Util::str_gsm2latin(modem.GetMessage()); |
148 |
|
|
149 |
|
cout << "---- " << msg.length() << " ----" << endl; |
150 |
|
cout << msg << endl; |
151 |
|
*/ |
152 |
|
/* |
153 |
|
vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro"); |
154 |
|
|
155 |
|
for (unsigned i=0; i<trains.size(); ++i) |
156 |
|
{ |
157 |
|
TrainInfo& train = trains[i]; |
158 |
|
cout << "-------------------------------------" << endl; |
159 |
|
cout << "Time: {" << train.time << "}" << endl; |
160 |
|
cout << "Update: {" << train.update << "}" << endl; |
161 |
|
cout << "Type: {" << train.type << "}" << endl; |
162 |
|
cout << "Destination:{" << train.destination << "}" << endl; |
163 |
|
cout << "Origin: {" << train.origin << "}" << endl; |
164 |
|
cout << "Current: {" << train.current << "}" << endl; |
165 |
|
cout << "Status: {" << train.status << "}" << endl; |
166 |
|
cout << "Note: {" << train.note << "}" << endl; |
167 |
|
} |
168 |
|
*/ |
169 |
|
/* |
170 |
|
SMS sms; |
171 |
|
|
172 |
|
sms.message = "Test test2 teste3 test4"; |
173 |
|
|
174 |
|
cout << "|" << GetSmsCommand(sms) << "|" << GetSmsData(sms) << "|" << endl; |
175 |
|
|
176 |
|
return 0; |
177 |
|
|
178 |
|
|
179 |
|
SerialPort port("/dev/ttyS1" ); |
180 |
|
port.Open(); |
181 |
|
ModemTransceiver modem(port); |
182 |
|
|
183 |
|
//modem.SendSms("22337617", "Hello, sir!"); |
184 |
|
// |
185 |
|
vector<SMS> res = modem.ReadSms(); |
186 |
|
|
187 |
|
|
188 |
|
for (unsigned i=0; i<res.size(); ++i) |
189 |
|
{ |
190 |
|
cout << "--- SMS Recieved ---" << endl; |
191 |
|
cout << "Index: " << res[i].sms_index << endl; |
192 |
|
cout << "From: " << res[i].sender << endl; |
193 |
|
cout << "Time: " << res[i].timestamp << endl; |
194 |
|
cout << "Message:>" << res[i].message << "<" << endl; |
195 |
|
cout << endl; |
196 |
|
modem.DeleteSms(res[i].sms_index); |
197 |
|
} |
198 |
|
|
199 |
|
for (int j=0; j<5; j++) |
200 |
|
{ |
201 |
|
modem.SendSms("22337617","Test"); |
202 |
|
} |
203 |
|
*/ |
204 |
return 0; |
return 0; |
205 |
} |
} |