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

Diff of /smsdaemon/tester.cpp

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

revision 71 by torben, Fri Jun 13 07:58:40 2008 UTC revision 188 by torben, Mon Dec 15 13:27:53 2008 UTC
# Line 6  Line 6 
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 "DebugTransceiver.h"
12    #include "SmsToolTransceiver.h"
13    #include "plugins/HostStatusPlugin.h"
14  #include "Sms.h"  #include "Sms.h"
15  #include "TogPlugin.h"  #include "plugins/TogPlugin.h"
16  #include "TrainInfo.h"  #include "plugins/TrainInfo.h"
17  #include "util.h"  #include "Util.h"
18    #include "plugins/StatusPlugin.h"
19    #include "plugins/WeatherPlugin.h"
20  #include "SmsPdu.h"  #include "SmsPdu.h"
21    
22  using namespace std;  using namespace std;
23    using namespace Util;
24    
25    void test_sms(ISmsTransceiver& modem, int len)
 void test_sms(GsmModem& modem, int len)  
26  {  {
27          cout << "----- test_sms( " << len << " ) ------- " << endl;          cout << "----- test_sms( " << len << " ) ------- " << endl;
28    
# Line 27  void test_sms(GsmModem& modem, int len) Line 30  void test_sms(GsmModem& modem, int len)
30          msg.append(1, ' ');          msg.append(1, ' ');
31          msg.append(len - msg.length(), 'a');          msg.append(len - msg.length(), 'a');
32                    
33          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", msg, true);          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("22337617", msg, true);
34    
35          for (unsigned int i=0; i<pdu.size(); ++i)          for (unsigned int i=0; i<pdu.size(); ++i)
36          {          {
# Line 35  void test_sms(GsmModem& modem, int len) Line 38  void test_sms(GsmModem& modem, int len)
38                  cout << "Len: " << pdu[i].len << endl;                  cout << "Len: " << pdu[i].len << endl;
39                  cout << "Pdu: " << pdu[i].pdu << endl;                  cout << "Pdu: " << pdu[i].pdu << endl;
40    
41                  modem.SendSmsPdu(pdu[i].pdu, pdu[i].len);  //              modem.SendSmsPdu(pdu[i].pdu, pdu[i].len);
42          }          }
43  }  }
44    
45    
46  int main()  int main()
47  {  {
48          string pdu = "06915404950000040A91542233677100008060211202528009AB61F3C8D481622C";  /*
49            int shift = 6;
50            string start = "Hej med dig";
51            string end = SmsPdu::Decode8to7bit(SmsPdu::Encode7to8bit(start,shift), shift );
52    
53            cout << start << endl;
54            cout << end << endl;
55            return 0;
56    */
57    
         string long_pdu1 = "06915404950000440A915422336771000080601132054380A005000346020188653ABD0C2ACB416537885E9ED35D2E972BE672B95C2E97CBE572B95C2E970BE472B95C2E97CBE572B95C2E97CBE572B95C2E97CBE572B95C2E970BE472B95C2E97CBE572B95C2E97CBE572B95C2E97CBE572B95C2097CBE572B95C2E97CBE572B95C2E97CBE572B95C2E97CBE572B9402E97CBE572B95C2E97CBE572B95C2E97CBE572B95C";  
         string long_pdu2 = "06915404950000440A9154223367710000806011320563800F0500034602025C2E97CBE572B900";  
58    
59          SMS sms = SmsPdu::ParseSmsPdu(long_pdu1);          DebugTransceiver trans(true);
60            WeatherPlugin pl;
61    
62            SMS sms;
63    
64            pl.Execute(trans,sms);
65    
66    
         cout << "Sender " << sms.sender << endl;  
         cout << "Time   " << sms.timestamp << endl;  
         cout << "Msg.   " << sms.message << endl;  
67    
68          return 0;          return 0;
69            string start = "hej ������";
70            string mid = str_latin2gsm(start);
71            string final = str_gsm2latin(mid);
72    
73            str_dump (start);
74            str_dump(mid);
75            str_dump(final);
76    
77    
78            return 0;
79    
80    /*
81      SerialPort port("/dev/ttyS1" );      SerialPort port("/dev/ttyS1" );
82      port.Open( SerialPort::BAUD_9600,      port.Open( SerialPort::BAUD_9600,
83                          SerialPort::CHAR_SIZE_8,                          SerialPort::CHAR_SIZE_8,
# Line 63  int main() Line 85  int main()
85                  SerialPort::STOP_BITS_1,                  SerialPort::STOP_BITS_1,
86                  SerialPort::FLOW_CONTROL_HARD );                  SerialPort::FLOW_CONTROL_HARD );
87    
88          GsmModem modem(port);          ModemTransceiver modem(port);
89          modem.Init();          modem.Init();
90    
91          test_sms(modem, 161);  
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);          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true);
119          cout << "Len: " << pdu[0].len << endl;          cout << "Len: " << pdu[0].len << endl;
# Line 81  int main() Line 128  int main()
128          SMS sms;          SMS sms;
129          sms.sender = "12345678";          sms.sender = "12345678";
130          sms.message = "Tog list";          sms.message = "Tog list";
131          DebugGsmModem modem;          DebugModemTransceiver modem;
132          TogPlugin plugin;          TogPlugin plugin;
133    
134          plugin.Execute(modem, sms);          plugin.Execute(modem, sms);
# Line 121  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.71  
changed lines
  Added in v.188

  ViewVC Help
Powered by ViewVC 1.1.20