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

Annotation of /smsdaemon/tester.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (hide annotations) (download)
Wed Jun 11 10:21:47 2008 UTC (15 years, 11 months ago) by torben
File size: 1979 byte(s)
Make togplugin work

GsmModem.cpp - when sending SMS - truncate message body to 160 chars

1 torben 26 /* using http://sourceforge.net/projects/libserial/
2     */
3    
4    
5     #include <string>
6     #include <iostream>
7 torben 38 #include <vector>
8     /*#include "SerialPort.h"
9 torben 49 */
10 torben 26 #include "GsmModem.h"
11 torben 49 #include "Sms.h"
12     #include "TogPlugin.h"
13     #include "util.h"
14 torben 26
15 torben 49
16 torben 26 using namespace std;
17    
18    
19     int main()
20     {
21 torben 49 SMS sms;
22     sms.sender = "12345678";
23     sms.message = "Tog bj";
24     DebugGsmModem modem;
25     TogPlugin plugin;
26    
27     plugin.Execute(modem, sms);
28    
29    
30     string msg = Util::str_gsm2latin(modem.GetMessage());
31    
32     cout << "---- " << msg.length() << " ----" << endl;
33     cout << msg << endl;
34    
35     /*
36 torben 38 vector<TrainInfo> trains = GetTrainInfo("BJ","Bjerringbro");
37 torben 26
38 torben 38 for (unsigned i=0; i<trains.size(); ++i)
39     {
40     TrainInfo& train = trains[i];
41     cout << "-------------------------------------" << endl;
42     cout << "Time: {" << train.time << "}" << endl;
43     cout << "Update: {" << train.update << "}" << endl;
44     cout << "Type: {" << train.type << "}" << endl;
45     cout << "Destination:{" << train.destination << "}" << endl;
46     cout << "Origin: {" << train.origin << "}" << endl;
47     cout << "Current: {" << train.current << "}" << endl;
48     cout << "Status: {" << train.status << "}" << endl;
49     cout << "Note: {" << train.note << "}" << endl;
50     }
51 torben 49 */
52 torben 38 /*
53 torben 26 SMS sms;
54    
55     sms.message = "Test test2 teste3 test4";
56    
57     cout << "|" << GetSmsCommand(sms) << "|" << GetSmsData(sms) << "|" << endl;
58    
59     return 0;
60    
61    
62     SerialPort port("/dev/ttyS1" );
63     port.Open();
64     GsmModem modem(port);
65    
66     //modem.SendSms("22337617", "Hello, sir!");
67     //
68     vector<SMS> res = modem.ReadSms();
69    
70    
71     for (unsigned i=0; i<res.size(); ++i)
72     {
73     cout << "--- SMS Recieved ---" << endl;
74     cout << "Index: " << res[i].sms_index << endl;
75     cout << "From: " << res[i].sender << endl;
76     cout << "Time: " << res[i].timestamp << endl;
77     cout << "Message:>" << res[i].message << "<" << endl;
78     cout << endl;
79     modem.DeleteSms(res[i].sms_index);
80     }
81    
82     for (int j=0; j<5; j++)
83     {
84     modem.SendSms("22337617","Test");
85     }
86 torben 38 */
87 torben 26 return 0;
88     }

  ViewVC Help
Powered by ViewVC 1.1.20