1 |
#ifndef __GSMMODEM_H__ |
#ifndef __MODEMTRANSCEIVER_H__ |
2 |
#define __GSMMODEM_H__ |
#define __MODEMTRANSCEIVER_H__ |
3 |
|
|
|
/* using http://sourceforge.net/projects/libserial/ |
|
|
*/ |
|
4 |
|
|
5 |
|
|
6 |
|
#include "ISmsTransceiver.h" |
7 |
|
|
8 |
#include <string> |
#include <string> |
9 |
#include <vector> |
#include <vector> |
10 |
|
|
12 |
|
|
13 |
class SerialPort; |
class SerialPort; |
14 |
|
|
|
class IGsmModem |
|
|
{ |
|
|
public: |
|
|
virtual void SendSms(std::string to, std::string message) = 0; |
|
|
virtual ~IGsmModem() {} |
|
|
}; |
|
15 |
|
|
16 |
class GsmModem : public IGsmModem |
class ModemTransceiver : public ISmsTransceiver |
17 |
{ |
{ |
18 |
public: |
public: |
19 |
GsmModem(SerialPort& serialport); |
ModemTransceiver(SerialPort& serialport); |
20 |
virtual ~GsmModem() {} |
virtual ~ModemTransceiver() {} |
21 |
|
|
22 |
void Init(); |
void Init(); |
23 |
|
|
24 |
virtual void SendSms(std::string to, std::string message); |
virtual void SendSms(std::string to, std::string message, bool allowMultipart); |
25 |
void SendSmsPdu(std::string pdu, int len); |
void SendSmsPdu(std::string pdu, int len); |
26 |
|
|
27 |
std::vector<SMS> ReadSms(bool readAll=false); |
virtual std::vector<SMS> ReadSms(bool readAll=false); |
28 |
void DeleteSms(std::string smsIndex); |
|
29 |
int DeleteAllSms(); |
virtual void DeleteSms(std::string smsIndex); |
30 |
|
virtual int DeleteAllSms(); |
31 |
private: |
private: |
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 |
|
void HandlePincode(); |
36 |
|
void WaitForSimcard(); |
37 |
|
|
38 |
bool _timeout; |
bool _timeout; |
39 |
SerialPort& m_port; |
SerialPort& m_port; |
40 |
}; |
}; |
41 |
|
|
|
class DebugGsmModem : public IGsmModem |
|
|
{ |
|
|
public: |
|
|
virtual void SendSms(std::string to, std::string message) |
|
|
{_to=to; _message = message;} |
|
|
|
|
|
std::string GetTo() {return _to;} |
|
|
std::string GetMessage() {return _message;} |
|
|
private: |
|
|
std::string _to; |
|
|
std::string _message; |
|
|
}; |
|
42 |
|
|
43 |
#endif // __GSMMODEM_H__ |
#endif // __MODEMTRANSCEIVER_H__ |