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

Diff of /smsdaemon/main.cpp

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

revision 29 by torben, Mon Jun 9 21:36:39 2008 UTC revision 75 by torben, Fri Jun 13 10:10:06 2008 UTC
# Line 1  Line 1 
 #include <iostream>  
1  #include <string>  #include <string>
2    
3  #include <cctype>  #include <cctype>
# Line 58  void main_loop(GsmModem& modem) Line 57  void main_loop(GsmModem& modem)
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)
# Line 73  void main_loop(GsmModem& modem) Line 73  void main_loop(GsmModem& modem)
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  {  {
# Line 88  int main(int argc, char* argv[]) Line 95  int main(int argc, char* argv[])
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          /////////////////////          /////////////////////
# Line 104  int main(int argc, char* argv[]) Line 112  int main(int argc, char* argv[])
112          SerialPort port("/dev/ttyS1" );          SerialPort port("/dev/ttyS1" );
113          try          try
114          {          {
115                  port.Open( SerialPort::BAUD_9600 );                  port.Open( SerialPort::BAUD_9600,
116                                       SerialPort::CHAR_SIZE_8,
117                                       SerialPort::PARITY_NONE,
118                                       SerialPort::STOP_BITS_1,
119                                       SerialPort::FLOW_CONTROL_HARD );
120          }          }
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    
# Line 123  int main(int argc, char* argv[]) Line 145  int main(int argc, char* argv[])
145    
146          main_loop(modem);          main_loop(modem);
147    
148            cmn->logMessage( cmn->getStatusMessage() );
149    
150        if (cmn->isDaemon)
151            daemonCleanup();
152    
153            return 0;
154  }  }
155    

Legend:
Removed from v.29  
changed lines
  Added in v.75

  ViewVC Help
Powered by ViewVC 1.1.20