see http://mbed.org/users/okini3939/notebook/wattmeter-shield-on-mbed/

Dependencies:   mbed

Fork of GSwifi_xively by gs fan

Committer:
okini3939
Date:
Wed Nov 27 08:18:45 2013 +0000
Revision:
4:9a2415f2ab07
update GSwifiInterface library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 4:9a2415f2ab07 1 /* GSwifiInterface.h */
okini3939 4:9a2415f2ab07 2 /* EthernetInterface.h */
okini3939 4:9a2415f2ab07 3 /* Copyright (C) 2012 mbed.org, MIT License
okini3939 4:9a2415f2ab07 4 *
okini3939 4:9a2415f2ab07 5 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
okini3939 4:9a2415f2ab07 6 * and associated documentation files (the "Software"), to deal in the Software without restriction,
okini3939 4:9a2415f2ab07 7 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
okini3939 4:9a2415f2ab07 8 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
okini3939 4:9a2415f2ab07 9 * furnished to do so, subject to the following conditions:
okini3939 4:9a2415f2ab07 10 *
okini3939 4:9a2415f2ab07 11 * The above copyright notice and this permission notice shall be included in all copies or
okini3939 4:9a2415f2ab07 12 * substantial portions of the Software.
okini3939 4:9a2415f2ab07 13 *
okini3939 4:9a2415f2ab07 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
okini3939 4:9a2415f2ab07 15 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
okini3939 4:9a2415f2ab07 16 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
okini3939 4:9a2415f2ab07 17 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
okini3939 4:9a2415f2ab07 18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
okini3939 4:9a2415f2ab07 19 */
okini3939 4:9a2415f2ab07 20 /* Copyright (C) 2013 gsfan, MIT License
okini3939 4:9a2415f2ab07 21 * port to the GainSpan Wi-FI module GS1011
okini3939 4:9a2415f2ab07 22 */
okini3939 4:9a2415f2ab07 23
okini3939 4:9a2415f2ab07 24 #ifndef GSWIFIINTERFACE_H_
okini3939 4:9a2415f2ab07 25 #define GSWIFIINTERFACE_H_
okini3939 4:9a2415f2ab07 26
okini3939 4:9a2415f2ab07 27 #include "GSwifi.h"
okini3939 4:9a2415f2ab07 28
okini3939 4:9a2415f2ab07 29 /** Interface using GSwifi to connect to an IP-based network
okini3939 4:9a2415f2ab07 30 *
okini3939 4:9a2415f2ab07 31 */
okini3939 4:9a2415f2ab07 32 class GSwifiInterface: public GSwifi {
okini3939 4:9a2415f2ab07 33 public:
okini3939 4:9a2415f2ab07 34
okini3939 4:9a2415f2ab07 35 /**
okini3939 4:9a2415f2ab07 36 * Constructor
okini3939 4:9a2415f2ab07 37 *
okini3939 4:9a2415f2ab07 38 * \param tx mbed pin to use for tx line of Serial interface
okini3939 4:9a2415f2ab07 39 * \param rx mbed pin to use for rx line of Serial interface
okini3939 4:9a2415f2ab07 40 * \param cts mbed pin to use for cts line of Serial interface
okini3939 4:9a2415f2ab07 41 * \param rts mbed pin to use for rts line of Serial interface
okini3939 4:9a2415f2ab07 42 * \param reset reset pin of the wifi module
okini3939 4:9a2415f2ab07 43 * \param alarm alarm pin of the wifi module (default: NC)
okini3939 4:9a2415f2ab07 44 * \param baud baud rate of Serial interface (default: 9600)
okini3939 4:9a2415f2ab07 45 */
okini3939 4:9a2415f2ab07 46 GSwifiInterface(PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm = NC, int baud = 9600);
okini3939 4:9a2415f2ab07 47
okini3939 4:9a2415f2ab07 48 /** Initialize the interface with DHCP.
okini3939 4:9a2415f2ab07 49 * Initialize the interface and configure it to use DHCP (no connection at this point).
okini3939 4:9a2415f2ab07 50 * \return 0 on success, a negative number on failure
okini3939 4:9a2415f2ab07 51 */
okini3939 4:9a2415f2ab07 52 int init(const char* name = NULL); //With DHCP
okini3939 4:9a2415f2ab07 53
okini3939 4:9a2415f2ab07 54 /** Initialize the interface with a static IP address.
okini3939 4:9a2415f2ab07 55 * Initialize the interface and configure it with the following static configuration (no connection at this point).
okini3939 4:9a2415f2ab07 56 * \param ip the IP address to use
okini3939 4:9a2415f2ab07 57 * \param mask the IP address mask
okini3939 4:9a2415f2ab07 58 * \param gateway the gateway to use
okini3939 4:9a2415f2ab07 59 * \return 0 on success, a negative number on failure
okini3939 4:9a2415f2ab07 60 */
okini3939 4:9a2415f2ab07 61 int init(const char* ip, const char* mask, const char* gateway, const char* name = NULL);
okini3939 4:9a2415f2ab07 62
okini3939 4:9a2415f2ab07 63 /** Connect
okini3939 4:9a2415f2ab07 64 * Bring the interface up, start DHCP if needed.
okini3939 4:9a2415f2ab07 65 * \param sec the Wi-Fi security type
okini3939 4:9a2415f2ab07 66 * \param ssid the Wi-Fi SSID
okini3939 4:9a2415f2ab07 67 * \param phrase the Wi-Fi passphrase or security key
okini3939 4:9a2415f2ab07 68 * \param mode the Wi-Fi mode
okini3939 4:9a2415f2ab07 69 * \return 0 on success, a negative number on failure
okini3939 4:9a2415f2ab07 70 */
okini3939 4:9a2415f2ab07 71 int connect(Security sec, const char* ssid, const char* phrase, WiFiMode mode = WM_INFRASTRUCTURE);
okini3939 4:9a2415f2ab07 72
okini3939 4:9a2415f2ab07 73 /** Disconnect
okini3939 4:9a2415f2ab07 74 * Bring the interface down
okini3939 4:9a2415f2ab07 75 * \return 0 on success, a negative number on failure
okini3939 4:9a2415f2ab07 76 */
okini3939 4:9a2415f2ab07 77 int disconnect();
okini3939 4:9a2415f2ab07 78
okini3939 4:9a2415f2ab07 79 /** Get the MAC address of your Ethernet interface
okini3939 4:9a2415f2ab07 80 * \return a pointer to a string containing the MAC address
okini3939 4:9a2415f2ab07 81 */
okini3939 4:9a2415f2ab07 82 char* getMACAddress();
okini3939 4:9a2415f2ab07 83
okini3939 4:9a2415f2ab07 84 /** Get the IP address of your Ethernet interface
okini3939 4:9a2415f2ab07 85 * \return a pointer to a string containing the IP address
okini3939 4:9a2415f2ab07 86 */
okini3939 4:9a2415f2ab07 87 char* getIPAddress();
okini3939 4:9a2415f2ab07 88
okini3939 4:9a2415f2ab07 89 /** Get the Gateway address of your Ethernet interface
okini3939 4:9a2415f2ab07 90 * \return a pointer to a string containing the Gateway address
okini3939 4:9a2415f2ab07 91 */
okini3939 4:9a2415f2ab07 92 char* getGateway();
okini3939 4:9a2415f2ab07 93
okini3939 4:9a2415f2ab07 94 /** Get the Network mask of your Ethernet interface
okini3939 4:9a2415f2ab07 95 * \return a pointer to a string containing the Network mask
okini3939 4:9a2415f2ab07 96 */
okini3939 4:9a2415f2ab07 97 char* getNetworkMask();
okini3939 4:9a2415f2ab07 98
okini3939 4:9a2415f2ab07 99 };
okini3939 4:9a2415f2ab07 100
okini3939 4:9a2415f2ab07 101 #include "TCPSocketConnection.h"
okini3939 4:9a2415f2ab07 102 #include "TCPSocketServer.h"
okini3939 4:9a2415f2ab07 103
okini3939 4:9a2415f2ab07 104 #include "Endpoint.h"
okini3939 4:9a2415f2ab07 105 #include "UDPSocket.h"
okini3939 4:9a2415f2ab07 106
okini3939 4:9a2415f2ab07 107 #endif /* GSWIFIINTERFACE_H_ */