1 |
#include <string> |
#include <string> |
2 |
#include <stdlib.h> |
#include <stdlib.h> |
3 |
|
#include <iostream> |
4 |
|
|
5 |
#include "daemon.h" |
#include "daemon.h" |
6 |
#include "common.h" |
#include "Common.h" |
7 |
|
#include "Logger.h" |
8 |
|
|
9 |
#include "ModemTransceiver.h" |
#include "ModemTransceiver.h" |
10 |
#include "DebugTransceiver.h" |
#include "DebugTransceiver.h" |
33 |
Common* cmn = Common::instance(); |
Common* cmn = Common::instance(); |
34 |
ConfigFile* config = cmn->GetConfigfile(); |
ConfigFile* config = cmn->GetConfigfile(); |
35 |
|
|
36 |
port = new SerialPort ( config->GetValue("smsdaemon","serialport") ); |
port = new SerialPort ( config->GetValue("gsmmodem","serialport") ); |
37 |
try |
try |
38 |
{ |
{ |
39 |
port->Open( SerialPort::BAUD_9600, |
port->Open( SerialPort::BAUD_9600, |
44 |
} |
} |
45 |
catch(std::exception &e) |
catch(std::exception &e) |
46 |
{ |
{ |
47 |
cmn->logMessage( string("PortOpen Exception: ") + e.what() ); |
Logger::logMessage( string("PortOpen Exception: ") + e.what() ); |
48 |
sms_exit(1); |
sms_exit(1); |
49 |
} |
} |
50 |
|
|
56 |
} |
} |
57 |
catch (std::exception& e) |
catch (std::exception& e) |
58 |
{ |
{ |
59 |
cmn->logMessage( string("ModemTransceiver Exception: ") + e.what() ); |
Logger::logMessage( string("ModemTransceiver Exception: ") + e.what() ); |
60 |
sms_exit(2); |
sms_exit(2); |
61 |
} |
} |
62 |
} |
} |
73 |
|
|
74 |
//Set default values |
//Set default values |
75 |
|
|
76 |
cmn->setLogfile( "/var/log/smsdaemon.log"); |
Logger::setLogfile( "/var/log/smsdaemon.log"); |
77 |
cmn->pidfile = "/var/run/smsdaemon.pid"; |
cmn->pidfile = "/var/run/smsdaemon.pid"; |
78 |
cmn->spooldir = "/var/spool/smsdaemon"; |
cmn->spooldir = "/var/spool/smsdaemon"; |
79 |
|
|
85 |
|
|
86 |
bool res = config->Open( cmn->configFilePath ) ; |
bool res = config->Open( cmn->configFilePath ) ; |
87 |
if (!res) { |
if (!res) { |
88 |
cmn->logMessage(string("Could not open config file:") + cmn->configFilePath); |
cout << "Could not open config file:" << cmn->configFilePath << endl; |
89 |
return 1; |
return 1; |
90 |
} |
} |
91 |
|
|
92 |
|
Logger::initLog(); |
93 |
|
|
94 |
|
|
95 |
///////////////////// |
///////////////////// |
107 |
} |
} |
108 |
else |
else |
109 |
{ |
{ |
110 |
cmn->logMessage( string("Invalid transceiver setting: ")+transconf); |
Logger::logMessage( string("Invalid transceiver setting: ")+transconf); |
111 |
exit(1); |
exit(1); |
112 |
} |
} |
113 |
|
|