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