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

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

  ViewVC Help
Powered by ViewVC 1.1.20