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:
- 138:a233b9775f93
- Parent:
- 131:da8f0e1c264a
- Child:
- 139:73a7d1cd2e9c
--- a/wifi/Wifi.h Fri Jan 03 22:42:06 2014 +0000 +++ b/wifi/Wifi.h Sat Jan 04 00:55:16 2014 +0000 @@ -5,6 +5,7 @@ #include "MTSBufferedIO.h" #include "mbed.h" #include <string> +#include <vector> using namespace mts; @@ -36,33 +37,33 @@ * std::string ssid = "Your SSID goes here"; * std::string securityKey = "Your secuirty key goes here"; * Wifi::SecurityType securityType = Wifi::WPA2; -* +* * //Wait for wifi module to boot up * for (int i = 10; i >= 0; i = i - 2) { * wait(2); * printf("Waiting %d seconds...\n\r", i); -* } +* } * * //Setup serial interface to WiFi module * MTSSerial* serial = new MTSSerial(PTD3, PTD2, 256, 256); * serial->baud(9600); -* +* * //Setup Wifi class * Wifi* wifi = Wifi::getInstance(); * printf("Init: %s\n\r", wifi->init(serial) ? "SUCCESS" : "FAILURE"); -* +* * //Setup and check connection * printf("Set Network: %s\n\r", getCodeNames(wifi->setNetwork(ssid, securityType, securityKey)).c_str()); * printf("Set DHCP: %s\n\r", getCodeNames(wifi->setDeviceIP("DHCP")).c_str()); * printf("Connect: %s\n\r", wifi->connect() ? "Success" : "Failure"); * printf("Is Connected: %s\n\r", wifi->isConnected() ? "True" : "False"); * printf("Ping Server: %s\n\r", wifi->ping("8.8.8.8") ? "Success" : "Failed"); -* +* * //Disconnect from network * printf("Disconnecting...\n\r"); * wifi->disconnect(); * printf("Is Connected: %s\n\r", wifi->isConnected() ? "True" : "False"); -* +* * printf("End Program\n\r"); * } * @endcode @@ -181,7 +182,7 @@ * @param key the security key for the network. The default is no key. */ Code setNetwork(const std::string& ssid, SecurityType type = NONE, const std::string& key = ""); - + /** This method is used to set the IP address or puts the module in DHCP mode. * * @param address the IP address you want to use in the form of xxx.xxx.xxx.xxx or DHCP @@ -189,7 +190,7 @@ * @returns the standard Code enumeration. */ Code setDeviceIP(std::string address = "DHCP"); - + /** This method is used to get the IP address of the device, which can be * set either statically or via DHCP after connecting to a network. * @@ -253,6 +254,7 @@ Wifi(); //Private constructor, use the getInstance() method. Wifi(MTSBufferedIO* io); //Private constructor, use the getInstance() method. bool sortInterfaceMode(void); // module gets in wierd state without IO reset + std::string getHostByName(std::string url); // Gets the IP address for a URL }; #endif /* WIFI_H */ \ No newline at end of file