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
wifi/Wifi.h
- Committer:
- jengbrecht
- Date:
- 2013-12-26
- Revision:
- 74:9f87bd22c222
- Parent:
- 69:f3e696bbb0d5
- Child:
- 75:7ad32827b39e
File content as of revision 74:9f87bd22c222:
#ifndef WIFI_H #define WIFI_H #include "IPStack.h" #include "MTSBufferedIO.h" #include "mbed.h" #include "Cellular.h" #include <string> #include <vector> using namespace mts; class Wifi : public IPStack { public: enum SecurityType { NONE, WEP64, WEP128, WPA, WPA2 }; ~Wifi(); static Wifi* getInstance(); bool init(MTSBufferedIO* io); virtual bool connect(); virtual void disconnect(); virtual bool isConnected(); // TCP and UDP Socket related commands // For behavior of the following methods refer to IPStack.h documentation virtual bool bind(unsigned int port); virtual bool open(const std::string& address, unsigned int port, Mode mode); virtual bool isOpen(); virtual bool close(); virtual int read(char* data, int max, int timeout = -1); virtual int write(const char* data, int length, int timeout = -1); virtual unsigned int readable(); virtual unsigned int writeable(); virtual void reset(); std::string sendCommand(std::string command, int timeoutMillis, Cellular::ESC_CHAR esc = Cellular::CR); Cellular::Code sendBasicCommand(std::string command, int timeoutMillis, Cellular::ESC_CHAR esc = Cellular::CR); Cellular::Code echo(bool state); Cellular::Code setNetwork(const std::string& ssid, const std::string& key, SecurityType type); int getSignalStrength(); private: static Wifi* instance; //Static pointer to the single Cellular object. MTSBufferedIO* io; //IO interface obect that the radio is accessed through. bool echoMode; //Specifies if the echo mode is currently enabled. bool wifiConnected; //Specifies if a Wifi network session is currently connected. std::string _ssid; //A string that holds the SSID for the Wifi module. Mode mode; //The current socket Mode. bool socketOpened; //Specifies if a Socket is presently opened. bool socketCloseable; //Specifies is a Socket can be closed. unsigned int local_port; //Holds the local port for socket connections. std::string local_address; //Holds the local address for socket connections. unsigned int host_port; //Holds the remote port for socket connections. std::string host_address; //Holds the remote address for socket connections. bool cmdMode(); Wifi(); //Private constructor, use the getInstance() method. Wifi(MTSBufferedIO* io); //Private constructor, use the getInstance() method. }; #endif /* WIFI_H */