4 |
/* using http://sourceforge.net/projects/libserial/ |
/* using http://sourceforge.net/projects/libserial/ |
5 |
*/ |
*/ |
6 |
|
|
7 |
|
#include "IGsmModem.h" |
8 |
|
|
9 |
#include <string> |
#include <string> |
10 |
#include <vector> |
#include <vector> |
11 |
|
|
|
#include "SerialPort.h" |
|
12 |
#include "Sms.h" |
#include "Sms.h" |
13 |
|
|
14 |
class GsmModem |
class SerialPort; |
15 |
|
|
16 |
|
|
17 |
|
class GsmModem : public IGsmModem |
18 |
{ |
{ |
19 |
public: |
public: |
20 |
GsmModem(SerialPort& serialport); |
GsmModem(SerialPort& serialport); |
21 |
virtual ~GsmModem() {} |
virtual ~GsmModem() {} |
22 |
|
|
23 |
|
void Init(); |
24 |
|
|
25 |
|
virtual void SendSms(std::string to, std::string message, bool allowMultipart); |
26 |
|
void SendSmsPdu(std::string pdu, int len); |
27 |
|
|
|
void SendSms(std::string to, std::string message); |
|
28 |
std::vector<SMS> ReadSms(bool readAll=false); |
std::vector<SMS> ReadSms(bool readAll=false); |
29 |
void DeleteSms(std::string smsIndex); |
void DeleteSms(std::string smsIndex); |
30 |
int DeleteAllSms(); |
int DeleteAllSms(); |
31 |
private: |
private: |
|
void Init(); |
|
32 |
std::string GetResponse(); |
std::string GetResponse(); |
33 |
std::string Command(std::string command, std::string term = "OK\r\n"); |
std::string Command(std::string command, std::string term = "OK\r\n"); |
34 |
|
|
35 |
|
bool _timeout; |
36 |
SerialPort& m_port; |
SerialPort& m_port; |
37 |
}; |
}; |
38 |
|
|
39 |
|
class DebugGsmModem : public IGsmModem |
40 |
|
{ |
41 |
|
public: |
42 |
|
DebugGsmModem() : _print(false) {} |
43 |
|
DebugGsmModem(bool print) : _print(print) {} |
44 |
|
|
45 |
|
|
46 |
|
virtual void SendSms(std::string to, std::string message, bool allowMultipart); |
47 |
|
|
48 |
|
std::string GetTo() {return _to;} |
49 |
|
std::string GetMessage() {return _message;} |
50 |
|
bool GetMultipart() {return _multipart;} |
51 |
|
private: |
52 |
|
std::string _to; |
53 |
|
std::string _message; |
54 |
|
bool _multipart; |
55 |
|
bool _print; |
56 |
|
}; |
57 |
|
|
58 |
#endif // __GSMMODEM_H__ |
#endif // __GSMMODEM_H__ |