6 |
#include <string> |
#include <string> |
7 |
#include <iostream> |
#include <iostream> |
8 |
#include <vector> |
#include <vector> |
9 |
#include "SerialPort.h" |
#include "serialport/SerialPort.h" |
10 |
|
|
11 |
#include "GsmModem.h" |
#include "GsmModem.h" |
12 |
#include "Sms.h" |
#include "Sms.h" |
13 |
#include "TogPlugin.h" |
#include "plugins/TogPlugin.h" |
14 |
#include "TrainInfo.h" |
#include "plugins/TrainInfo.h" |
15 |
#include "util.h" |
#include "util.h" |
16 |
|
#include "plugins/StatusPlugin.h" |
17 |
#include "SmsPdu.h" |
#include "SmsPdu.h" |
18 |
|
|
19 |
using namespace std; |
using namespace std; |
27 |
msg.append(1, ' '); |
msg.append(1, ' '); |
28 |
msg.append(len - msg.length(), 'a'); |
msg.append(len - msg.length(), 'a'); |
29 |
|
|
30 |
vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", msg, true); |
vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("22337617", msg, true); |
31 |
|
|
32 |
for (unsigned int i=0; i<pdu.size(); ++i) |
for (unsigned int i=0; i<pdu.size(); ++i) |
33 |
{ |
{ |
42 |
|
|
43 |
int main() |
int main() |
44 |
{ |
{ |
45 |
|
/* |
46 |
|
int shift = 6; |
47 |
|
string start = "Hej med dig"; |
48 |
|
string end = SmsPdu::Decode8to7bit(SmsPdu::Encode7to8bit(start,shift), shift ); |
49 |
|
|
50 |
|
cout << start << endl; |
51 |
|
cout << end << endl; |
52 |
|
return 0; |
53 |
|
*/ |
54 |
|
|
55 |
|
DebugGsmModem modem(true); |
56 |
|
SMS sms; |
57 |
|
sms.sender="1234"; |
58 |
|
sms.message="status"; |
59 |
|
StatusPlugin status; |
60 |
|
status.Execute(modem,sms); |
61 |
|
|
62 |
|
return 0; |
63 |
|
/* |
64 |
SerialPort port("/dev/ttyS1" ); |
SerialPort port("/dev/ttyS1" ); |
65 |
port.Open( SerialPort::BAUD_9600, |
port.Open( SerialPort::BAUD_9600, |
66 |
SerialPort::CHAR_SIZE_8, |
SerialPort::CHAR_SIZE_8, |
71 |
GsmModem modem(port); |
GsmModem modem(port); |
72 |
modem.Init(); |
modem.Init(); |
73 |
|
|
74 |
test_sms(modem, 161); |
|
75 |
|
test_sms(modem, 100); |
76 |
|
return 0; |
77 |
|
|
78 |
|
|
79 |
|
vector<SMS> res = modem.ReadSms(true); |
80 |
|
|
81 |
|
for (unsigned int i = 0; i<res.size(); ++i) |
82 |
|
{ |
83 |
|
SMS& sms = res[i]; |
84 |
|
string cmd = GetSmsCommand(sms); |
85 |
|
string data = GetSmsData(sms); |
86 |
|
cout << "------------------------------" << endl; |
87 |
|
cout << "Index " << sms.sms_index << endl; |
88 |
|
cout << "Sender: " << sms.sender << endl; |
89 |
|
cout << "Time: " << sms.timestamp << endl; |
90 |
|
cout << "Message: >" << sms.message << "<" << endl; |
91 |
|
cout << "Cmd: >" << cmd << "<" << endl; |
92 |
|
cout << "Data >" << data << "<" << endl; |
93 |
|
|
94 |
|
Util::str_dump(sms.message); |
95 |
|
//modem.SendSms(sms.sender, sms.message, false); |
96 |
|
|
97 |
|
} |
98 |
|
|
99 |
|
*/ |
100 |
/* |
/* |
101 |
vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true); |
vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true); |
102 |
cout << "Len: " << pdu[0].len << endl; |
cout << "Len: " << pdu[0].len << endl; |