Turn down WIFI_API_DEBUG_LOG in wifi_api.h
Fork of WIFI_API_32kRAM by
WIFIDevice.h@27:40ec92889c3c, 2016-01-26 (annotated)
- Committer:
- gillwei7
- Date:
- Tue Jan 26 09:30:40 2016 +0000
- Revision:
- 27:40ec92889c3c
- Parent:
- 24:928f7988387c
Turn down WIFI_API_DEBUG_LOG in wifi_api.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Marcomissyou | 0:4085cc9441f3 | 1 | #ifndef WIFIDEVICE_H_ |
Marcomissyou | 0:4085cc9441f3 | 2 | #define WIFIDEVICE_H_ |
Marcomissyou | 0:4085cc9441f3 | 3 | |
Marcomissyou | 0:4085cc9441f3 | 4 | #include "nmi_wlan_if.h" |
Marcomissyou | 0:4085cc9441f3 | 5 | #include "nmi_wlan.h" |
Marcomissyou | 0:4085cc9441f3 | 6 | |
wgd8700 | 19:a11db6055532 | 7 | #include "spi_master.h" |
wgd8700 | 11:659b13c3437a | 8 | |
wgd8700 | 24:928f7988387c | 9 | #include "wifi_api.h" |
Marcomissyou | 0:4085cc9441f3 | 10 | /** Interface using WI-FI to connect to Ethernet |
Marcomissyou | 0:4085cc9441f3 | 11 | * |
Marcomissyou | 0:4085cc9441f3 | 12 | */ |
wgd8700 | 7:91824a659c5b | 13 | |
wgd8700 | 7:91824a659c5b | 14 | //Tsungta, 2015/09/05, added for WIFIDevice.apScan() |
wgd8700 | 7:91824a659c5b | 15 | typedef struct{ |
wgd8700 | 7:91824a659c5b | 16 | uint32_t chipID; |
wgd8700 | 7:91824a659c5b | 17 | uint32_t imgStaID; |
wgd8700 | 7:91824a659c5b | 18 | uint32_t imgApID; |
wgd8700 | 7:91824a659c5b | 19 | } wifiSpInfo; |
wgd8700 | 7:91824a659c5b | 20 | |
Marcomissyou | 0:4085cc9441f3 | 21 | class WIFIDevice { |
Marcomissyou | 0:4085cc9441f3 | 22 | public: |
Marcomissyou | 0:4085cc9441f3 | 23 | |
Marcomissyou | 0:4085cc9441f3 | 24 | /** Set WIFI in sleep mode. |
Marcomissyou | 0:4085cc9441f3 | 25 | * Disable WIFI and set into sleep mode to conserve energy (no WIFI function is available at this point). |
Marcomissyou | 0:4085cc9441f3 | 26 | * \return 0 on success, a negative number on failure |
Marcomissyou | 0:4085cc9441f3 | 27 | */ |
Marcomissyou | 0:4085cc9441f3 | 28 | int sleep(void); |
Marcomissyou | 0:4085cc9441f3 | 29 | |
wgd8700 | 11:659b13c3437a | 30 | /** Enable the coexistance of WIFI and BLE. |
wgd8700 | 19:a11db6055532 | 31 | * Enable the setting of two coexistence control pins (COEX_B and COEX_W) are short to each other. |
Marcomissyou | 0:4085cc9441f3 | 32 | * \return 0 on success, a negative number on failure |
Marcomissyou | 0:4085cc9441f3 | 33 | */ |
wgd8700 | 11:659b13c3437a | 34 | int enableCoexistance(); |
wgd8700 | 11:659b13c3437a | 35 | |
wgd8700 | 11:659b13c3437a | 36 | // /** Set the position of embedded RF switch. |
wgd8700 | 11:659b13c3437a | 37 | // * Set the position of RF switch between WIFI and BLE. |
wgd8700 | 11:659b13c3437a | 38 | // * \param position set 1 on WIFI to use, set 0 on BLE to use. |
wgd8700 | 11:659b13c3437a | 39 | // * \return 0 on success, a negative number on failure |
wgd8700 | 11:659b13c3437a | 40 | // */ |
wgd8700 | 11:659b13c3437a | 41 | // int setSwitch(int position); |
wgd8700 | 11:659b13c3437a | 42 | // |
wgd8700 | 11:659b13c3437a | 43 | // /** Get the position of embedded RF switch. |
wgd8700 | 11:659b13c3437a | 44 | // * Get the current position of RF switch |
wgd8700 | 11:659b13c3437a | 45 | // * \return get 1 on WIFI to use, get 0 on BLE to use |
wgd8700 | 11:659b13c3437a | 46 | // */ |
wgd8700 | 11:659b13c3437a | 47 | // int getSwitch(void); |
Marcomissyou | 0:4085cc9441f3 | 48 | |
wgd8700 | 7:91824a659c5b | 49 | /** Perform WIFI scan. |
wgd8700 | 7:91824a659c5b | 50 | * Scan for available access point on all channels. |
wgd8700 | 7:91824a659c5b | 51 | * \return number of scanned WIFI access point |
wgd8700 | 7:91824a659c5b | 52 | */ |
wgd8700 | 7:91824a659c5b | 53 | int apScan(void (*eventCallback)(scanApInfo result)); |
Marcomissyou | 0:4085cc9441f3 | 54 | |
Marcomissyou | 0:4085cc9441f3 | 55 | /** Set network connection in priority. |
Marcomissyou | 0:4085cc9441f3 | 56 | * Set SSID, password and priority to connect. |
Marcomissyou | 0:4085cc9441f3 | 57 | * \param SSID name of access point to connect |
Marcomissyou | 0:4085cc9441f3 | 58 | * \param PW password of the given SSID |
Marcomissyou | 0:4085cc9441f3 | 59 | * \param priority range from 0 to 2, set 0 for the highest priority |
Marcomissyou | 0:4085cc9441f3 | 60 | */ |
Marcomissyou | 0:4085cc9441f3 | 61 | void setNetwork(char* SSID, char* PW, uint8_t priority); |
Marcomissyou | 0:4085cc9441f3 | 62 | |
wgd8700 | 5:d20c2d97258a | 63 | /** Set Access Point in given configuration. |
wgd8700 | 5:d20c2d97258a | 64 | * Set SSID, password, security type and channel in AP mode. |
wgd8700 | 5:d20c2d97258a | 65 | * \param SSID name of access point in AP mode |
wgd8700 | 5:d20c2d97258a | 66 | * \param PW password of the given SSID |
wgd8700 | 5:d20c2d97258a | 67 | * \param security tyoe of security in AP mode (default: (SECURITY_WPA2_AES_PSK)), support |
wgd8700 | 5:d20c2d97258a | 68 | SECURITY_OPEN < Open security > |
wgd8700 | 5:d20c2d97258a | 69 | SECURITY_WEP_PSK < WEP Security with open authentication with 5/13 ascii characters or 10/26 hex codes passwords |
wgd8700 | 5:d20c2d97258a | 70 | SECURITY_WEP_SHARED < WEP Security with shared authentication with 5/13 ascii characters or 10/26 hex codes passwords |
wgd8700 | 5:d20c2d97258a | 71 | SECURITY_WPA_TKIP_PSK < WPA Security with TKIP with 8 or more ascii characters passwords |
wgd8700 | 5:d20c2d97258a | 72 | SECURITY_WPA_AES_PSK < WPA Security with AES with 8 or more ascii characters passwords |
wgd8700 | 5:d20c2d97258a | 73 | SECURITY_WPA2_AES_PSK < WPA2 Security with AES with 8 or more ascii characters passwords |
wgd8700 | 5:d20c2d97258a | 74 | SECURITY_WPA2_TKIP_PSK < WPA2 Security with TKIP with 8 or more ascii characters passwords |
wgd8700 | 5:d20c2d97258a | 75 | SECURITY_WPA2_MIXED_PSK< WPA2 Security with AES & TKIP with 8 or more ascii characters passwords |
wgd8700 | 5:d20c2d97258a | 76 | * \param channel range from 1 to 14 (default: (1)) |
wgd8700 | 5:d20c2d97258a | 77 | */ |
wgd8700 | 5:d20c2d97258a | 78 | void WIFIDevice::setAccessPoint(char* SSID, char* PW, security_t security=SECURITY_WPA2_AES_PSK, uint8_t channel=1); |
wgd8700 | 7:91824a659c5b | 79 | |
wgd8700 | 7:91824a659c5b | 80 | /** Read WIFI Service Pack version |
wgd8700 | 7:91824a659c5b | 81 | ** \return wifiSpInfo |
wgd8700 | 7:91824a659c5b | 82 | */ |
wgd8700 | 7:91824a659c5b | 83 | wifiSpInfo read_WIFI_SP_version(); |
wgd8700 | 7:91824a659c5b | 84 | |
wgd8700 | 7:91824a659c5b | 85 | /** Erase a 4KB sector of embeeded flash. |
wgd8700 | 7:91824a659c5b | 86 | * Flash memory will be erased in groups of 4KB sector. |
wgd8700 | 7:91824a659c5b | 87 | * \param address range from 0x00 to 0x3F000 (must be a multiple of 0x1000). |
wgd8700 | 7:91824a659c5b | 88 | * \return 0 on success, a negative number on failure |
wgd8700 | 7:91824a659c5b | 89 | */ |
wgd8700 | 7:91824a659c5b | 90 | int storage_erase4KB(uint32_t address); |
wgd8700 | 5:d20c2d97258a | 91 | |
wgd8700 | 7:91824a659c5b | 92 | /** Write data into embeeded flash. |
wgd8700 | 7:91824a659c5b | 93 | * Write one (multiple) byte(s) of data into flash, must perform erase before the flash memory area can be overwrite. |
wgd8700 | 7:91824a659c5b | 94 | * \param address flash memory address to be written, range from 0x00 to 0x3FFFF. |
wgd8700 | 7:91824a659c5b | 95 | * \param data pointer to the buffer containing data to be written. |
wgd8700 | 7:91824a659c5b | 96 | * \param len length of the data to be written to flash. |
wgd8700 | 7:91824a659c5b | 97 | * \return 0 on success, a negative number on failure |
wgd8700 | 7:91824a659c5b | 98 | */ |
wgd8700 | 7:91824a659c5b | 99 | int storage_write(uint32_t address, uint8_t *data, uint16_t len); |
wgd8700 | 7:91824a659c5b | 100 | |
wgd8700 | 7:91824a659c5b | 101 | /** Read data from embeeded flash. |
wgd8700 | 7:91824a659c5b | 102 | * Read one (multiple) byte(s) of data from flash. |
wgd8700 | 7:91824a659c5b | 103 | * \param address flash memory address to be read, range from 0x00 to 0x3FFFF. |
wgd8700 | 7:91824a659c5b | 104 | * \param data pointer to the buffer containing data to be read. |
wgd8700 | 7:91824a659c5b | 105 | * \param len length of the data to be read from flash. |
wgd8700 | 7:91824a659c5b | 106 | * \return 0 on success, a negative number on failure |
wgd8700 | 7:91824a659c5b | 107 | */ |
wgd8700 | 7:91824a659c5b | 108 | int storage_read(uint32_t address, uint8_t *data, uint16_t len); |
wgd8700 | 7:91824a659c5b | 109 | |
Marcomissyou | 0:4085cc9441f3 | 110 | // /** Get the status of embedded WIFI chipset. |
Marcomissyou | 0:4085cc9441f3 | 111 | // * Get the current status of embedded WIFI chipset |
Marcomissyou | 0:4085cc9441f3 | 112 | // * \return get 1 on WIFI to use, get 0 on BLE to use |
Marcomissyou | 0:4085cc9441f3 | 113 | // */ |
Marcomissyou | 0:4085cc9441f3 | 114 | // int getStatus(void); |
Marcomissyou | 0:4085cc9441f3 | 115 | |
Marcomissyou | 0:4085cc9441f3 | 116 | // /** Set WIFI output power. |
Marcomissyou | 0:4085cc9441f3 | 117 | // * Set WIFI output power level |
Marcomissyou | 0:4085cc9441f3 | 118 | // * \param output power level |
Marcomissyou | 0:4085cc9441f3 | 119 | // * \return 0 on success, a negative number on failure |
Marcomissyou | 0:4085cc9441f3 | 120 | // */ |
Marcomissyou | 0:4085cc9441f3 | 121 | // int setTxPower(uint8_t powerIndex); |
Marcomissyou | 0:4085cc9441f3 | 122 | |
Marcomissyou | 0:4085cc9441f3 | 123 | }; |
Marcomissyou | 0:4085cc9441f3 | 124 | |
wgd8700 | 11:659b13c3437a | 125 | #endif /* WIFIDEVICE_H_ */ |
wgd8700 | 19:a11db6055532 | 126 | |
wgd8700 | 19:a11db6055532 | 127 |