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 SerialPort; |
15 |
|
|
|
class IGsmModem |
|
|
{ |
|
|
public: |
|
|
virtual void SendSms(std::string to, std::string message) = 0; |
|
|
virtual ~IGsmModem() {} |
|
|
}; |
|
16 |
|
|
17 |
class GsmModem : public IGsmModem |
class GsmModem : public IGsmModem |
18 |
{ |
{ |
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 |
|
|
28 |
|
virtual std::vector<SMS> ReadSms(bool readAll=false); |
29 |
|
|
30 |
virtual void SendSms(std::string to, std::string message); |
virtual void DeleteSms(std::string smsIndex); |
31 |
std::vector<SMS> ReadSms(bool readAll=false); |
virtual int DeleteAllSms(); |
|
void DeleteSms(std::string smsIndex); |
|
|
int DeleteAllSms(); |
|
32 |
private: |
private: |
|
void Init(); |
|
33 |
std::string GetResponse(); |
std::string GetResponse(); |
34 |
std::string Command(std::string command, std::string term = "OK\r\n"); |
std::string Command(std::string command, std::string term = "OK\r\n"); |
35 |
|
|
36 |
|
void HandlePincode(); |
37 |
|
void WaitForSimcard(); |
38 |
|
|
39 |
|
bool _timeout; |
40 |
SerialPort& m_port; |
SerialPort& m_port; |
41 |
}; |
}; |
42 |
|
|
43 |
class DebugGsmModem : public IGsmModem |
class DebugGsmModem : public IGsmModem |
44 |
{ |
{ |
45 |
public: |
public: |
46 |
virtual void SendSms(std::string to, std::string message) |
DebugGsmModem() : _print(false) {} |
47 |
{_to=to; _message = message;} |
DebugGsmModem(bool print) : _print(print) {} |
48 |
|
|
49 |
|
|
50 |
|
virtual std::vector<SMS> ReadSms(bool readAll=false); |
51 |
|
virtual void SendSms(std::string to, std::string message, bool allowMultipart); |
52 |
|
|
53 |
|
virtual void DeleteSms(std::string smsIndex) {} |
54 |
|
virtual int DeleteAllSms() { return 0;} |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
std::string GetTo() {return _to;} |
std::string GetTo() {return _to;} |
59 |
std::string GetMessage() {return _message;} |
std::string GetMessage() {return _message;} |
60 |
|
bool GetMultipart() {return _multipart;} |
61 |
private: |
private: |
62 |
std::string _to; |
std::string _to; |
63 |
std::string _message; |
std::string _message; |
64 |
|
bool _multipart; |
65 |
|
bool _print; |
66 |
}; |
}; |
67 |
|
|
68 |
#endif // __GSMMODEM_H__ |
#endif // __GSMMODEM_H__ |