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

Diff of /smsdaemon/tester.cpp

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

revision 61 by torben, Thu Jun 12 11:05:18 2008 UTC revision 141 by torben, Sun Dec 7 13:28:52 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 "GsmModem.h"
12  #include "Sms.h"  #include "Sms.h"
13  #include "TogPlugin.h"  #include "plugins/TogPlugin.h"
14  #include "TrainInfo.h"  #include "plugins/TrainInfo.h"
15  #include "util.h"  #include "util.h"
16    #include "plugins/StatusPlugin.h"
17  #include "SmsPdu.h"  #include "SmsPdu.h"
18    
19  using namespace std;  using namespace std;
20    using namespace Util;
21    
22  void test_sms(GsmModem& modem, int len)  void test_sms(GsmModem& modem, int len)
23  {  {
24          cout << "----- test_sms( " << len << " ) ------- " << endl;          cout << "----- test_sms( " << len << " ) ------- " << endl;
25    
26          string msg = Util::str_formatint(len);          string msg = Util::str_formatint(len);
27            msg.append(1, ' ');
28          msg.append(len - msg.length(), 'a');          msg.append(len - msg.length(), 'a');
29                    
30          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", msg, true);          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("22337617", msg, true);
31    
32          for (unsigned int i=0; i<pdu.size(); ++i)          for (unsigned int i=0; i<pdu.size(); ++i)
33          {          {
# Line 41  void test_sms(GsmModem& modem, int len) Line 42  void test_sms(GsmModem& modem, int len)
42    
43  int main()  int main()
44  {  {
45    /*
46            int shift = 6;
47            string start = "Hej med dig";
48            string end = SmsPdu::Decode8to7bit(SmsPdu::Encode7to8bit(start,shift), shift );
49    
50            cout << start << endl;
51            cout << end << endl;
52            return 0;
53    */
54            string start = "hej æøåÆØÅ";
55            string mid = str_latin2gsm(start);
56            string final = str_gsm2latin(mid);
57    
58            str_dump (start);
59            str_dump(mid);
60            str_dump(final);
61    
62    
63            return 0;
64    
65            DebugGsmModem modem(true);
66            SMS sms;
67            sms.sender="1234";
68            sms.message="status";
69            StatusPlugin status;
70            status.Execute(modem,sms);
71    
72            return 0;
73    /*
74      SerialPort port("/dev/ttyS1" );      SerialPort port("/dev/ttyS1" );
75      port.Open( SerialPort::BAUD_9600,      port.Open( SerialPort::BAUD_9600,
76                          SerialPort::CHAR_SIZE_8,                          SerialPort::CHAR_SIZE_8,
# Line 51  int main() Line 81  int main()
81          GsmModem modem(port);          GsmModem modem(port);
82          modem.Init();          modem.Init();
83    
84          test_sms(modem, 161);  
85            test_sms(modem, 100);
86            return 0;
87    
88    
89            vector<SMS> res = modem.ReadSms(true);
90    
91            for (unsigned int i = 0; i<res.size(); ++i)
92            {
93                    SMS& sms = res[i];
94                    string cmd = GetSmsCommand(sms);
95                    string data = GetSmsData(sms);
96                    cout << "------------------------------" << endl;
97                    cout << "Index    " << sms.sms_index << endl;
98                    cout << "Sender:  " << sms.sender << endl;
99                    cout << "Time:    " << sms.timestamp << endl;
100                    cout << "Message: >" << sms.message << "<" << endl;
101                    cout << "Cmd:     >" << cmd << "<" << endl;
102                    cout << "Data     >" << data << "<" << endl;
103    
104                    Util::str_dump(sms.message);
105                    //modem.SendSms(sms.sender, sms.message, false);
106    
107            }
108    
109    */
110  /*  /*
111          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true);          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true);
112          cout << "Len: " << pdu[0].len << endl;          cout << "Len: " << pdu[0].len << endl;

Legend:
Removed from v.61  
changed lines
  Added in v.141

  ViewVC Help
Powered by ViewVC 1.1.20