posilani dat

Dependencies:   FatFileSystemCpp mbed PowerControl USBHostLite

Committer:
PavelKumpan
Date:
Tue May 23 18:42:14 2017 +0000
Revision:
26:5674b8978551
Parent:
7:805c16a071d0
Recreated communication protocol.

Who changed what in which revision?

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