wifly/socket interface for wifly modules

Dependents:   WiFi neurGAI_WIFI thingspeak thingspeak2

Committer:
samux
Date:
Fri Aug 24 13:25:55 2012 +0000
Revision:
13:108340829acc
Parent:
8:9a3cd07ed7e8
reduce buffer size

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 0:6ffb0aeb3972 1 /* WiflyInterface.h */
samux 0:6ffb0aeb3972 2 /* Copyright (C) 2012 mbed.org, MIT License
samux 0:6ffb0aeb3972 3 *
samux 0:6ffb0aeb3972 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
samux 0:6ffb0aeb3972 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
samux 0:6ffb0aeb3972 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
samux 0:6ffb0aeb3972 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
samux 0:6ffb0aeb3972 8 * furnished to do so, subject to the following conditions:
samux 0:6ffb0aeb3972 9 *
samux 0:6ffb0aeb3972 10 * The above copyright notice and this permission notice shall be included in all copies or
samux 0:6ffb0aeb3972 11 * substantial portions of the Software.
samux 0:6ffb0aeb3972 12 *
samux 0:6ffb0aeb3972 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
samux 0:6ffb0aeb3972 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
samux 0:6ffb0aeb3972 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
samux 0:6ffb0aeb3972 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
samux 0:6ffb0aeb3972 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
samux 0:6ffb0aeb3972 18 */
samux 0:6ffb0aeb3972 19
samux 0:6ffb0aeb3972 20 #ifndef WIFLYINTERFACE_H_
samux 0:6ffb0aeb3972 21 #define WIFLYINTERFACE_H_
samux 0:6ffb0aeb3972 22
samux 0:6ffb0aeb3972 23 #include "Wifly.h"
samux 0:6ffb0aeb3972 24
samux 0:6ffb0aeb3972 25 /** Interface using Wifly to connect to an IP-based network
samux 0:6ffb0aeb3972 26 *
samux 0:6ffb0aeb3972 27 */
samux 0:6ffb0aeb3972 28 class WiflyInterface: public Wifly {
samux 0:6ffb0aeb3972 29 public:
samux 0:6ffb0aeb3972 30
samux 8:9a3cd07ed7e8 31 /**
samux 8:9a3cd07ed7e8 32 * Constructor
samux 8:9a3cd07ed7e8 33 *
samux 8:9a3cd07ed7e8 34 * \param tx mbed pin to use for tx line of Serial interface
samux 8:9a3cd07ed7e8 35 * \param rx mbed pin to use for rx line of Serial interface
samux 8:9a3cd07ed7e8 36 * \param reset reset pin of the wifi module ()
samux 8:9a3cd07ed7e8 37 * \param tcp_status connection status pin of the wifi module (GPIO 6)
samux 8:9a3cd07ed7e8 38 * \param ssid ssid of the network
samux 8:9a3cd07ed7e8 39 * \param phrase WEP or WPA key
samux 8:9a3cd07ed7e8 40 * \param sec Security type (NONE, WEP_128 or WPA)
samux 8:9a3cd07ed7e8 41 */
samux 7:a92dbed32890 42 WiflyInterface(PinName tx, PinName rx, PinName reset, PinName tcp_status, const char * ssid, const char * phrase, Security sec = NONE);
samux 0:6ffb0aeb3972 43
samux 0:6ffb0aeb3972 44 /** Initialize the interface with DHCP.
samux 0:6ffb0aeb3972 45 * Initialize the interface and configure it to use DHCP (no connection at this point).
samux 0:6ffb0aeb3972 46 * \return 0 on success, a negative number on failure
samux 0:6ffb0aeb3972 47 */
samux 0:6ffb0aeb3972 48 int init(); //With DHCP
samux 0:6ffb0aeb3972 49
samux 0:6ffb0aeb3972 50 /** Initialize the interface with a static IP address.
samux 0:6ffb0aeb3972 51 * Initialize the interface and configure it with the following static configuration (no connection at this point).
samux 0:6ffb0aeb3972 52 * \param ip the IP address to use
samux 0:6ffb0aeb3972 53 * \param mask the IP address mask
samux 0:6ffb0aeb3972 54 * \param gateway the gateway to use
samux 0:6ffb0aeb3972 55 * \return 0 on success, a negative number on failure
samux 0:6ffb0aeb3972 56 */
samux 0:6ffb0aeb3972 57 int init(const char* ip, const char* mask, const char* gateway);
samux 0:6ffb0aeb3972 58
samux 0:6ffb0aeb3972 59 /** Connect
samux 0:6ffb0aeb3972 60 * Bring the interface up, start DHCP if needed.
samux 0:6ffb0aeb3972 61 * \return 0 on success, a negative number on failure
samux 0:6ffb0aeb3972 62 */
samux 0:6ffb0aeb3972 63 int connect();
samux 0:6ffb0aeb3972 64
samux 0:6ffb0aeb3972 65 /** Disconnect
samux 0:6ffb0aeb3972 66 * Bring the interface down
samux 0:6ffb0aeb3972 67 * \return 0 on success, a negative number on failure
samux 0:6ffb0aeb3972 68 */
samux 0:6ffb0aeb3972 69 int disconnect();
samux 0:6ffb0aeb3972 70
samux 0:6ffb0aeb3972 71 /** Get IP address
samux 0:6ffb0aeb3972 72 *
samux 0:6ffb0aeb3972 73 * @ returns ip address
samux 0:6ffb0aeb3972 74 */
samux 0:6ffb0aeb3972 75 char* getIPAddress();
samux 0:6ffb0aeb3972 76
samux 0:6ffb0aeb3972 77 private:
samux 0:6ffb0aeb3972 78 char ip_string[30];
samux 0:6ffb0aeb3972 79 bool ip_set;
samux 0:6ffb0aeb3972 80 };
samux 0:6ffb0aeb3972 81
samux 0:6ffb0aeb3972 82 #include "TCPSocketConnection.h"
samux 0:6ffb0aeb3972 83 #include "TCPSocketServer.h"
samux 0:6ffb0aeb3972 84 #include "UDPSocket.h"
samux 0:6ffb0aeb3972 85
samux 0:6ffb0aeb3972 86 #endif /* WIFLYINTERFACE_H_ */