--- smsdaemon/GsmModem.cpp 2008/06/17 17:47:37 105 +++ smsdaemon/ModemTransceiver.cpp 2008/12/07 20:58:41 149 @@ -8,27 +8,28 @@ #include -#include "SerialPort.h" +#include "serialport/SerialPort.h" -#include "GsmModem.h" +#include "ModemTransceiver.h" #include "util.h" #include "common.h" #include "SmsPdu.h" +#include "SmsHelper.h" using namespace std; -GsmModem::GsmModem(SerialPort& serialport) +ModemTransceiver::ModemTransceiver(SerialPort& serialport) : m_port(serialport) { } -string GsmModem::GetResponse() +string ModemTransceiver::GetResponse() { SerialPort::DataBuffer buf; @@ -42,7 +43,7 @@ } -string GsmModem::Command(string command, string term) +string ModemTransceiver::Command(string command, string term) { time_t start,now; start = time(0); @@ -71,7 +72,7 @@ now = time(0); if ( (now-start) > 10 ) { - Common::instance()->logMessage( string("GsmModem::Command time out --") + command); + Common::instance()->logMessage( string("ModemTransceiver::Command time out --") + command); Common::instance()->logMessage( string("Modem responded: ") + Util::str_trim(response) ); _timeout = true; break; @@ -84,7 +85,7 @@ return response; } -vector GsmModem::ReadSms(bool readAll) +vector ModemTransceiver::ReadSms(bool readAll) { Command( "AT+CMGF=0" ); //Set SMS format to PDU @@ -109,7 +110,7 @@ string sms_entry = result.substr(0,endpos); - retval.push_back( SMS::FromPduString(sms_entry) );; + retval.push_back( SmsHelper::FromPduString(sms_entry) );; if (endpos == string::npos) break; @@ -121,7 +122,7 @@ } -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") ); @@ -141,14 +142,14 @@ 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); if (to.at(0) == '+') to.erase(0,0); - vector pdu_vec = SmsPdu::CreateSmsPdu(to, message, allowMultipart); + vector pdu_vec = SmsPdu::CreateSmsPdu(to, Util::str_latin2gsm(message), allowMultipart); for (unsigned i=0; ilogMessage( "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); for (unsigned int i= 0; i