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

Contents of /smsdaemon/main.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 118 - (show annotations) (download)
Mon Dec 1 12:08:23 2008 UTC (15 years, 5 months ago) by torben
File size: 1432 byte(s)
main.cpp: reconfigured to usb port (i _really_ need to create that config module)

plugins/ListPlugin.(h|cpp): forgot to add the ListPlugin earlier. 
		this plugins sends an sms back with all the plugins loaded by the daemon.


1 #include <string>
2 #include <stdlib.h>
3
4 #include "daemon.h"
5 #include "common.h"
6
7 #include "GsmModem.h"
8 #include "SerialPort.h"
9 #include "SmsDaemon.h"
10
11
12 using namespace std;
13
14
15 bool sms_exit(int exitcode)
16 {
17 if (Common::instance()->isDaemon)
18 daemonCleanup();
19
20 exit(exitcode);
21 }
22
23 int main(int argc, char* argv[])
24 {
25 Common* cmn = Common::instance();
26
27 //Set default values
28
29 cmn->setLogfile( "/var/log/smsdaemon.log");
30 cmn->pidfile = "/var/run/smsdaemon.pid";
31 cmn->spooldir = "/var/spool/smsdaemon";
32
33 cmn->uid = 1000;
34 cmn->gid = 1000;
35
36 cmn->loadConfig(argc,argv);
37 cmn->daemonStart = time(0);
38
39
40 /////////////////////
41
42 //Write a delimiter line in the logfile to seperate sessions
43
44 if (Common::instance()->isDaemon)
45 daemonize();
46
47
48 SerialPort port("/dev/ttyUSB0" );
49 try
50 {
51 port.Open( SerialPort::BAUD_9600,
52 SerialPort::CHAR_SIZE_8,
53 SerialPort::PARITY_NONE,
54 SerialPort::STOP_BITS_1,
55 SerialPort::FLOW_CONTROL_HARD );
56 }
57 catch(std::exception &e)
58 {
59 cmn->logMessage( string("PortOpen Exception: ") + e.what() );
60 sms_exit(1);
61 }
62
63 GsmModem modem(port);
64
65 try
66 {
67 modem.Init();
68 }
69 catch (std::exception& e)
70 {
71 cmn->logMessage( string("GsmModem Exception: ") + e.what() );
72 sms_exit(2);
73 }
74
75
76 //////////////////////////////////
77
78 SmsDaemon daemon(modem);
79
80 daemon.Start();
81 //returns here when main-loop exits
82
83 if (cmn->isDaemon)
84 daemonCleanup();
85
86 return 0;
87 }

  ViewVC Help
Powered by ViewVC 1.1.20