--- smsdaemon/SmsDaemon.cpp 2008/06/16 11:30:20 92 +++ smsdaemon/SmsDaemon.cpp 2008/12/08 10:42:04 151 @@ -3,9 +3,11 @@ #include #include +#include + #include "common.h" -#include "GsmModem.h" +#include "ISmsTransceiver.h" #include "Plugin.h" #include "kbhit.h" @@ -14,14 +16,16 @@ #include "TaskManager.h" #include "PluginManager.h" +#include "ConfigFile.h" -using namespace std; +#include "version.h" +using namespace std; void SmsDaemon::CreateLogMessage(SMS& sms,bool hasPlugin) { ostringstream os; - os << "Recieved sms from " << sms.sender << " ; command=" << GetSmsCommand(sms); + os << "Recieved sms from " << sms.GetSender() << " ; command=" << sms.ExtractCommand(); if (!hasPlugin) os << " -- PLUGIN NOT FOUND"; @@ -31,6 +35,14 @@ void SmsDaemon::CheckSms() { + const int INTERVAL = 1000; //no of milliseconds between sms checks + timeval now = Util::GetTimeOfDay(); + + if ( Util::mTimeDiff(_lastSmsCheck,now) < INTERVAL) + return; + + _lastSmsCheck = now; + Common* cmn = Common::instance(); PluginManager* manager = cmn->GetPluginManager(); @@ -38,7 +50,7 @@ for (unsigned int i=0; ismsCounter.incomming++; } } @@ -79,7 +91,7 @@ if (cmn->isDebug && kbhit()) break; - Util::Sleep(10); + Util::Sleep(100); } } @@ -87,11 +99,17 @@ void SmsDaemon::Start() { Common* cmn = Common::instance(); + string transceiver = cmn->GetConfigfile()->GetValue("smsdaemon","transceiver"); + srand(time(0)); cmn->daemonStart = time(0); + _lastSmsCheck = Util::GetTimeOfDay(); cmn->logMessage("--------------------------------"); + cmn->logMessage( VERSION ); + cmn->logMessage( SVNVERSION ); + cmn->logMessage( string("Transceiver: ") + transceiver ); cmn->GetTaskManager()->LoadTasks(); cmn->GetPluginManager()->LoadPlugins();