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
Diff: cellular/Cellular.h
- Revision:
- 11:134435d8a2d5
- Parent:
- 5:93e889a5abc6
- Child:
- 13:0af863114629
--- a/cellular/Cellular.h Thu Dec 12 14:45:23 2013 +0000 +++ b/cellular/Cellular.h Fri Dec 13 20:18:47 2013 +0000 @@ -1,12 +1,13 @@ #ifndef CELLULAR_H #define CELLULAR_H +#include "IPStack.h" +#include "MTSBufferedIO.h" #include "mbed.h" -#include "MTSBufferedIO.h" #include <string> #include <vector> -class Cellular +class Cellular : virtual IPStack { public: enum Code { @@ -31,14 +32,34 @@ Cellular(MTSBufferedIO& io); ~Cellular(); - string sendCommand(string command, int timeoutMillis, ESC_CHAR esc = CR); - Code sendBasicCommand(string command, int timeoutMillis, ESC_CHAR esc = CR); + virtual bool connect(); // Parameters for this function will vary between devices!!! + virtual void disconnect(); + virtual bool isConnected(); - Code ATTest(); + // 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); @@ -47,10 +68,23 @@ Code deleteAllReceivedSms(); Code deleteOnlyReceivedReadSms(); - int connect(string host, int port); + 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 */ \ No newline at end of file