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

Diff of /smsdaemon/tester.cpp

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

revision 69 by torben, Fri Jun 13 06:38:43 2008 UTC revision 185 by torben, Mon Dec 15 09:10:05 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 "SmsPdu.h"  #include "SmsPdu.h"
20    
21  using namespace std;  using namespace std;
22    using namespace Util;
23    
24    void test_sms(ISmsTransceiver& modem, int len)
 void test_sms(GsmModem& modem, int len)  
25  {  {
26          cout << "----- test_sms( " << len << " ) ------- " << endl;          cout << "----- test_sms( " << len << " ) ------- " << endl;
27    
# Line 27  void test_sms(GsmModem& modem, int len) Line 29  void test_sms(GsmModem& modem, int len)
29          msg.append(1, ' ');          msg.append(1, ' ');
30          msg.append(len - msg.length(), 'a');          msg.append(len - msg.length(), 'a');
31                    
32          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", msg, true);          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("22337617", msg, true);
33    
34          for (unsigned int i=0; i<pdu.size(); ++i)          for (unsigned int i=0; i<pdu.size(); ++i)
35          {          {
# Line 35  void test_sms(GsmModem& modem, int len) Line 37  void test_sms(GsmModem& modem, int len)
37                  cout << "Len: " << pdu[i].len << endl;                  cout << "Len: " << pdu[i].len << endl;
38                  cout << "Pdu: " << pdu[i].pdu << endl;                  cout << "Pdu: " << pdu[i].pdu << endl;
39    
40                  modem.SendSmsPdu(pdu[i].pdu, pdu[i].len);  //              modem.SendSmsPdu(pdu[i].pdu, pdu[i].len);
41          }          }
42  }  }
43    
44    
45  int main()  int main()
46  {  {
47          string pdu = "06915404950000040A91542233677100008060211202528009AB61F3C8D481622C";  /*
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    
         SMS sms = SmsPdu::ParseSmsPdu(pdu);  
65    
         cout << "Sender " << sms.sender << endl;  
         cout << "Time   " << sms.timestamp << endl;  
         cout << "Msg.   " << sms.message << endl;  
66    
67          return 0;          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" );      SerialPort port("/dev/ttyS1" );
81      port.Open( SerialPort::BAUD_9600,      port.Open( SerialPort::BAUD_9600,
82                          SerialPort::CHAR_SIZE_8,                          SerialPort::CHAR_SIZE_8,
# Line 60  int main() Line 84  int main()
84                  SerialPort::STOP_BITS_1,                  SerialPort::STOP_BITS_1,
85                  SerialPort::FLOW_CONTROL_HARD );                  SerialPort::FLOW_CONTROL_HARD );
86    
87          GsmModem modem(port);          ModemTransceiver modem(port);
88          modem.Init();          modem.Init();
89    
90          test_sms(modem, 161);  
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);          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true);
118          cout << "Len: " << pdu[0].len << endl;          cout << "Len: " << pdu[0].len << endl;
# Line 78  int main() Line 127  int main()
127          SMS sms;          SMS sms;
128          sms.sender = "12345678";          sms.sender = "12345678";
129          sms.message = "Tog list";          sms.message = "Tog list";
130          DebugGsmModem modem;          DebugModemTransceiver modem;
131          TogPlugin plugin;          TogPlugin plugin;
132    
133          plugin.Execute(modem, sms);          plugin.Execute(modem, sms);
# Line 118  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.69  
changed lines
  Added in v.185

  ViewVC Help
Powered by ViewVC 1.1.20