2 |
*/ |
*/ |
3 |
|
|
4 |
#include <iostream> |
#include <iostream> |
|
|
|
5 |
#include <string> |
#include <string> |
6 |
#include <stdexcept> |
#include <stdexcept> |
7 |
|
|
81 |
|
|
82 |
Util::Sleep(5); |
Util::Sleep(5); |
83 |
|
|
|
// cout << response.length() << ":" << response << endl; |
|
|
// DumpString(response); |
|
84 |
|
|
85 |
return response; |
return response; |
86 |
} |
} |
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 |
|
|
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; |