/[projects]/smsdaemon/ModemTransceiver.cpp
ViewVC logotype

Diff of /smsdaemon/ModemTransceiver.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 49 by torben, Wed Jun 11 10:21:47 2008 UTC revision 58 by torben, Wed Jun 11 16:14:28 2008 UTC
# Line 26  using namespace std; Line 26  using namespace std;
26  GsmModem::GsmModem(SerialPort& serialport)  GsmModem::GsmModem(SerialPort& serialport)
27  : m_port(serialport)  : m_port(serialport)
28  {  {
         Init();  
29  }  }
30    
31    
# Line 49  string GsmModem::Command(string command, Line 48  string GsmModem::Command(string command,
48  {  {
49          time_t  start,now;          time_t  start,now;
50          start = time(0);          start = time(0);
51            _timeout = false;
52    
53          if (term != "> ")          if (term != "> ")
54                  command.append("\r"); //Dont append CarriageReturn if sending SMS                  command.append("\r"); //Dont append CarriageReturn if sending SMS
# Line 74  string GsmModem::Command(string command, Line 74  string GsmModem::Command(string command,
74          if ( (now-start) > 10 )          if ( (now-start) > 10 )
75          {          {
76                  Common::instance()->logMessage( string("GsmModem::Command time out --") + command);                  Common::instance()->logMessage( string("GsmModem::Command time out --") + command);
77                            _timeout = true;
78              break;              break;
79          }          }
80          }          }
# Line 132  void GsmModem::SendSms(string to, string Line 133  void GsmModem::SendSms(string to, string
133    
134          Command(line1,"> ");          Command(line1,"> ");
135    
136            if (message.length() > 160)
137            {
138                    message = message.substr(0,160);
139                    Common::instance()->logMessage( "Trunkating message! ");
140            }
141    
142          message.append("\032"); // \032 == Ctrl+Z          message.append("\032"); // \032 == Ctrl+Z
143    
144          Command( message.substr(0,160) ); //In textmode limit to 160 bytes          Command( message ); //In textmode limit to 160 bytes
145    
146    
147          Util::Sleep(50); //Give the modem some time to send the sms and be ready again          Util::Sleep(50); //Give the modem some time to send the sms and be ready again
# Line 164  int  GsmModem::DeleteAllSms() Line 170  int  GsmModem::DeleteAllSms()
170    
171  void GsmModem::Init()  void GsmModem::Init()
172  {  {
173            Command( "AT" );
174            if (_timeout)
175                    throw std::runtime_error("Modem did not respond!");
176    
177          Command( "ATZ" ); //Reset any previous setup          Command( "ATZ" ); //Reset any previous setup
178    
179          Command( "AT\\Q3" ); //Hardware flow control          Command( "AT\\Q3" ); //Hardware flow control
180    
181          Command( "ATE0" ); //Disable echo          Command( "ATE0" ); //Disable echo

Legend:
Removed from v.49  
changed lines
  Added in v.58

  ViewVC Help
Powered by ViewVC 1.1.20