--- smsdaemon/GsmModem.cpp 2008/12/07 15:51:02 142 +++ smsdaemon/ModemTransceiver.cpp 2008/12/08 21:49:49 158 @@ -10,10 +10,11 @@ #include "serialport/SerialPort.h" -#include "GsmModem.h" +#include "ModemTransceiver.h" -#include "util.h" -#include "common.h" +#include "Util.h" +#include "Common.h" +#include "Logger.h" #include "SmsPdu.h" #include "SmsHelper.h" @@ -22,14 +23,14 @@ -GsmModem::GsmModem(SerialPort& serialport) +ModemTransceiver::ModemTransceiver(SerialPort& serialport) : m_port(serialport) { } -string GsmModem::GetResponse() +string ModemTransceiver::GetResponse() { SerialPort::DataBuffer buf; @@ -43,7 +44,7 @@ } -string GsmModem::Command(string command, string term) +string ModemTransceiver::Command(string command, string term) { time_t start,now; start = time(0); @@ -72,8 +73,8 @@ now = time(0); if ( (now-start) > 10 ) { - Common::instance()->logMessage( string("GsmModem::Command time out --") + command); - Common::instance()->logMessage( string("Modem responded: ") + Util::str_trim(response) ); + Logger::logMessage( string("ModemTransceiver::Command time out --") + command); + Logger::logMessage( string("Modem responded: ") + Util::str_trim(response) ); _timeout = true; break; } @@ -85,7 +86,7 @@ return response; } -vector GsmModem::ReadSms(bool readAll) +vector ModemTransceiver::ReadSms(bool readAll) { Command( "AT+CMGF=0" ); //Set SMS format to PDU @@ -122,9 +123,9 @@ } -void GsmModem::SendSmsPdu(std::string pdu, int len) //pdu inclussive leading "00" +void ModemTransceiver::SendSmsPdu(std::string pdu, int len) //pdu inclussive leading "00" { - Common::instance()->logMessage( string("SMS pdu send") ); + Logger::logMessage( string("SMS pdu send") ); Command("AT+CMGF=0"); Util::Sleep(2); @@ -142,9 +143,9 @@ Common::instance()->smsCounter.outgoing++; } -void GsmModem::SendSms(string to, string message, bool allowMultipart) +void ModemTransceiver::SendSms(string to, string message, bool allowMultipart) { - Common::instance()->logMessage( string("SMS send to ") + to); + Logger::logMessage( string("SMS send to ") + to); if (to.at(0) == '+') to.erase(0,0); @@ -157,18 +158,18 @@ SendSmsPdu(pdu.pdu, pdu.len); } - Common::instance()->logMessage( "All PDU's send"); + Logger::logMessage( "All PDU's send"); } -void GsmModem::DeleteSms(std::string smsIndex) +void ModemTransceiver::DeleteSms(std::string smsIndex) { string cmd = "AT+CMGD="; cmd.append(smsIndex); Command(cmd); } -int GsmModem::DeleteAllSms() +int ModemTransceiver::DeleteAllSms() { vector sms = ReadSms(true); @@ -181,7 +182,7 @@ -void GsmModem::WaitForSimcard() +void ModemTransceiver::WaitForSimcard() { int start = time(0); string result; @@ -199,7 +200,7 @@ } -void GsmModem::HandlePincode() +void ModemTransceiver::HandlePincode() { string result = Command("AT+CPIN?"); result = Util::str_trim(result); @@ -224,7 +225,7 @@ } } -void GsmModem::Init() +void ModemTransceiver::Init() { Command( "AT" ); if (_timeout) @@ -246,21 +247,3 @@ } - - -void DebugGsmModem::SendSms(std::string to, std::string message, bool allowMultipart) -{ - _to=to; - _message = message; - _multipart = allowMultipart; - - if (_print) - { - cout << "DebugGsmModem::SendSms --------------" << endl; - cout << "To: " << to << endl;; - cout << "Message: " << message << endl; - cout << "Multipart: " << allowMultipart << endl; - - } -} -