wifly/socket interface for wifly modules
Dependents: PROJET_MATTHIEU_2019 PROJET_MATTHIEU_2019
WiflyInterface.h@7:a92dbed32890, 2012-08-23 (annotated)
- Committer:
- samux
- Date:
- Thu Aug 23 12:59:19 2012 +0000
- Revision:
- 7:a92dbed32890
- Parent:
- 0:6ffb0aeb3972
- Child:
- 8:9a3cd07ed7e8
add security enum
Who changed what in which revision?
User | Revision | Line number | New 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 | 7:a92dbed32890 | 31 | WiflyInterface(PinName tx, PinName rx, PinName reset, PinName tcp_status, const char * ssid, const char * phrase, Security sec = NONE); |
samux | 0:6ffb0aeb3972 | 32 | |
samux | 0:6ffb0aeb3972 | 33 | /** Initialize the interface with DHCP. |
samux | 0:6ffb0aeb3972 | 34 | * Initialize the interface and configure it to use DHCP (no connection at this point). |
samux | 0:6ffb0aeb3972 | 35 | * \return 0 on success, a negative number on failure |
samux | 0:6ffb0aeb3972 | 36 | */ |
samux | 0:6ffb0aeb3972 | 37 | int init(); //With DHCP |
samux | 0:6ffb0aeb3972 | 38 | |
samux | 0:6ffb0aeb3972 | 39 | /** Initialize the interface with a static IP address. |
samux | 0:6ffb0aeb3972 | 40 | * Initialize the interface and configure it with the following static configuration (no connection at this point). |
samux | 0:6ffb0aeb3972 | 41 | * \param ip the IP address to use |
samux | 0:6ffb0aeb3972 | 42 | * \param mask the IP address mask |
samux | 0:6ffb0aeb3972 | 43 | * \param gateway the gateway to use |
samux | 0:6ffb0aeb3972 | 44 | * \return 0 on success, a negative number on failure |
samux | 0:6ffb0aeb3972 | 45 | */ |
samux | 0:6ffb0aeb3972 | 46 | int init(const char* ip, const char* mask, const char* gateway); |
samux | 0:6ffb0aeb3972 | 47 | |
samux | 0:6ffb0aeb3972 | 48 | /** Connect |
samux | 0:6ffb0aeb3972 | 49 | * Bring the interface up, start DHCP if needed. |
samux | 0:6ffb0aeb3972 | 50 | * \return 0 on success, a negative number on failure |
samux | 0:6ffb0aeb3972 | 51 | */ |
samux | 0:6ffb0aeb3972 | 52 | int connect(); |
samux | 0:6ffb0aeb3972 | 53 | |
samux | 0:6ffb0aeb3972 | 54 | /** Disconnect |
samux | 0:6ffb0aeb3972 | 55 | * Bring the interface down |
samux | 0:6ffb0aeb3972 | 56 | * \return 0 on success, a negative number on failure |
samux | 0:6ffb0aeb3972 | 57 | */ |
samux | 0:6ffb0aeb3972 | 58 | int disconnect(); |
samux | 0:6ffb0aeb3972 | 59 | |
samux | 0:6ffb0aeb3972 | 60 | /** Get IP address |
samux | 0:6ffb0aeb3972 | 61 | * |
samux | 0:6ffb0aeb3972 | 62 | * @ returns ip address |
samux | 0:6ffb0aeb3972 | 63 | */ |
samux | 0:6ffb0aeb3972 | 64 | char* getIPAddress(); |
samux | 0:6ffb0aeb3972 | 65 | |
samux | 0:6ffb0aeb3972 | 66 | private: |
samux | 0:6ffb0aeb3972 | 67 | char ip_string[30]; |
samux | 0:6ffb0aeb3972 | 68 | bool ip_set; |
samux | 0:6ffb0aeb3972 | 69 | }; |
samux | 0:6ffb0aeb3972 | 70 | |
samux | 0:6ffb0aeb3972 | 71 | #include "TCPSocketConnection.h" |
samux | 0:6ffb0aeb3972 | 72 | #include "TCPSocketServer.h" |
samux | 0:6ffb0aeb3972 | 73 | #include "UDPSocket.h" |
samux | 0:6ffb0aeb3972 | 74 | |
samux | 0:6ffb0aeb3972 | 75 | #endif /* WIFLYINTERFACE_H_ */ |