A library for talking to Multi-Tech's Cellular SocketModem Devices.
Dependents: M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more
cellular/Cellular.h
- Committer:
- sgodinez
- Date:
- 2013-12-13
- Revision:
- 11:134435d8a2d5
- Parent:
- 5:93e889a5abc6
- Child:
- 13:0af863114629
File content as of revision 11:134435d8a2d5:
#ifndef CELLULAR_H #define CELLULAR_H #include "IPStack.h" #include "MTSBufferedIO.h" #include "mbed.h" #include <string> #include <vector> class Cellular : virtual IPStack { public: enum Code { OK, ERROR, NO_RESPONSE, FAILURE }; enum ESC_CHAR { CR, CTRL_Z }; enum Registration { NOT_REGISTERED, REGISTERED, SEARCHING, DENIED, UNKNOWN, ROAMING }; struct Sms { std::string phoneNumber; std::string message; std::string timestamp; }; Cellular(MTSBufferedIO& io); ~Cellular(); virtual bool connect(); // Parameters for this function will vary between devices!!! virtual void disconnect(); virtual bool isConnected(); // Used for TCPSocketConnection & UDPSocketConnection virtual bool bind(unsigned int port); virtual bool open(const std::string& address, unsigned int port, Mode mode); virtual bool isOpen(); virtual void close(); virtual int read(char* data, int max, int timeout = -1); virtual int write(char* data, int length, int timeout = -1); virtual unsigned int readable(); virtual unsigned int writeable(); //Other virtual void reset(); //Cellular Radio Specific std::string sendCommand(std::string command, int timeoutMillis, ESC_CHAR esc = CR); Code sendBasicCommand(std::string command, int timeoutMillis, ESC_CHAR esc = CR); Code test(); Code echoOff(bool state); int getSignalStrength(); std::string getPhoneNumber(); Registration getRegistration(); Code setApn(const std::string& apn); Code setDns(const std::string& apn); //SMS Code sendSMS(const std::string& phoneNumber, const std::string& message); Code sendSMS(const Sms& sms); std::vector<Cellular::Sms> getReceivedSms(); Code deleteAllReceivedSms(); Code deleteOnlyReceivedReadSms(); Code getCode(); private: MTSBufferedIO& io; Code code; bool pppConnected; std::string apn; Mode mode; bool socketOpened; unsigned int local_port; unsigned int host_port; std::string host_address; }; #endif /* CELLULAR_H */