--- smsdaemon/GsmModem.cpp 2008/06/10 13:29:19 34 +++ smsdaemon/GsmModem.cpp 2008/06/11 16:08:37 57 @@ -26,7 +26,6 @@ GsmModem::GsmModem(SerialPort& serialport) : m_port(serialport) { - Init(); } @@ -49,6 +48,7 @@ { time_t start,now; start = time(0); + _timeout = false; if (term != "> ") command.append("\r"); //Dont append CarriageReturn if sending SMS @@ -74,6 +74,7 @@ if ( (now-start) > 10 ) { Common::instance()->logMessage( string("GsmModem::Command time out --") + command); + _timeout = true; break; } } @@ -132,11 +133,19 @@ Command(line1,"> "); + if (message.length() > 160) + { + message = message.substr(0,160); + Common::instance()->logMessage( "Trunkating message! "); + } message.append("\032"); // \032 == Ctrl+Z - Command(message); + Command( message ); //In textmode limit to 160 bytes + + 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) @@ -162,6 +171,9 @@ void GsmModem::Init() { Command( "ATZ" ); //Reset any previous setup + if (_timeout) + throw std::runtime_error("Modem did not respond!"); + Command( "AT\\Q3" ); //Hardware flow control Command( "ATE0" ); //Disable echo