NNN50 WIFI_API library

Dependents:   NNN50_CE_Test_UDP NNN50_linux_firmware NNN50_SoftAP_HelloWorld NNN50_BLEWIFISensor ... more

This is mbed compatible EthernetInterface lib exclude for Delta DFCM-NNN50 platform.

Additional information and examples can be found in mbed Handbook

Committer:
tsungta
Date:
Tue Jan 03 09:35:21 2017 +0000
Revision:
9:32d6cd2f8456
Parent:
1:be6abb24f013
Child:
25:2008b3bae5ca
31:c38cd9c; Add TCP buffering mechanism (to support HTTPServer and HTTPClient Lib); Add WPS support; Add Socket.close() a delay of 15ms; Fix M2M_WIFI_SEC_WEP connect bug

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tsungta 0:06fccc63b33d 1 #ifndef WIFIDEVICE_H_
tsungta 0:06fccc63b33d 2 #define WIFIDEVICE_H_
tsungta 0:06fccc63b33d 3
tsungta 0:06fccc63b33d 4 /** Interface using WI-FI to connect to Ethernet
tsungta 0:06fccc63b33d 5 *
tsungta 0:06fccc63b33d 6 */
tsungta 0:06fccc63b33d 7
tsungta 0:06fccc63b33d 8 #include "mbed.h"
tsungta 0:06fccc63b33d 9 #include "EthernetInterface.h"
tsungta 0:06fccc63b33d 10
tsungta 0:06fccc63b33d 11 class WIFIDevice {
tsungta 0:06fccc63b33d 12 public:
tsungta 0:06fccc63b33d 13
tsungta 0:06fccc63b33d 14 /** Set WIFI in sleep mode.
tsungta 0:06fccc63b33d 15 * Disable WIFI and set into sleep mode to conserve energy (no WIFI function is available at this point).
tsungta 0:06fccc63b33d 16 * \return 0 on success, a negative number on failure
tsungta 0:06fccc63b33d 17 */
tsungta 0:06fccc63b33d 18 int sleep(void);
tsungta 0:06fccc63b33d 19
tsungta 0:06fccc63b33d 20 /** Check if the device is connected to Access Point
tsungta 0:06fccc63b33d 21 * \return 1 if connected, 0 otherwise.
tsungta 0:06fccc63b33d 22 */
tsungta 0:06fccc63b33d 23 int is_AP_connected(void);
tsungta 0:06fccc63b33d 24
tsungta 0:06fccc63b33d 25 /** Perform WIFI scan.
tsungta 0:06fccc63b33d 26 * Scan for available access point on all channels.
tsungta 0:06fccc63b33d 27 * \return number of scanned WIFI access point
tsungta 0:06fccc63b33d 28 */
tsungta 0:06fccc63b33d 29 int apScan(void (*eventCallback)(tstrM2mWifiscanResult result));
tsungta 0:06fccc63b33d 30
tsungta 0:06fccc63b33d 31 /** Set network connection in priority.
tsungta 0:06fccc63b33d 32 * Set SSID, password and priority to connect.
tsungta 0:06fccc63b33d 33 * \param secType type of securith support in STA mode, support
tsungta 0:06fccc63b33d 34 M2M_WIFI_SEC_OPEN < Open security >
tsungta 0:06fccc63b33d 35 M2M_WIFI_SEC_WPA_PSK < Wi-Fi network is secured with WPA/WPA2 personal(PSK) >
tsungta 0:06fccc63b33d 36 M2M_WIFI_SEC_WEP < Security type WEP (40 or 104) OPEN OR SHARED >
tsungta 0:06fccc63b33d 37 M2M_WIFI_SEC_802_1X < Wi-Fi network is secured with WPA/WPA2 Enterprise.IEEE802.1x user-name/password authentication >
tsungta 0:06fccc63b33d 38 * \param SSID name of access point to connect
tsungta 9:32d6cd2f8456 39 * \param PW password of the given SSID
tsungta 9:32d6cd2f8456 40 * \param wepIndex WEP Index of PW when using M2M_WIFI_SEC_WEP (set between 1 to 4)
tsungta 0:06fccc63b33d 41 */
tsungta 9:32d6cd2f8456 42 void setNetwork(uint8_t secType, char* SSID, char* PW, uint8_t wepIndex = 1);
tsungta 0:06fccc63b33d 43
tsungta 9:32d6cd2f8456 44 /** Set WPA/WPA2 Enterprise.IEEE802.1x user-name/password authentication.
tsungta 9:32d6cd2f8456 45 * \param USER user-name of IEEE802.1x authentication
tsungta 9:32d6cd2f8456 46 * \param PW password of IEEE802.1x authentication
tsungta 9:32d6cd2f8456 47 */
tsungta 9:32d6cd2f8456 48 void setLogin(char* USER, char* PW);
tsungta 9:32d6cd2f8456 49
tsungta 9:32d6cd2f8456 50 /** Trigger Wi-Fi Protected Setup (WPS).
tsungta 9:32d6cd2f8456 51 * WPS activation and scan for fixed 120 seconds (support WPA/WPA2 key only).
tsungta 9:32d6cd2f8456 52 * \return 0 on success (AP connected), a negative number on failure (timeout)
tsungta 9:32d6cd2f8456 53 */
tsungta 9:32d6cd2f8456 54 int triggerWPS();
tsungta 9:32d6cd2f8456 55
tsungta 1:be6abb24f013 56 /** Enable Access Point in given configuration.
tsungta 0:06fccc63b33d 57 * Set SSID, password, security type and channel in AP mode.
tsungta 0:06fccc63b33d 58 * \param SSID name of access point in AP mode
tsungta 0:06fccc63b33d 59 * \param PW password of the given SSID
tsungta 1:be6abb24f013 60 * \param AP_ip the IP address of AP
tsungta 1:be6abb24f013 61 * \param security tyoe of security in AP mode (default: (M2M_WIFI_SEC_WEP)), support
tsungta 1:be6abb24f013 62 M2M_WIFI_SEC_OPEN < Open security >
tsungta 1:be6abb24f013 63 M2M_WIFI_SEC_WEP < Security type WEP with 10 hexadecimal digits >
tsungta 0:06fccc63b33d 64 * \param channel range from 1 to 14 (default: (1))
tsungta 1:be6abb24f013 65 * \return 0 on success, a negative number on failure
tsungta 0:06fccc63b33d 66 */
tsungta 1:be6abb24f013 67 int WIFIDevice::enableAccessPoint(char* SSID, char* PW, char* AP_ip = "192.168.1.1", uint8_t secType=M2M_WIFI_SEC_WEP, uint8_t channel=1);
tsungta 0:06fccc63b33d 68
tsungta 0:06fccc63b33d 69 /** Erase a 4KB sector of embeeded flash.
tsungta 0:06fccc63b33d 70 * Flash memory will be erased in groups of 4KB sector.
tsungta 0:06fccc63b33d 71 * \param address range from 0x00 to 0x3F000 (must be a multiple of 0x1000).
tsungta 0:06fccc63b33d 72 * \return 0 on success, a negative number on failure
tsungta 0:06fccc63b33d 73 */
tsungta 0:06fccc63b33d 74 //int storage_erase4KB(uint32_t address);
tsungta 0:06fccc63b33d 75
tsungta 0:06fccc63b33d 76 /** Write data into embeeded flash.
tsungta 0:06fccc63b33d 77 * Write one (multiple) byte(s) of data into flash, must perform erase before the flash memory area can be overwrite.
tsungta 0:06fccc63b33d 78 * \param address flash memory address to be written, range from 0x00 to 0x3FFFF.
tsungta 0:06fccc63b33d 79 * \param data pointer to the buffer containing data to be written.
tsungta 0:06fccc63b33d 80 * \param len length of the data to be written to flash.
tsungta 0:06fccc63b33d 81 * \return 0 on success, a negative number on failure
tsungta 0:06fccc63b33d 82 */
tsungta 0:06fccc63b33d 83 //int storage_write(uint32_t address, uint8_t *data, uint16_t len);
tsungta 0:06fccc63b33d 84
tsungta 0:06fccc63b33d 85 /** Read data from embeeded flash.
tsungta 0:06fccc63b33d 86 * Read one (multiple) byte(s) of data from flash.
tsungta 0:06fccc63b33d 87 * \param address flash memory address to be read, range from 0x00 to 0x3FFFF.
tsungta 0:06fccc63b33d 88 * \param data pointer to the buffer containing data to be read.
tsungta 0:06fccc63b33d 89 * \param len length of the data to be read from flash.
tsungta 0:06fccc63b33d 90 * \return 0 on success, a negative number on failure
tsungta 0:06fccc63b33d 91 */
tsungta 0:06fccc63b33d 92 //int storage_read(uint32_t address, uint8_t *data, uint16_t len);
tsungta 0:06fccc63b33d 93
tsungta 0:06fccc63b33d 94 };
tsungta 0:06fccc63b33d 95
tsungta 0:06fccc63b33d 96 int enableCoexistance();
tsungta 0:06fccc63b33d 97
tsungta 0:06fccc63b33d 98 #endif /* WIFIDEVICE_H_ */
tsungta 1:be6abb24f013 99