WiFi example for mbed OS, fork from https://github.com/ARMmbed/mbed-os-example-wifi

This is a quick example of a simple WiFi application using the WiFi and network-socket APIs that is provided as a part of mbed-os

The program brings up the WiFi and the underlying network interface, and uses it to scans available networks, connects to a network, prints interface and connection details and performs simple HTTP operation.

This example has been used on the following platforms

Note: The ISM43362 WIFI Driver developed by ST Team can also be integrated in the mbed-os-example-client example.

DISCO_L475VG_IOT01A DISCO_F413ZH

Committer:
adustm
Date:
Tue Feb 27 10:59:23 2018 +0100
Revision:
57:c8c960b825f0
Parent:
55:23a0d1e8270a
Child:
58:8d4bde75ebb9
Remove ESP8266 from this example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:857719181846 1 # mbed-os-example-wifi #
mbed_official 0:857719181846 2
mbed_official 49:d44cac40bf15 3 Wi-Fi example for Mbed OS
mbed_official 0:857719181846 4
mbed_official 49:d44cac40bf15 5 ## Getting started with the Wi-Fi API ##
mbed_official 0:857719181846 6
mbed_official 49:d44cac40bf15 7 This is an example of a Wi-Fi application using the Wi-Fi and network socket APIs that [Mbed OS](https://github.com/ARMmbed/mbed-os) provides.
mbed_official 0:857719181846 8
mbed_official 49:d44cac40bf15 9 The program brings up the Wi-Fi and the underlying network interface and uses it to scan available networks, connects to a network, prints interface and connection details and performs an HTTP operation.
mbed_official 49:d44cac40bf15 10
mbed_official 49:d44cac40bf15 11 For more information about Wi-Fi APIs, please visit the [Mbed OS Wi-Fi](https://os.mbed.com/docs/latest/reference/wi-fi.html) documentation.
mbed_official 0:857719181846 12
mbed_official 0:857719181846 13 ### Supported hardware ###
mbed_official 0:857719181846 14
mbed_official 49:d44cac40bf15 15 * [NUCLEO-F401RE](https://os.mbed.com/platforms/ST-Nucleo-F401RE/) with [X-NUCLEO-IDW04A1](http://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32-nucleo-expansion-boards/stm32-ode-connect-hw/x-nucleo-idw04a1.html) Wi-Fi expansion board using pins D8 and D2 _(of the Arduino connector)_.
mbed_official 49:d44cac40bf15 16 * [NUCLEO-F401RE](https://os.mbed.com/platforms/ST-Nucleo-F401RE/) with [X-NUCLEO-IDW01M1](https://os.mbed.com/components/X-NUCLEO-IDW01M1/) Wi-Fi expansion board using pins PA_9 and PA_10 _(of the Morpho connector)_.
adustm adustm@gmail.com 55:23a0d1e8270a 17 * [DISCO_L475VG_IOT01A](https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/) with ISM43362 built-in module
adustm 57:c8c960b825f0 18 * Other Mbed targets with [X-NUCLEO-IDW04A1](http://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32-nucleo-expansion-boards/stm32-ode-connect-hw/x-nucleo-idw04a1.html) or [X-NUCLEO-IDW01M1](https://os.mbed.com/components/X-NUCLEO-IDW01M1/) expansion board.
mbed_official 49:d44cac40bf15 19 *(The Mbed target board the Wi-Fi shield connects to shouldn't have any other network interface, for example Ethernet.)*
mbed_official 0:857719181846 20
mbed_official 44:63be19b7a3db 21 #### Connecting the X-NUCLEO-IDW0XX1 ####
mbed_official 49:d44cac40bf15 22
mbed_official 49:d44cac40bf15 23 To connect the [X-NUCLEO-IDW04A1](http://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32-nucleo-expansion-boards/stm32-ode-connect-hw/x-nucleo-idw04a1.html) or [X-NUCLEO-IDW01M1](https://developer.mbed.org/components/X-NUCLEO-IDW01M1/) expansion board to your NUCLEO development board, plug the expansion board on top of the NUCLEO board using the Arduino or Morpho connector.
mbed_official 6:9944c5308062 24
mbed_official 44:63be19b7a3db 25 ## Getting started ##
mbed_official 0:857719181846 26
mbed_official 49:d44cac40bf15 27 1. Import the example.
mbed_official 0:857719181846 28
mbed_official 32:bca3f5f442b3 29 ```
mbed_official 32:bca3f5f442b3 30 mbed import mbed-os-example-wifi
mbed_official 32:bca3f5f442b3 31 cd mbed-os-example-wifi
mbed_official 32:bca3f5f442b3 32 ```
mbed_official 49:d44cac40bf15 33
mbed_official 49:d44cac40bf15 34 2. Configure the Wi-Fi shield to use.
mbed_official 0:857719181846 35
mbed_official 49:d44cac40bf15 36 Edit ```mbed_app.json``` to include the correct Wi-Fi shield, SSID and password:
mbed_official 0:857719181846 37
mbed_official 32:bca3f5f442b3 38 ```
mbed_official 33:12f0df4d51d7 39 "config": {
mbed_official 32:bca3f5f442b3 40 "wifi-shield": {
adustm 57:c8c960b825f0 41 "help": "Options are WIFI_IDW0XX1",
adustm 57:c8c960b825f0 42 "value": "WIFI_IDW0XX1"
mbed_official 32:bca3f5f442b3 43 },
mbed_official 32:bca3f5f442b3 44 "wifi-ssid": {
mbed_official 32:bca3f5f442b3 45 "help": "WiFi SSID",
mbed_official 32:bca3f5f442b3 46 "value": "\"SSID\""
mbed_official 32:bca3f5f442b3 47 },
mbed_official 32:bca3f5f442b3 48 "wifi-password": {
mbed_official 32:bca3f5f442b3 49 "help": "WiFi Password",
mbed_official 32:bca3f5f442b3 50 "value": "\"Password\""
mbed_official 32:bca3f5f442b3 51 }
mbed_official 32:bca3f5f442b3 52 },
mbed_official 32:bca3f5f442b3 53 ```
mbed_official 0:857719181846 54
adustm 57:c8c960b825f0 55 Sample ```mbed_app.json``` files are provided for X-NUCLEO-IDW04A1 (```mbed_app_idw04a1.json```), X-NUCLEO-IDW01M1 (```mbed_app_idw01m1```) and DISCO_L475VG_IOT01A/ISM43362 (```mbed_app_ism43362.json```)
mbed_official 44:63be19b7a3db 56
mbed_official 49:d44cac40bf15 57 For built-in Wi-Fi, ignore the value of `wifi-shield`.
mbed_official 33:12f0df4d51d7 58
mbed_official 49:d44cac40bf15 59 3. Compile and generate binary.
mbed_official 0:857719181846 60
mbed_official 32:bca3f5f442b3 61 For example, for `GCC`:
mbed_official 32:bca3f5f442b3 62
mbed_official 32:bca3f5f442b3 63 ```
mbed_official 32:bca3f5f442b3 64 mbed compile -t GCC_ARM -m UBLOX_EVK_ODIN_W2
mbed_official 32:bca3f5f442b3 65 ```
mbed_official 36:aa0b6789bbd2 66
mbed_official 44:63be19b7a3db 67 4. Open a serial console session with the target platform using the following parameters:
mbed_official 49:d44cac40bf15 68
mbed_official 36:aa0b6789bbd2 69 * **Baud rate:** 9600
mbed_official 36:aa0b6789bbd2 70 * **Data bits:** 8
mbed_official 36:aa0b6789bbd2 71 * **Stop bits:** 1
mbed_official 36:aa0b6789bbd2 72 * **Parity:** None
mbed_official 36:aa0b6789bbd2 73
mbed_official 44:63be19b7a3db 74 5. Copy or drag the application `mbed-os-example-wifi.bin` in the folder `mbed-os-example-wifi/BUILD/<TARGET NAME>/<PLATFORM NAME>` onto the target board.
mbed_official 36:aa0b6789bbd2 75
mbed_official 49:d44cac40bf15 76 6. The serial console should display a similar output to below, indicating a successful Wi-Fi connection:
mbed_official 49:d44cac40bf15 77
mbed_official 36:aa0b6789bbd2 78 ```
mbed_official 36:aa0b6789bbd2 79 WiFi example
mbed_official 36:aa0b6789bbd2 80
mbed_official 36:aa0b6789bbd2 81 Scan:
mbed_official 36:aa0b6789bbd2 82 Network: Dave Hot Spot secured: Unknown BSSID: 00:01:02:03:04:05 RSSI: -58 Ch: 1
mbed_official 36:aa0b6789bbd2 83 1 network available.
mbed_official 36:aa0b6789bbd2 84
mbed_official 36:aa0b6789bbd2 85 Connecting...
mbed_official 36:aa0b6789bbd2 86 Success
mbed_official 36:aa0b6789bbd2 87
mbed_official 36:aa0b6789bbd2 88 MAC: 00:01:02:03:04:05
mbed_official 36:aa0b6789bbd2 89 IP: 192.168.0.5
mbed_official 36:aa0b6789bbd2 90 Netmask: 255.255.255.0
mbed_official 36:aa0b6789bbd2 91 Gateway: 192.168.0.1
mbed_official 36:aa0b6789bbd2 92 RSSI: -27
mbed_official 36:aa0b6789bbd2 93
mbed_official 36:aa0b6789bbd2 94 Sending HTTP request to www.arm.com...
mbed_official 36:aa0b6789bbd2 95 sent 38 [GET / HTTP/1.1]
mbed_official 36:aa0b6789bbd2 96 recv 64 [HTTP/1.1 301 Moved Permanently]
mbed_official 36:aa0b6789bbd2 97
mbed_official 36:aa0b6789bbd2 98 Done
mbed_official 36:aa0b6789bbd2 99 ```
mbed_official 0:857719181846 100
mbed_official 49:d44cac40bf15 101 ## Troubleshooting
mbed_official 0:857719181846 102
mbed_official 49:d44cac40bf15 103 If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.