--- smsdaemon/GsmModem.cpp 2008/06/12 12:04:32 62 +++ smsdaemon/GsmModem.cpp 2008/06/12 12:43:29 63 @@ -17,6 +17,7 @@ #include "util.h" #include "common.h" +#include "SmsPdu.h" using namespace std; @@ -88,6 +89,9 @@ vector GsmModem::ReadSms(bool readAll) { + + Command( "AT+CMGF=1" ); //Set SMS format to text + const string search = "+CMGL: "; std::string cmd = "AT+CMGL"; if (readAll) @@ -140,32 +144,22 @@ Common::instance()->smsCounter.outgoing++; } -void GsmModem::SendSms(string to, string message) +void GsmModem::SendSms(string to, string message, bool allowMultipart) { Common::instance()->logMessage( string("SMS send to ") + to); - Command("AT+CMGF=1");///Allways telling the format makes the application more stable - Util::Sleep(2); - - string line1 = "AT+CMGS="; - line1.append(to); - line1.append("\r"); + if (to.at(0) == '+') + to.erase(0,0); - Command(line1,"> "); + vector pdu_vec = SmsPdu::CreateSmsPdu(to, message, allowMultipart); - if (message.length() > 160) + for (unsigned i=0; ilogMessage( "Trunkating message! "); - } - - message.append("\032"); // \032 == Ctrl+Z - - Command( message ); //In textmode limit to 160 bytes + PduInfo& pdu = pdu_vec[i]; + SendSmsPdu(pdu.pdu, pdu.len); + } - Util::Sleep(50); //Give the modem some time to send the sms and be ready again - Common::instance()->smsCounter.outgoing++; } void GsmModem::DeleteSms(std::string smsIndex) @@ -200,8 +194,6 @@ Command( "ATE0" ); //Disable echo - Command( "AT+CMGF=1" ); //Set SMS format to text - Command ("AT^SM20=0,0" ); //No SM20 compability //Set RealTimeClock ??