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