/[projects]/smsdaemon/tester.cpp
ViewVC logotype

Annotation of /smsdaemon/tester.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 59 - (hide annotations) (download)
Wed Jun 11 19:42:24 2008 UTC (15 years, 11 months ago) by torben
File size: 2560 byte(s)
Implemented basic sms pdu support

1 torben 26 /* using http://sourceforge.net/projects/libserial/
2 torben 59 *
3 torben 26 */
4    
5    
6     #include <string>
7     #include <iostream>
8 torben 38 #include <vector>
9 torben 59 #include "SerialPort.h"
10    
11 torben 26 #include "GsmModem.h"
12 torben 49 #include "Sms.h"
13     #include "TogPlugin.h"
14 torben 54 #include "TrainInfo.h"
15 torben 49 #include "util.h"
16 torben 26
17 torben 59 #include "SmsPdu.h"
18 torben 49
19 torben 26 using namespace std;
20    
21    
22     int main()
23     {
24 torben 59 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 torben 54
31 torben 59 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 torben 49 SMS sms;
47     sms.sender = "12345678";
48 torben 54 sms.message = "Tog list";
49 torben 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 torben 59 */
60 torben 49 /*
61 torben 38 vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro");
62 torben 26
63 torben 38 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 torben 49 */
77 torben 38 /*
78 torben 26 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 torben 38 */
112 torben 26 return 0;
113     }

  ViewVC Help
Powered by ViewVC 1.1.20