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

Diff of /smsdaemon/ModemTransceiver.cpp

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

revision 26 by torben, Mon Jun 9 18:15:53 2008 UTC revision 49 by torben, Wed Jun 11 10:21:47 2008 UTC
# Line 44  string GsmModem::GetResponse() Line 44  string GsmModem::GetResponse()
44          return str;          return str;
45  }  }
46    
47    
48  string GsmModem::Command(string command, string term)  string GsmModem::Command(string command, string term)
49  {  {
50          time_t  start,now;          time_t  start,now;
51          start = time(0);          start = time(0);
52    
53          command.append("\r");          if (term != "> ")
54                    command.append("\r"); //Dont append CarriageReturn if sending SMS
55    
56          m_port.Write(command);          m_port.Write(command);
57    
58          Util::Sleep(25);          Util::Sleep(1);
59          string response = GetResponse();          string response = GetResponse();
60    
   
61          unsigned int tlen = term.length();          unsigned int tlen = term.length();
62          while ( 1 )          while ( 1 )
63          {          {
# Line 66  string GsmModem::Command(string command, Line 68  string GsmModem::Command(string command,
68                  }                  }
69    
70                  response += GetResponse();                  response += GetResponse();
71                  Util::Sleep(25);                  Util::Sleep(1);
72    
73          now = time(0);          now = time(0);
74          if ( (now-start) > 10 )          if ( (now-start) > 10 )
# Line 74  string GsmModem::Command(string command, Line 76  string GsmModem::Command(string command,
76                  Common::instance()->logMessage( string("GsmModem::Command time out --") + command);                  Common::instance()->logMessage( string("GsmModem::Command time out --") + command);
77              break;              break;
78          }          }
   
   
79          }          }
80    
81          Util::Sleep(5);          Util::Sleep(5);
# Line 133  void GsmModem::SendSms(string to, string Line 133  void GsmModem::SendSms(string to, string
133          Command(line1,"> ");          Command(line1,"> ");
134    
135    
136          message.append("\032\r"); // \032 == Ctrl+Z          message.append("\032"); // \032 == Ctrl+Z
137    
138            Command( message.substr(0,160) ); //In textmode limit to 160 bytes
139    
140    
         Command(message);  
141          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
142            Common::instance()->smsCounter.outgoing++;
143  }  }
144    
145  void GsmModem::DeleteSms(std::string smsIndex)  void GsmModem::DeleteSms(std::string smsIndex)
# Line 162  int  GsmModem::DeleteAllSms() Line 165  int  GsmModem::DeleteAllSms()
165  void GsmModem::Init()  void GsmModem::Init()
166  {  {
167          Command( "ATZ" ); //Reset any previous setup          Command( "ATZ" ); //Reset any previous setup
168            Command( "AT\\Q3" ); //Hardware flow control
169    
170          Command( "ATE0" ); //Disable echo          Command( "ATE0" ); //Disable echo
171    

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

  ViewVC Help
Powered by ViewVC 1.1.20