|
#include <iostream> |
|
1 |
#include <string> |
#include <string> |
2 |
|
|
3 |
#include <cctype> |
#include <cctype> |
57 |
} |
} |
58 |
else |
else |
59 |
{ |
{ |
60 |
modem.SendSms(sms[i].sender, "Unknown command!"); |
modem.SendSms(sms[i].sender, "Unknown command!", false); |
61 |
} |
} |
62 |
|
|
63 |
modem.DeleteSms(sms[i].sms_index); |
modem.DeleteSms(sms[i].sms_index); |
64 |
|
cmn->smsCounter.incomming++; |
65 |
} |
} |
66 |
|
|
67 |
if (sms.size() == 0) |
if (sms.size() == 0) |
73 |
} |
} |
74 |
} |
} |
75 |
|
|
76 |
|
bool sms_exit(int exitcode) |
77 |
|
{ |
78 |
|
if (Common::instance()->isDaemon) |
79 |
|
daemonCleanup(); |
80 |
|
|
81 |
|
exit(exitcode); |
82 |
|
} |
83 |
|
|
84 |
int main(int argc, char* argv[]) |
int main(int argc, char* argv[]) |
85 |
{ |
{ |
95 |
cmn->gid = 1000; |
cmn->gid = 1000; |
96 |
|
|
97 |
cmn->loadConfig(argc,argv); |
cmn->loadConfig(argc,argv); |
98 |
|
cmn->daemonStart = time(0); |
99 |
|
|
100 |
|
|
101 |
///////////////////// |
///////////////////// |
121 |
catch(std::exception &e) |
catch(std::exception &e) |
122 |
{ |
{ |
123 |
cmn->logMessage( string("PortOpen Exception: ") + e.what() ); |
cmn->logMessage( string("PortOpen Exception: ") + e.what() ); |
124 |
exit(1); |
sms_exit(1); |
125 |
} |
} |
126 |
|
|
127 |
GsmModem modem(port); |
GsmModem modem(port); |
128 |
|
|
129 |
|
try |
130 |
|
{ |
131 |
|
modem.Init(); |
132 |
|
} |
133 |
|
catch (std::exception& e) |
134 |
|
{ |
135 |
|
cmn->logMessage( string("GsmModem Exception: ") + e.what() ); |
136 |
|
sms_exit(2); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
////////////////////////////////// |
////////////////////////////////// |
141 |
|
|
145 |
|
|
146 |
main_loop(modem); |
main_loop(modem); |
147 |
|
|
148 |
|
cmn->logMessage( cmn->getStatusMessage() ); |
149 |
|
|
150 |
if (cmn->isDaemon) |
if (cmn->isDaemon) |
151 |
daemonCleanup(); |
daemonCleanup(); |
152 |
|
|