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:
Thu Jun 29 04:17:47 2017 +0000
Revision:
27:617c6acde338
Parent:
25:2008b3bae5ca
Child:
29:86b2de427eab
50:c1cdd22; Compiled with mbed-os 5.5.1 using Optimization Level 3; Host driver is upgrade to 19.5.2; Add API setTXPower and setPPAGain; Remove RTOS relative call function to save RAM space

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 25:2008b3bae5ca 67 int 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 27:617c6acde338 69 /** Set TX power level, must be called after the EthernetInterface initialization and before any connection request and can't be changed in runtime.
tsungta 27:617c6acde338 70 * \param power_level can be configurable as following
tsungta 27:617c6acde338 71 TX_PWR_HIGH < High power level >
tsungta 27:617c6acde338 72 TX_PWR_MED < Med power level >
tsungta 27:617c6acde338 73 TX_PWR_LOW < Low power level >
tsungta 27:617c6acde338 74 * \return 0 on success, a negative number on failure
tsungta 27:617c6acde338 75 */
tsungta 27:617c6acde338 76 int setTXPower(uint8_t power_level);
tsungta 27:617c6acde338 77
tsungta 27:617c6acde338 78 /** Set the PPA (Pre-Power Amplifier) gain, must be called after the EthernetInterface initialization
tsungta 27:617c6acde338 79 * \param gain_dB is only configable among 3, 6, 9 dB, default is 9 dB
tsungta 27:617c6acde338 80 * \return 0 on success, a negative number on failure
tsungta 27:617c6acde338 81 */
tsungta 27:617c6acde338 82 int setPPAGain(uint8_t gain_dB);
tsungta 27:617c6acde338 83
tsungta 0:06fccc63b33d 84 /** Erase a 4KB sector of embeeded flash.
tsungta 0:06fccc63b33d 85 * Flash memory will be erased in groups of 4KB sector.
tsungta 0:06fccc63b33d 86 * \param address range from 0x00 to 0x3F000 (must be a multiple of 0x1000).
tsungta 0:06fccc63b33d 87 * \return 0 on success, a negative number on failure
tsungta 0:06fccc63b33d 88 */
tsungta 0:06fccc63b33d 89 //int storage_erase4KB(uint32_t address);
tsungta 0:06fccc63b33d 90
tsungta 0:06fccc63b33d 91 /** Write data into embeeded flash.
tsungta 0:06fccc63b33d 92 * Write one (multiple) byte(s) of data into flash, must perform erase before the flash memory area can be overwrite.
tsungta 0:06fccc63b33d 93 * \param address flash memory address to be written, range from 0x00 to 0x3FFFF.
tsungta 0:06fccc63b33d 94 * \param data pointer to the buffer containing data to be written.
tsungta 0:06fccc63b33d 95 * \param len length of the data to be written to flash.
tsungta 0:06fccc63b33d 96 * \return 0 on success, a negative number on failure
tsungta 0:06fccc63b33d 97 */
tsungta 0:06fccc63b33d 98 //int storage_write(uint32_t address, uint8_t *data, uint16_t len);
tsungta 0:06fccc63b33d 99
tsungta 0:06fccc63b33d 100 /** Read data from embeeded flash.
tsungta 0:06fccc63b33d 101 * Read one (multiple) byte(s) of data from flash.
tsungta 0:06fccc63b33d 102 * \param address flash memory address to be read, range from 0x00 to 0x3FFFF.
tsungta 0:06fccc63b33d 103 * \param data pointer to the buffer containing data to be read.
tsungta 0:06fccc63b33d 104 * \param len length of the data to be read from flash.
tsungta 0:06fccc63b33d 105 * \return 0 on success, a negative number on failure
tsungta 0:06fccc63b33d 106 */
tsungta 0:06fccc63b33d 107 //int storage_read(uint32_t address, uint8_t *data, uint16_t len);
tsungta 0:06fccc63b33d 108
tsungta 0:06fccc63b33d 109 };
tsungta 0:06fccc63b33d 110
tsungta 0:06fccc63b33d 111 int enableCoexistance();
tsungta 25:2008b3bae5ca 112 void RF_Switch_WIFI_lock(void);
tsungta 25:2008b3bae5ca 113 void RF_Switch_WIFI_unlock(void);
tsungta 0:06fccc63b33d 114
tsungta 0:06fccc63b33d 115 #endif /* WIFIDEVICE_H_ */
tsungta 27:617c6acde338 116