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: wifi/Wifi.h
- Revision:
- 69:f3e696bbb0d5
- Child:
- 73:bb5bbca971ae
- Child:
- 74:9f87bd22c222
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wifi/Wifi.h Thu Dec 26 14:46:40 2013 +0000 @@ -0,0 +1,70 @@ +#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. + + Wifi(); //Private constructor, use the getInstance() method. + Wifi(MTSBufferedIO* io); //Private constructor, use the getInstance() method. +}; + +#endif /* WIFI_H */ \ No newline at end of file