Delta / NNN50_WIFI_API

Dependents:   NNN50_CE_Test_UDP NNN50_linux_firmware NNN50_SoftAP_HelloWorld NNN50_BLEWIFISensor ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WIFIDevice.h Source File

WIFIDevice.h

00001 #ifndef WIFIDEVICE_H_
00002 #define WIFIDEVICE_H_
00003 
00004  /** Interface using WI-FI to connect to Ethernet
00005  *
00006  */
00007  
00008 //#include "mbed.h"
00009 #include <stdio.h>
00010 #include "nrf_delay.h"
00011 
00012 #include "drivers/Ticker.h"
00013 #include "drivers/InterruptIn.h"
00014 using namespace mbed;
00015 
00016 #include "EthernetInterface.h"
00017  
00018 class WIFIDevice {
00019 public:
00020 
00021   /** Set WIFI in sleep mode.
00022   * Disable WIFI and set into sleep mode to conserve energy (no WIFI function is available at this point).
00023   * \return 0 on success, a negative number on failure
00024   */
00025   int sleep(void);
00026 
00027   /** Check if the device is connected to Access Point
00028   * \return 1 if connected, 0 otherwise.
00029   */
00030   int is_AP_connected(void);
00031     
00032   /** Perform WIFI scan.
00033   * Scan for available access point on all channels.
00034   * \return number of scanned WIFI access point
00035   */
00036   int apScan(void (*eventCallback)(tstrM2mWifiscanResult result));
00037     
00038   /** Set network connection in priority.
00039   * Set SSID, password and priority to connect.
00040   * \param secType type of securith support in STA mode, support
00041     M2M_WIFI_SEC_OPEN       < Open security >
00042     M2M_WIFI_SEC_WPA_PSK    < Wi-Fi network is secured with WPA/WPA2 personal(PSK) >
00043     M2M_WIFI_SEC_WEP        < Security type WEP (40 or 104) OPEN OR SHARED >
00044     M2M_WIFI_SEC_802_1X     < Wi-Fi network is secured with WPA/WPA2 Enterprise.IEEE802.1x user-name/password authentication >
00045   * \param SSID name of access point to connect
00046   * \param PW password of the given SSID   
00047   * \param wepIndex WEP Index of PW when using M2M_WIFI_SEC_WEP (set between 1 to 4)    
00048   */
00049   void setNetwork(uint8_t secType, char* SSID, char* PW, uint8_t wepIndex = 1);
00050 
00051   /** Set WPA/WPA2 Enterprise.IEEE802.1x user-name/password authentication.
00052   * \param USER user-name of IEEE802.1x authentication
00053   * \param PW password of IEEE802.1x authentication 
00054   */  
00055   void setLogin(char* USER, char* PW);
00056 
00057   /** Trigger Wi-Fi Protected Setup (WPS).
00058   * WPS activation and scan for fixed 120 seconds (support WPA/WPA2 key only).
00059   * \return 0 on success (AP connected), a negative number on failure (timeout)
00060   */
00061   int triggerWPS();
00062     
00063   /** Enable Access Point in given configuration.
00064   * Set SSID, password, security type and channel in AP mode.
00065   * \param SSID name of access point in AP mode
00066   * \param PW password of the given SSID
00067   * \param AP_ip the IP address of AP
00068   * \param security tyoe of security in AP mode (default: (M2M_WIFI_SEC_WEP)), support
00069     M2M_WIFI_SEC_OPEN       < Open security >
00070     M2M_WIFI_SEC_WEP        < Security type WEP with 10 hexadecimal digits >
00071   * \param channel range from 1 to 14 (default: (1))
00072   * \return 0 on success, a negative number on failure  
00073   */
00074   int enableAccessPoint(char* SSID, char* PW, char* AP_ip = "192.168.1.1", uint8_t secType=M2M_WIFI_SEC_WEP , uint8_t channel=1);
00075 
00076   /** Set TX power level, must be called after the EthernetInterface initialization and before any connection request and can't be changed in runtime.
00077   * \param power_level can be configurable as following
00078     TX_PWR_HIGH             < High power level >
00079     TX_PWR_MED              < Med power level >
00080     TX_PWR_LOW              < Low power level >  
00081   * \return 0 on success, a negative number on failure   
00082   */  
00083   int setTXPower(uint8_t power_level);
00084 
00085   /** Set the PPA (Pre-Power Amplifier) gain, must be called after the EthernetInterface initialization
00086   * \param gain_dB is only configable among 3, 6, 9 dB, default is 9 dB
00087   * \return 0 on success, a negative number on failure   
00088   */  
00089   int setPPAGain(uint8_t gain_dB);
00090 
00091   /** get the current RSSI from the connected AP
00092   * \return a negative RSSI value in dBm   
00093   */
00094   int getRSSI(void);
00095   
00096   /** Erase a 4KB sector of embeeded flash.
00097   * Flash memory will be erased in groups of 4KB sector.
00098   * \param address range from 0x00 to 0x3F000 (must be a multiple of 0x1000).
00099   * \return 0 on success, a negative number on failure
00100   */  
00101   //int storage_erase4KB(uint32_t address);
00102   
00103   /** Write data into embeeded flash.
00104   * Write one (multiple) byte(s) of data into flash, must perform erase before the flash memory area can be overwrite.
00105   * \param address flash memory address to be written, range from 0x00 to 0x3FFFF.
00106   * \param data pointer to the buffer containing data to be written.
00107   * \param len length of the data to be written to flash.
00108   * \return 0 on success, a negative number on failure
00109   */    
00110   //int storage_write(uint32_t address, uint8_t *data, uint16_t len);
00111   
00112   /** Read data from embeeded flash.
00113   * Read one (multiple) byte(s) of data from flash.
00114   * \param address flash memory address to be read, range from 0x00 to 0x3FFFF.
00115   * \param data pointer to the buffer containing data to be read.
00116   * \param len length of the data to be read from flash.
00117   * \return 0 on success, a negative number on failure
00118   */     
00119   //int storage_read(uint32_t address, uint8_t *data, uint16_t len);
00120   
00121 };
00122 
00123 int enableCoexistance();
00124 void RF_Switch_WIFI_lock(void);
00125 void RF_Switch_WIFI_unlock(void);
00126 #define WIFI_WINDOW_US      600     //min is 300
00127 #define BLE_WINDOW_US      600      //min is 300
00128 
00129 #endif /* WIFIDEVICE_H_ */
00130