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

Diff of /smsdaemon/ModemTransceiver.cpp

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

smsdaemon/GsmModem.cpp revision 144 by torben, Sun Dec 7 16:27:34 2008 UTC smsdaemon/ModemTransceiver.cpp revision 149 by torben, Sun Dec 7 20:58:41 2008 UTC
# Line 10  Line 10 
10    
11  #include "serialport/SerialPort.h"  #include "serialport/SerialPort.h"
12    
13  #include "GsmModem.h"  #include "ModemTransceiver.h"
14    
15  #include "util.h"  #include "util.h"
16  #include "common.h"  #include "common.h"
# Line 22  using namespace std; Line 22  using namespace std;
22    
23    
24    
25  GsmModem::GsmModem(SerialPort& serialport)  ModemTransceiver::ModemTransceiver(SerialPort& serialport)
26  : m_port(serialport)  : m_port(serialport)
27  {  {
28  }  }
29    
30    
31    
32  string GsmModem::GetResponse()  string ModemTransceiver::GetResponse()
33  {  {
34    
35          SerialPort::DataBuffer buf;          SerialPort::DataBuffer buf;
# Line 43  string GsmModem::GetResponse() Line 43  string GsmModem::GetResponse()
43  }  }
44    
45    
46  string GsmModem::Command(string command, string term)  string ModemTransceiver::Command(string command, string term)
47  {  {
48          time_t  start,now;          time_t  start,now;
49          start = time(0);          start = time(0);
# Line 72  string GsmModem::Command(string command, Line 72  string GsmModem::Command(string command,
72          now = time(0);          now = time(0);
73          if ( (now-start) > 10 )          if ( (now-start) > 10 )
74          {          {
75                  Common::instance()->logMessage( string("GsmModem::Command time out --") + command);                  Common::instance()->logMessage( string("ModemTransceiver::Command time out --") + command);
76                          Common::instance()->logMessage( string("Modem responded: ") + Util::str_trim(response) );                          Common::instance()->logMessage( string("Modem responded: ") + Util::str_trim(response) );
77                          _timeout = true;                          _timeout = true;
78              break;              break;
# Line 85  string GsmModem::Command(string command, Line 85  string GsmModem::Command(string command,
85          return response;          return response;
86  }  }
87    
88  vector<SMS> GsmModem::ReadSms(bool readAll)  vector<SMS> ModemTransceiver::ReadSms(bool readAll)
89  {  {
90    
91          Command( "AT+CMGF=0" ); //Set SMS format to PDU          Command( "AT+CMGF=0" ); //Set SMS format to PDU
# Line 122  vector<SMS> GsmModem::ReadSms(bool readA Line 122  vector<SMS> GsmModem::ReadSms(bool readA
122  }  }
123    
124    
125  void GsmModem::SendSmsPdu(std::string pdu, int len) //pdu inclussive leading "00"  void ModemTransceiver::SendSmsPdu(std::string pdu, int len) //pdu inclussive leading "00"
126  {  {
127          Common::instance()->logMessage( string("SMS pdu send") );          Common::instance()->logMessage( string("SMS pdu send") );
128    
# Line 142  void GsmModem::SendSmsPdu(std::string pd Line 142  void GsmModem::SendSmsPdu(std::string pd
142          Common::instance()->smsCounter.outgoing++;          Common::instance()->smsCounter.outgoing++;
143  }  }
144    
145  void GsmModem::SendSms(string to, string message, bool allowMultipart)  void ModemTransceiver::SendSms(string to, string message, bool allowMultipart)
146  {  {
147          Common::instance()->logMessage( string("SMS send to ") + to);          Common::instance()->logMessage( string("SMS send to ") + to);
148    
# Line 161  void GsmModem::SendSms(string to, string Line 161  void GsmModem::SendSms(string to, string
161    
162  }  }
163    
164  void GsmModem::DeleteSms(std::string smsIndex)  void ModemTransceiver::DeleteSms(std::string smsIndex)
165  {  {
166          string cmd = "AT+CMGD=";          string cmd = "AT+CMGD=";
167          cmd.append(smsIndex);          cmd.append(smsIndex);
168          Command(cmd);          Command(cmd);
169  }  }
170    
171  int  GsmModem::DeleteAllSms()  int  ModemTransceiver::DeleteAllSms()
172  {  {
173          vector<SMS> sms = ReadSms(true);          vector<SMS> sms = ReadSms(true);
174    
# Line 181  int  GsmModem::DeleteAllSms() Line 181  int  GsmModem::DeleteAllSms()
181    
182    
183    
184  void GsmModem::WaitForSimcard()  void ModemTransceiver::WaitForSimcard()
185  {  {
186          int start = time(0);          int start = time(0);
187          string result;          string result;
# Line 199  void GsmModem::WaitForSimcard() Line 199  void GsmModem::WaitForSimcard()
199    
200  }  }
201    
202  void GsmModem::HandlePincode()  void ModemTransceiver::HandlePincode()
203  {  {
204          string result = Command("AT+CPIN?");          string result = Command("AT+CPIN?");
205          result = Util::str_trim(result);          result = Util::str_trim(result);
# Line 224  void GsmModem::HandlePincode() Line 224  void GsmModem::HandlePincode()
224          }          }
225  }  }
226    
227  void GsmModem::Init()  void ModemTransceiver::Init()
228  {  {
229          Command( "AT" );          Command( "AT" );
230          if (_timeout)          if (_timeout)
# Line 246  void GsmModem::Init() Line 246  void GsmModem::Init()
246  }  }
247    
248    
   
   
 void DebugGsmModem::SendSms(std::string to, std::string message, bool allowMultipart)  
 {  
         _to=to;  
         _message = message;  
         _multipart = allowMultipart;  
   
         if (_print)  
         {  
                 cout << "DebugGsmModem::SendSms --------------" << endl;  
                 cout << "To:        " << to << endl;;  
                 cout << "Message:   " << message << endl;  
                 cout << "Multipart: " << allowMultipart << endl;  
   
         }  
 }  
   
 std::vector<SMS> DebugGsmModem::ReadSms(bool readAll)  
 {  
         vector<SMS> result;  
         return result;  
 }  

Legend:
Removed from v.144  
changed lines
  Added in v.149

  ViewVC Help
Powered by ViewVC 1.1.20