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

Diff of /smsdaemon/tester.cpp

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

revision 158 by torben, Mon Dec 8 21:49:49 2008 UTC revision 196 by torben, Thu Dec 18 06:53:29 2008 UTC
# Line 10  Line 10 
10    
11  #include "DebugTransceiver.h"  #include "DebugTransceiver.h"
12  #include "SmsToolTransceiver.h"  #include "SmsToolTransceiver.h"
13    #include "plugins/HostStatusPlugin.h"
14  #include "Sms.h"  #include "Sms.h"
15  #include "plugins/TogPlugin.h"  #include "plugins/TogPlugin.h"
16  #include "plugins/TrainInfo.h"  #include "plugins/TrainInfo.h"
17  #include "Util.h"  #include "Util.h"
18  #include "plugins/StatusPlugin.h"  #include "plugins/StatusPlugin.h"
19    #include "plugins/WeatherPlugin.h"
20  #include "SmsPdu.h"  #include "SmsPdu.h"
21    
22  using namespace std;  using namespace std;
# Line 27  void test_sms(ISmsTransceiver& modem, in Line 29  void test_sms(ISmsTransceiver& modem, in
29          string msg = Util::str_formatint(len);          string msg = Util::str_formatint(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("22337617", 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)
# Line 43  void test_sms(ISmsTransceiver& modem, in Line 45  void test_sms(ISmsTransceiver& modem, in
45    
46  int main()  int main()
47  {  {
48  /*          /*
49          int shift = 6;                  int shift = 6;
50          string start = "Hej med dig";                  string start = "Hej med dig";
51          string end = SmsPdu::Decode8to7bit(SmsPdu::Encode7to8bit(start,shift), shift );                  string end = SmsPdu::Decode8to7bit(SmsPdu::Encode7to8bit(start,shift), shift );
52    
53                    cout << start << endl;
54                    cout << end << endl;
55                    return 0;
56            */
57    
         cout << start << endl;  
         cout << end << endl;  
         return 0;  
 */  
58    
59          SmsToolTransceiver trans;          DebugTransceiver trans(true);
60            WeatherPlugin pl;
61    
62            SMS sms;
63    
64            pl.Execute(trans,sms);
65    
66    
         trans.ReadSms();  
67    
68          return 0;          return 0;
69          string start = "hej ������";          string start = "hej ������";
# Line 69  int main() Line 77  int main()
77    
78          return 0;          return 0;
79    
80          DebugTransceiver modem(true);          /*
81          SMS sms;              SerialPort port("/dev/ttyS1" );
82          sms.SetSender("1234");              port.Open( SerialPort::BAUD_9600,
83          sms.SetMessage("status");                                  SerialPort::CHAR_SIZE_8,
84          StatusPlugin status;                                  SerialPort::PARITY_NONE,
85          status.Execute(modem,sms);                          SerialPort::STOP_BITS_1,
86                            SerialPort::FLOW_CONTROL_HARD );
87          return 0;  
88  /*                  ModemTransceiver modem(port);
89      SerialPort port("/dev/ttyS1" );                  modem.Init();
90      port.Open( SerialPort::BAUD_9600,  
91                          SerialPort::CHAR_SIZE_8,  
92                          SerialPort::PARITY_NONE,                  test_sms(modem, 100);
93                  SerialPort::STOP_BITS_1,                  return 0;
94                  SerialPort::FLOW_CONTROL_HARD );  
95    
96          ModemTransceiver modem(port);                  vector<SMS> res = modem.ReadSms(true);
97          modem.Init();  
98                    for (unsigned int i = 0; i<res.size(); ++i)
99                    {
100          test_sms(modem, 100);                          SMS& sms = res[i];
101          return 0;                          string cmd = GetSmsCommand(sms);
102                            string data = GetSmsData(sms);
103                            cout << "------------------------------" << endl;
104          vector<SMS> res = modem.ReadSms(true);                          cout << "Index    " << sms.sms_index << endl;
105                            cout << "Sender:  " << sms.sender << endl;
106          for (unsigned int i = 0; i<res.size(); ++i)                          cout << "Time:    " << sms.timestamp << endl;
107          {                          cout << "Message: >" << sms.message << "<" << endl;
108                  SMS& sms = res[i];                          cout << "Cmd:     >" << cmd << "<" << endl;
109                  string cmd = GetSmsCommand(sms);                          cout << "Data     >" << data << "<" << endl;
110                  string data = GetSmsData(sms);  
111                  cout << "------------------------------" << endl;                          Util::str_dump(sms.message);
112                  cout << "Index    " << sms.sms_index << endl;                          //modem.SendSms(sms.sender, sms.message, false);
113                  cout << "Sender:  " << sms.sender << endl;  
114                  cout << "Time:    " << sms.timestamp << endl;                  }
115                  cout << "Message: >" << sms.message << "<" << endl;  
116                  cout << "Cmd:     >" << cmd << "<" << endl;          */
117                  cout << "Data     >" << data << "<" << endl;          /*
118                    vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true);
119                  Util::str_dump(sms.message);                  cout << "Len: " << pdu[0].len << endl;
120                  //modem.SendSms(sms.sender, sms.message, false);                  cout << "Pdu: " << pdu[0].pdu << endl;
121    
122          }                  modem.SendSmsPdu(pdu[0].pdu, pdu[0].len);
123            */
124  */  
125  /*  
126          vector<PduInfo> pdu = SmsPdu::CreateSmsPdu("4522337617", "Hej med dig, igen", true);  
127          cout << "Len: " << pdu[0].len << endl;          /*
128          cout << "Pdu: " << pdu[0].pdu << endl;                  SMS sms;
129                    sms.sender = "12345678";
130          modem.SendSmsPdu(pdu[0].pdu, pdu[0].len);                  sms.message = "Tog list";
131  */                  DebugModemTransceiver modem;
132                    TogPlugin plugin;
133                          
134                    plugin.Execute(modem, sms);
135  /*  
136          SMS sms;  
137          sms.sender = "12345678";                  string msg = Util::str_gsm2latin(modem.GetMessage());
138          sms.message = "Tog list";  
139          DebugModemTransceiver modem;                  cout << "---- " << msg.length() << " ----" << endl;
140          TogPlugin plugin;                  cout << msg << endl;
141            */
142          plugin.Execute(modem, sms);          /*
143                    vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro");
144    
145          string msg = Util::str_gsm2latin(modem.GetMessage());                  for (unsigned i=0; i<trains.size(); ++i)
146                    {
147          cout << "---- " << msg.length() << " ----" << endl;                          TrainInfo& train = trains[i];
148          cout << msg << endl;                          cout << "-------------------------------------" << endl;
149  */                          cout << "Time:       {" << train.time        << "}" << endl;
150  /*                          cout << "Update:     {" << train.update      << "}" << endl;
151          vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro");                          cout << "Type:       {" << train.type        << "}" << endl;
152                            cout << "Destination:{" << train.destination << "}" << endl;
153          for (unsigned i=0; i<trains.size(); ++i)                          cout << "Origin:     {" << train.origin      << "}" << endl;
154          {                          cout << "Current:    {" << train.current     << "}" << endl;
155                  TrainInfo& train = trains[i];                          cout << "Status:     {" << train.status      << "}" << endl;
156                  cout << "-------------------------------------" << endl;                          cout << "Note:       {" << train.note        << "}" << endl;
157                  cout << "Time:       {" << train.time        << "}" << endl;                  }
158                  cout << "Update:     {" << train.update      << "}" << endl;          */
159                  cout << "Type:       {" << train.type        << "}" << endl;          /*
160                  cout << "Destination:{" << train.destination << "}" << endl;                  SMS sms;
161                  cout << "Origin:     {" << train.origin      << "}" << endl;  
162                  cout << "Current:    {" << train.current     << "}" << endl;                  sms.message = "Test   test2   teste3 test4";
163                  cout << "Status:     {" << train.status      << "}" << endl;  
164                  cout << "Note:       {" << train.note        << "}" << endl;                  cout << "|" << GetSmsCommand(sms) << "|" << GetSmsData(sms) << "|" << endl;
165          }  
166  */                  return 0;
167  /*  
168          SMS sms;  
169                    SerialPort port("/dev/ttyS1" );
170          sms.message = "Test   test2   teste3 test4";                  port.Open();
171                    ModemTransceiver modem(port);
172          cout << "|" << GetSmsCommand(sms) << "|" << GetSmsData(sms) << "|" << endl;  
173                    //modem.SendSms("22337617", "Hello, sir!");
174          return 0;                  //
175                    vector<SMS> res = modem.ReadSms();
176    
177          SerialPort port("/dev/ttyS1" );  
178          port.Open();                  for (unsigned i=0; i<res.size(); ++i)
179          ModemTransceiver modem(port);                  {
180                            cout << "--- SMS Recieved ---" << endl;
181          //modem.SendSms("22337617", "Hello, sir!");                          cout << "Index:   " << res[i].sms_index << endl;
182          //                          cout << "From:    " << res[i].sender << endl;
183          vector<SMS> res = modem.ReadSms();                          cout << "Time:    " << res[i].timestamp << endl;
184                            cout << "Message:>" << res[i].message << "<" << endl;
185                            cout << endl;
186          for (unsigned i=0; i<res.size(); ++i)                          modem.DeleteSms(res[i].sms_index);
187          {                  }
188                  cout << "--- SMS Recieved ---" << endl;  
189                  cout << "Index:   " << res[i].sms_index << endl;                  for (int j=0; j<5; j++)
190                  cout << "From:    " << res[i].sender << endl;                  {
191                  cout << "Time:    " << res[i].timestamp << endl;                          modem.SendSms("22337617","Test");
192                  cout << "Message:>" << res[i].message << "<" << endl;                  }
193                  cout << endl;          */
                 modem.DeleteSms(res[i].sms_index);  
         }  
   
         for (int j=0; j<5; j++)  
         {  
                 modem.SendSms("22337617","Test");  
         }  
 */  
194          return 0;          return 0;
195  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.20