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

Diff of /smsdaemon/ModemTransceiver.cpp

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

revision 67 by torben, Thu Jun 12 15:23:11 2008 UTC revision 93 by torben, Mon Jun 16 11:39:33 2008 UTC
# Line 2  Line 2 
2   */   */
3    
4  #include <iostream>  #include <iostream>
   
5  #include <string>  #include <string>
6  #include <stdexcept>  #include <stdexcept>
7    
 #include <sys/time.h>  
8  #include <time.h>  #include <time.h>
9    
10    
# Line 74  string GsmModem::Command(string command, Line 72  string GsmModem::Command(string command,
72          if ( (now-start) > 10 )          if ( (now-start) > 10 )
73          {          {
74                  Common::instance()->logMessage( string("GsmModem::Command time out --") + command);                  Common::instance()->logMessage( string("GsmModem::Command time out --") + command);
75                            Common::instance()->logMessage( string("Modem responded: ") + Util::str_trim(response) );
76                          _timeout = true;                          _timeout = true;
77              break;              break;
78          }          }
# Line 81  string GsmModem::Command(string command, Line 80  string GsmModem::Command(string command,
80    
81          Util::Sleep(5);          Util::Sleep(5);
82    
 //      cout  << response.length() << ":" << response << endl;  
 //      DumpString(response);  
83    
84          return response;          return response;
85  }  }
# Line 90  string GsmModem::Command(string command, Line 87  string GsmModem::Command(string command,
87  vector<SMS> GsmModem::ReadSms(bool readAll)  vector<SMS> GsmModem::ReadSms(bool readAll)
88  {  {
89    
90          Command( "AT+CMGF=1" ); //Set SMS format to text          Command( "AT+CMGF=0" ); //Set SMS format to PDU
91    
92          const string search = "+CMGL: ";          const string search = "+CMGL: ";
93          std::string cmd = "AT+CMGL";          std::string cmd = "AT+CMGL";
94          if (readAll)          if (readAll)
95                  cmd.append("=ALL");                  cmd.append("=4");
96    
97          string result = Command(cmd);          string result = Command(cmd);
98                                    
# Line 112  vector<SMS> GsmModem::ReadSms(bool readA Line 109  vector<SMS> GsmModem::ReadSms(bool readA
109    
110                                    
111                  string sms_entry = result.substr(0,endpos);                  string sms_entry = result.substr(0,endpos);
112                  retval.push_back( SMS::FromRawString(sms_entry) );;                  retval.push_back( SMS::FromPduString(sms_entry) );;
113    
114                  if (endpos == string::npos)                  if (endpos == string::npos)
115                          break;                          break;
# Line 196  void GsmModem::Init() Line 193  void GsmModem::Init()
193    
194          Command ("AT^SM20=0,0" ); //No SM20 compability          Command ("AT^SM20=0,0" ); //No SM20 compability
195    
196            //Command("AT+CGATT=1"); //GPRS Attach
197    
198            //Command("AT+CGSMS=2"); //SMS over GPRS preferred
199    
200          //Set RealTimeClock ??          //Set RealTimeClock ??
201                    
202          //Enter pin code ??          //Enter pin code ??

Legend:
Removed from v.67  
changed lines
  Added in v.93

  ViewVC Help
Powered by ViewVC 1.1.20