WiFi example application for LPC55S69 with ESP8266 shield/module

Committer:
maclobdell
Date:
Wed May 01 20:12:30 2019 +0000
Revision:
1:7a6aa19c0277
Parent:
0:2f4d849e36e5
update to mbed os 5.12.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maclobdell 0:2f4d849e36e5 1 # mbed-os-example-wifi #
maclobdell 0:2f4d849e36e5 2
maclobdell 0:2f4d849e36e5 3 Wi-Fi example for Mbed OS
maclobdell 0:2f4d849e36e5 4
maclobdell 0:2f4d849e36e5 5 (Note: To see this example in a rendered form you can import into the Arm Mbed Online Compiler, please see [the documentation](https://os.mbed.com/docs/mbed-os/latest/apis/wi-fi.html#wi-fi-example).)
maclobdell 0:2f4d849e36e5 6
maclobdell 0:2f4d849e36e5 7 ## Getting started with the Wi-Fi API ##
maclobdell 0:2f4d849e36e5 8
maclobdell 0:2f4d849e36e5 9 This is an example of a Wi-Fi application using the Wi-Fi APIs that [Mbed OS](https://github.com/ARMmbed/mbed-os) provides.
maclobdell 0:2f4d849e36e5 10
maclobdell 0:2f4d849e36e5 11 The program brings up the Wi-Fi and the underlying network interface and uses it to scan available networks, connects to a network and prints interface and connection details.
maclobdell 0:2f4d849e36e5 12
maclobdell 0:2f4d849e36e5 13 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.
maclobdell 0:2f4d849e36e5 14
maclobdell 0:2f4d849e36e5 15 ### Supported hardware ###
maclobdell 0:2f4d849e36e5 16
maclobdell 0:2f4d849e36e5 17 * All Mbed OS boards with build-in Wi-Fi module:
maclobdell 0:2f4d849e36e5 18 * [u-blox ODIN-W2](https://os.mbed.com/platforms/ublox-EVK-ODIN-W2/)
maclobdell 0:2f4d849e36e5 19 * [Realtek RTL8195AM](https://os.mbed.com/platforms/REALTEK-RTL8195AM/)
maclobdell 0:2f4d849e36e5 20 * [ST DISCO IOT board](https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/) with integrated [ISM43362 WiFi Inventek module](https://github.com/ARMmbed/wifi-ism43362).
maclobdell 0:2f4d849e36e5 21 * [ST DISCO_F413ZH board](https://os.mbed.com/platforms/ST-Discovery-F413H/) with integrated [ISM43362 WiFi Inventek module](https://github.com/ARMmbed/wifi-ism43362).
maclobdell 0:2f4d849e36e5 22 * [Advantech WISE-150](https://os.mbed.com/modules/advantech-wise-1530/)
maclobdell 0:2f4d849e36e5 23 * USI WM-BN-BM-22
maclobdell 0:2f4d849e36e5 24 * MxChip EMW3166
maclobdell 0:2f4d849e36e5 25 * Boards with external WiFi shields.
maclobdell 0:2f4d849e36e5 26 * [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)_.
maclobdell 0:2f4d849e36e5 27 * [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)_.
maclobdell 0:2f4d849e36e5 28 * [NUCLEO-F429ZI](https://os.mbed.com/platforms/ST-Nucleo-F429ZI/) with ESP8266-01 module using pins D1 and D0.
maclobdell 0:2f4d849e36e5 29 * Other Mbed targets with an ESP8266 module, [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.
maclobdell 0:2f4d849e36e5 30
maclobdell 0:2f4d849e36e5 31 #### Adding connectivity driver
maclobdell 0:2f4d849e36e5 32
maclobdell 0:2f4d849e36e5 33 If the target does not have internal WiFi driver, or Mbed OS does not supply one, you need to add driver to your application and configure it to provide default WiFi interface.
maclobdell 0:2f4d849e36e5 34
maclobdell 0:2f4d849e36e5 35 ```
maclobdell 0:2f4d849e36e5 36 mbed add <driver>
maclobdell 0:2f4d849e36e5 37 ```
maclobdell 0:2f4d849e36e5 38
maclobdell 0:2f4d849e36e5 39 For example adding ISM43362 driver `mbed add wifi-ism43362` or X-Nucleo-IDW01M1 driver `mbed add wifi-x-nucleo-idw01m1`
maclobdell 0:2f4d849e36e5 40 The ESP8266 driver is already suplied by Mbed OS.
maclobdell 0:2f4d849e36e5 41
maclobdell 0:2f4d849e36e5 42 Then pin names need to be configured as instructed in the drivers README file.
maclobdell 0:2f4d849e36e5 43
maclobdell 0:2f4d849e36e5 44 ## Getting started ##
maclobdell 0:2f4d849e36e5 45
maclobdell 0:2f4d849e36e5 46 1. Import the example.
maclobdell 0:2f4d849e36e5 47
maclobdell 0:2f4d849e36e5 48 ```
maclobdell 0:2f4d849e36e5 49 mbed import mbed-os-example-wifi
maclobdell 0:2f4d849e36e5 50 cd mbed-os-example-wifi
maclobdell 0:2f4d849e36e5 51 ```
maclobdell 0:2f4d849e36e5 52
maclobdell 0:2f4d849e36e5 53 1. Configure the Wi-Fi shield and settings.
maclobdell 0:2f4d849e36e5 54 Edit ```mbed_app.json``` to include the correct Wi-Fi shield, SSID and password:
maclobdell 0:2f4d849e36e5 55
maclobdell 0:2f4d849e36e5 56 ```json
maclobdell 0:2f4d849e36e5 57 {
maclobdell 0:2f4d849e36e5 58 "config": {
maclobdell 0:2f4d849e36e5 59 "wifi-ssid": {
maclobdell 0:2f4d849e36e5 60 "help": "WiFi SSID",
maclobdell 0:2f4d849e36e5 61 "value": "\"SSID\""
maclobdell 0:2f4d849e36e5 62 },
maclobdell 0:2f4d849e36e5 63 "wifi-password": {
maclobdell 0:2f4d849e36e5 64 "help": "WiFi Password",
maclobdell 0:2f4d849e36e5 65 "value": "\"PASSWORD\""
maclobdell 0:2f4d849e36e5 66 }
maclobdell 0:2f4d849e36e5 67 },
maclobdell 0:2f4d849e36e5 68 "target_overrides": {
maclobdell 0:2f4d849e36e5 69 "*": {
maclobdell 0:2f4d849e36e5 70 "platform.stdio-convert-newlines": true,
maclobdell 0:2f4d849e36e5 71 "esp8266.provide-default" : false
maclobdell 0:2f4d849e36e5 72 }
maclobdell 0:2f4d849e36e5 73 }
maclobdell 0:2f4d849e36e5 74 }
maclobdell 0:2f4d849e36e5 75 ```
maclobdell 0:2f4d849e36e5 76
maclobdell 0:2f4d849e36e5 77 For build-in WiFi, you do not need to set any `provide-default` values. Those are required
maclobdell 0:2f4d849e36e5 78 if you use external WiFi shield.
maclobdell 0:2f4d849e36e5 79
maclobdell 0:2f4d849e36e5 80 Sample ```mbed_app.json``` files are provided for ESP8266 (```mbed_app_esp8266.json```), X-NUCLEO-IDW04A1 (```mbed_app_idw04a1.json```) and X-NUCLEO-IDW01M1 (```mbed_app_idw01m1```).
maclobdell 0:2f4d849e36e5 81
maclobdell 0:2f4d849e36e5 82
maclobdell 0:2f4d849e36e5 83 1. Compile and generate binary.
maclobdell 0:2f4d849e36e5 84 For example, for `GCC`:
maclobdell 0:2f4d849e36e5 85 ```
maclobdell 0:2f4d849e36e5 86 mbed compile -t GCC_ARM -m UBLOX_EVK_ODIN_W2
maclobdell 0:2f4d849e36e5 87 ```
maclobdell 0:2f4d849e36e5 88
maclobdell 0:2f4d849e36e5 89 1. Open a serial console session with the target platform using the following parameters:
maclobdell 0:2f4d849e36e5 90 * **Baud rate:** 9600
maclobdell 0:2f4d849e36e5 91 * **Data bits:** 8
maclobdell 0:2f4d849e36e5 92 * **Stop bits:** 1
maclobdell 0:2f4d849e36e5 93 * **Parity:** None
maclobdell 0:2f4d849e36e5 94
maclobdell 0:2f4d849e36e5 95 1. 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.
maclobdell 0:2f4d849e36e5 96
maclobdell 0:2f4d849e36e5 97 1. The serial console should display a similar output to below, indicating a successful Wi-Fi connection:
maclobdell 0:2f4d849e36e5 98 ```
maclobdell 0:2f4d849e36e5 99 WiFi example
maclobdell 0:2f4d849e36e5 100
maclobdell 0:2f4d849e36e5 101 Scan:
maclobdell 0:2f4d849e36e5 102 Network: Dave Hot Spot secured: Unknown BSSID: 00:01:02:03:04:05 RSSI: -58 Ch: 1
maclobdell 0:2f4d849e36e5 103 1 network available.
maclobdell 0:2f4d849e36e5 104
maclobdell 0:2f4d849e36e5 105 Connecting...
maclobdell 0:2f4d849e36e5 106 Success
maclobdell 0:2f4d849e36e5 107
maclobdell 0:2f4d849e36e5 108 MAC: 00:01:02:03:04:05
maclobdell 0:2f4d849e36e5 109 IP: 192.168.0.5
maclobdell 0:2f4d849e36e5 110 Netmask: 255.255.255.0
maclobdell 0:2f4d849e36e5 111 Gateway: 192.168.0.1
maclobdell 0:2f4d849e36e5 112 RSSI: -27
maclobdell 0:2f4d849e36e5 113
maclobdell 0:2f4d849e36e5 114 Sending HTTP request to www.arm.com...
maclobdell 0:2f4d849e36e5 115 sent 38 [GET / HTTP/1.1]
maclobdell 0:2f4d849e36e5 116 recv 64 [HTTP/1.1 301 Moved Permanently]
maclobdell 0:2f4d849e36e5 117
maclobdell 0:2f4d849e36e5 118 Done
maclobdell 0:2f4d849e36e5 119 ```
maclobdell 0:2f4d849e36e5 120
maclobdell 0:2f4d849e36e5 121 ## Troubleshooting
maclobdell 0:2f4d849e36e5 122
maclobdell 0:2f4d849e36e5 123 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.
maclobdell 0:2f4d849e36e5 124
maclobdell 0:2f4d849e36e5 125 ### License and contributions
maclobdell 0:2f4d849e36e5 126
maclobdell 0:2f4d849e36e5 127 The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info.
maclobdell 0:2f4d849e36e5 128
maclobdell 0:2f4d849e36e5 129 This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.