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

Diff of /smsdaemon/ModemTransceiver.cpp

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

revision 59 by torben, Wed Jun 11 19:42:24 2008 UTC revision 63 by torben, Thu Jun 12 12:43:29 2008 UTC
# Line 17  Line 17 
17  #include "util.h"  #include "util.h"
18  #include "common.h"  #include "common.h"
19    
20    #include "SmsPdu.h"
21    
22  using namespace std;  using namespace std;
23    
# Line 88  string GsmModem::Command(string command, Line 89  string GsmModem::Command(string command,
89    
90  vector<SMS> GsmModem::ReadSms(bool readAll)  vector<SMS> GsmModem::ReadSms(bool readAll)
91  {  {
92    
93            Command( "AT+CMGF=1" ); //Set SMS format to text
94    
95          const string search = "+CMGL: ";          const string search = "+CMGL: ";
96          std::string cmd = "AT+CMGL";          std::string cmd = "AT+CMGL";
97          if (readAll)          if (readAll)
# Line 140  void GsmModem::SendSmsPdu(std::string pd Line 144  void GsmModem::SendSmsPdu(std::string pd
144          Common::instance()->smsCounter.outgoing++;          Common::instance()->smsCounter.outgoing++;
145  }  }
146    
147  void GsmModem::SendSms(string to, string message)  void GsmModem::SendSms(string to, string message, bool allowMultipart)
148  {  {
149          Common::instance()->logMessage( string("SMS send to ") + to);          Common::instance()->logMessage( string("SMS send to ") + to);
150    
151          Command("AT+CMGF=1");///Allways telling the format makes the application more stable          if (to.at(0) == '+')
152          Util::Sleep(2);                  to.erase(0,0);
   
         string line1 = "AT+CMGS=";  
         line1.append(to);  
         line1.append("\r");  
153    
154          Command(line1,"> ");          vector<PduInfo> pdu_vec = SmsPdu::CreateSmsPdu(to, message, allowMultipart);
155    
156          if (message.length() > 160)          for (unsigned i=0; i<pdu_vec.size(); ++i)
157          {          {
158                  message = message.substr(0,160);                  PduInfo& pdu = pdu_vec[i];
                 Common::instance()->logMessage( "Trunkating message! ");  
         }  
   
         message.append("\032"); // \032 == Ctrl+Z  
   
         Command( message ); //In textmode limit to 160 bytes  
159    
160                    SendSmsPdu(pdu.pdu, pdu.len);
161            }
162    
         Util::Sleep(50); //Give the modem some time to send the sms and be ready again  
         Common::instance()->smsCounter.outgoing++;  
163  }  }
164    
165  void GsmModem::DeleteSms(std::string smsIndex)  void GsmModem::DeleteSms(std::string smsIndex)
# Line 200  void GsmModem::Init() Line 194  void GsmModem::Init()
194    
195          Command( "ATE0" ); //Disable echo          Command( "ATE0" ); //Disable echo
196    
         Command( "AT+CMGF=1" ); //Set SMS format to text  
   
197          Command ("AT^SM20=0,0" ); //No SM20 compability          Command ("AT^SM20=0,0" ); //No SM20 compability
198    
199          //Set RealTimeClock ??          //Set RealTimeClock ??

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

  ViewVC Help
Powered by ViewVC 1.1.20