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

Diff of /smsdaemon/tester.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 38 by torben, Tue Jun 10 20:25:15 2008 UTC revision 185 by torben, Mon Dec 15 09:10:05 2008 UTC
# Line 1  Line 1 
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>  #include <vector>
9  /*#include "SerialPort.h"  #include "serialport/SerialPort.h"
10  #include "GsmModem.h"  
11  #include "Sms.h"*/  #include "DebugTransceiver.h"
12    #include "SmsToolTransceiver.h"
13    #include "plugins/HostStatusPlugin.h"
14    #include "Sms.h"
15    #include "plugins/TogPlugin.h"
16  #include "plugins/TrainInfo.h"  #include "plugins/TrainInfo.h"
17    #include "Util.h"
18    #include "plugins/StatusPlugin.h"
19    #include "SmsPdu.h"
20    
21  using namespace std;  using namespace std;
22    using namespace Util;
23    
24    void test_sms(ISmsTransceiver& modem, int len)
25    {
26            cout << "----- test_sms( " << len << " ) ------- " << endl;
27    
28            string msg = Util::str_formatint(len);
29            msg.append(1, ' ');
30            msg.append(len - msg.length(), 'a');
31            
32            vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("22337617", msg, true);
33    
34            for (unsigned int i=0; i<pdu.size(); ++i)
35            {
36                    cout << "#" << i << endl;
37                    cout << "Len: " << pdu[i].len << endl;
38                    cout << "Pdu: " << pdu[i].pdu << endl;
39    
40    //              modem.SendSmsPdu(pdu[i].pdu, pdu[i].len);
41            }
42    }
43    
44    
45  int main()  int main()
46  {  {
47    /*
48            int shift = 6;
49            string start = "Hej med dig";
50            string end = SmsPdu::Decode8to7bit(SmsPdu::Encode7to8bit(start,shift), shift );
51    
52            cout << start << endl;
53            cout << end << endl;
54            return 0;
55    */
56    
57    
58            DebugTransceiver trans(true);
59            HostStatusPlugin pl;
60    
61            SMS sms;
62    
63            pl.Execute(trans,sms);
64    
65    
66    
67            return 0;
68            string start = "hej ������";
69            string mid = str_latin2gsm(start);
70            string final = str_gsm2latin(mid);
71    
72            str_dump (start);
73            str_dump(mid);
74            str_dump(final);
75    
76    
77            return 0;
78    
79    /*
80        SerialPort port("/dev/ttyS1" );
81        port.Open( SerialPort::BAUD_9600,
82                            SerialPort::CHAR_SIZE_8,
83                            SerialPort::PARITY_NONE,
84                    SerialPort::STOP_BITS_1,
85                    SerialPort::FLOW_CONTROL_HARD );
86    
87            ModemTransceiver modem(port);
88            modem.Init();
89    
90    
91            test_sms(modem, 100);
92            return 0;
93    
94    
95            vector<SMS> res = modem.ReadSms(true);
96    
97            for (unsigned int i = 0; i<res.size(); ++i)
98            {
99                    SMS& sms = res[i];
100                    string cmd = GetSmsCommand(sms);
101                    string data = GetSmsData(sms);
102                    cout << "------------------------------" << endl;
103                    cout << "Index    " << sms.sms_index << endl;
104                    cout << "Sender:  " << sms.sender << endl;
105                    cout << "Time:    " << sms.timestamp << endl;
106                    cout << "Message: >" << sms.message << "<" << endl;
107                    cout << "Cmd:     >" << cmd << "<" << endl;
108                    cout << "Data     >" << data << "<" << endl;
109    
110                    Util::str_dump(sms.message);
111                    //modem.SendSms(sms.sender, sms.message, false);
112    
113            }
114    
115    */
116    /*
117            vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true);
118            cout << "Len: " << pdu[0].len << endl;
119            cout << "Pdu: " << pdu[0].pdu << endl;
120    
121            modem.SendSmsPdu(pdu[0].pdu, pdu[0].len);
122    */
123    
124                          
125    
126    /*
127            SMS sms;
128            sms.sender = "12345678";
129            sms.message = "Tog list";
130            DebugModemTransceiver modem;
131            TogPlugin plugin;
132    
133            plugin.Execute(modem, sms);
134    
135    
136            string msg = Util::str_gsm2latin(modem.GetMessage());
137    
138            cout << "---- " << msg.length() << " ----" << endl;
139            cout << msg << endl;
140    */
141    /*
142          vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro");          vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro");
143    
144          for (unsigned i=0; i<trains.size(); ++i)          for (unsigned i=0; i<trains.size(); ++i)
# Line 30  int main() Line 154  int main()
154                  cout << "Status:     {" << train.status      << "}" << endl;                  cout << "Status:     {" << train.status      << "}" << endl;
155                  cout << "Note:       {" << train.note        << "}" << endl;                  cout << "Note:       {" << train.note        << "}" << endl;
156          }          }
157    */
158  /*  /*
159          SMS sms;          SMS sms;
160    
# Line 43  int main() Line 167  int main()
167    
168          SerialPort port("/dev/ttyS1" );          SerialPort port("/dev/ttyS1" );
169          port.Open();          port.Open();
170          GsmModem modem(port);          ModemTransceiver modem(port);
171    
172          //modem.SendSms("22337617", "Hello, sir!");          //modem.SendSms("22337617", "Hello, sir!");
173          //          //

Legend:
Removed from v.38  
changed lines
  Added in v.185

  ViewVC Help
Powered by ViewVC 1.1.20