--- smsdaemon/GsmModem.h 2008/06/12 15:23:11 67 +++ smsdaemon/ModemTransceiver.h 2010/04/27 21:06:53 678 @@ -1,10 +1,10 @@ -#ifndef __GSMMODEM_H__ -#define __GSMMODEM_H__ +#ifndef __MODEMTRANSCEIVER_H__ +#define __MODEMTRANSCEIVER_H__ -/* using http://sourceforge.net/projects/libserial/ - */ +#include "ISmsTransceiver.h" + #include #include @@ -12,52 +12,35 @@ class SerialPort; -class IGsmModem -{ -public: - virtual void SendSms(std::string to, std::string message, bool allowMultipart) = 0; - virtual ~IGsmModem() {} -}; -class GsmModem : public IGsmModem +class ModemTransceiver : public ISmsTransceiver { public: - GsmModem(SerialPort& serialport); - virtual ~GsmModem() {} + ModemTransceiver(SerialPort& serialport); + virtual ~ModemTransceiver() {} void Init(); virtual void SendSms(std::string to, std::string message, bool allowMultipart); - void SendSmsPdu(std::string pdu, int len); + void SendSmsPdu(std::string pdu, int len); + + virtual std::vector ReadSms(bool readAll=false); - std::vector ReadSms(bool readAll=false); void DeleteSms(std::string smsIndex); - int DeleteAllSms(); private: std::string GetResponse(); std::string Command(std::string command, std::string term = "OK\r\n"); + //decode an CMGF=1 text string + SMS FromRawString(const std::string& input); + SMS FromPduString(const std::string& input); + + void HandlePincode(); + void WaitForSimcard(); + bool _timeout; SerialPort& m_port; }; -class DebugGsmModem : public IGsmModem -{ -public: - DebugGsmModem() : _print(false) {} - DebugGsmModem(bool print) : _print(print) {} - - - virtual void SendSms(std::string to, std::string message, bool allowMultipart); - - std::string GetTo() {return _to;} - std::string GetMessage() {return _message;} - bool GetMultipart() {return _multipart;} -private: - std::string _to; - std::string _message; - bool _multipart; - bool _print; -}; -#endif // __GSMMODEM_H__ +#endif // __MODEMTRANSCEIVER_H__