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

Diff of /smsdaemon/main.cpp

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

revision 36 by torben, Tue Jun 10 15:34:19 2008 UTC revision 85 by torben, Mon Jun 16 06:46:56 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++;                          cmn->smsCounter.incomming++;
65                  }                  }
66    
67                  if (sms.size() == 0)                  cmn->taskManager.ExecuteTasks();
68                          Util::Sleep(10);  
69    
70                  if (cmn->isDebug && kbhit())                  if (cmn->isDebug && kbhit())
71                          break;                          break;
72    
73                    Util::Sleep(10);
74    
75          }          }
76  }  }
77    
78    bool sms_exit(int exitcode)
79    {
80        if (Common::instance()->isDaemon)
81            daemonCleanup();
82    
83            exit(exitcode);
84    }
85    
86  int main(int argc, char* argv[])  int main(int argc, char* argv[])
87  {  {
# Line 101  int main(int argc, char* argv[]) Line 109  int main(int argc, char* argv[])
109    
110          cmn->logMessage("--------------------------------");          cmn->logMessage("--------------------------------");
111    
112            cmn->taskManager.LoadTasks();
113          cmn->pluginManager.LoadPlugins();          cmn->pluginManager.LoadPlugins();
114                    
115          SerialPort port("/dev/ttyS1" );          SerialPort port("/dev/ttyS1" );
# Line 115  int main(int argc, char* argv[]) Line 124  int main(int argc, char* argv[])
124          catch(std::exception &e)          catch(std::exception &e)
125          {          {
126                  cmn->logMessage( string("PortOpen Exception: ") + e.what() );                  cmn->logMessage( string("PortOpen Exception: ") + e.what() );
127                  exit(1);                  sms_exit(1);
128          }          }
129    
130          GsmModem modem(port);          GsmModem modem(port);
131    
132            try
133            {
134                    modem.Init();
135            }
136            catch (std::exception& e)
137            {
138                    cmn->logMessage( string("GsmModem Exception: ") + e.what() );
139                    sms_exit(2);
140            }
141    
142    
143          //////////////////////////////////          //////////////////////////////////
144    
145          cmn->logMessage("SMS daemon started");          cmn->logMessage("SMS daemon started");
146    
147          modem.DeleteAllSms();          modem.DeleteAllSms();
148            
149          main_loop(modem);          try
150            {
151                    main_loop(modem);
152            }
153            catch (std::exception& e)
154            {
155                    cmn->logMessage( e.what() );
156            }
157            catch (...)
158            {
159                    cmn->logMessage( "Caught unknown exception" );
160            }
161    
162          cmn->logMessage( cmn->getStatusMessage() );          cmn->logMessage( cmn->getStatusMessage() );
163    

Legend:
Removed from v.36  
changed lines
  Added in v.85

  ViewVC Help
Powered by ViewVC 1.1.20