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

Diff of /smsdaemon/ModemTransceiver.cpp

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

revision 63 by torben, Thu Jun 12 12:43:29 2008 UTC revision 75 by torben, Fri Jun 13 10:10:06 2008 UTC
# Line 2  Line 2 
2   */   */
3    
4  #include <iostream>  #include <iostream>
   
5  #include <string>  #include <string>
6  #include <stdexcept>  #include <stdexcept>
7    
# Line 74  string GsmModem::Command(string command, Line 73  string GsmModem::Command(string command,
73          if ( (now-start) > 10 )          if ( (now-start) > 10 )
74          {          {
75                  Common::instance()->logMessage( string("GsmModem::Command time out --") + command);                  Common::instance()->logMessage( string("GsmModem::Command time out --") + command);
76                            Common::instance()->logMessage( string("Modem responded: ") + Util::str_trim(response) );
77                          _timeout = true;                          _timeout = true;
78              break;              break;
79          }          }
# Line 81  string GsmModem::Command(string command, Line 81  string GsmModem::Command(string command,
81    
82          Util::Sleep(5);          Util::Sleep(5);
83    
 //      cout  << response.length() << ":" << response << endl;  
 //      DumpString(response);  
84    
85          return response;          return response;
86  }  }
# Line 90  string GsmModem::Command(string command, Line 88  string GsmModem::Command(string command,
88  vector<SMS> GsmModem::ReadSms(bool readAll)  vector<SMS> GsmModem::ReadSms(bool readAll)
89  {  {
90    
91          Command( "AT+CMGF=1" ); //Set SMS format to text          Command( "AT+CMGF=0" ); //Set SMS format to PDU
92    
93          const string search = "+CMGL: ";          const string search = "+CMGL: ";
94          std::string cmd = "AT+CMGL";          std::string cmd = "AT+CMGL";
95          if (readAll)          if (readAll)
96                  cmd.append("=ALL");                  cmd.append("=4");
97    
98          string result = Command(cmd);          string result = Command(cmd);
99                                    
# Line 112  vector<SMS> GsmModem::ReadSms(bool readA Line 110  vector<SMS> GsmModem::ReadSms(bool readA
110    
111                                    
112                  string sms_entry = result.substr(0,endpos);                  string sms_entry = result.substr(0,endpos);
113                  retval.push_back( SMS::FromRawString(sms_entry) );;                  retval.push_back( SMS::FromPduString(sms_entry) );;
114    
115                  if (endpos == string::npos)                  if (endpos == string::npos)
116                          break;                          break;
# Line 202  void GsmModem::Init() Line 200  void GsmModem::Init()
200  }  }
201    
202    
203    
204    
205    void DebugGsmModem::SendSms(std::string to, std::string message, bool allowMultipart)
206    {
207            _to=to;
208            _message = message;
209            _multipart = allowMultipart;
210    
211            if (_print)
212            {
213                    cout << "DebugGsmModem::SendSms --------------" << endl;
214                    cout << "To:        " << to << endl;;
215                    cout << "Message:   " << message << endl;
216                    cout << "Multipart: " << allowMultipart << endl;
217    
218            }
219    }
220    

Legend:
Removed from v.63  
changed lines
  Added in v.75

  ViewVC Help
Powered by ViewVC 1.1.20