Hiroaki Okoshi / Mbed OS mbed-os-example-odinw2-wifi-ap-udp-echo
Committer:
Hiroaki_Okoshi
Date:
Sun Oct 10 15:06:21 2021 +0000
Revision:
0:fffc9412550a
Please note this repository is no longer maintained by u-blox.; ; "# mbed-os-example-odinw2-wifi-ap-udp-echo"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Hiroaki_Okoshi 0:fffc9412550a 1 # mbed-os-example-wifi #
Hiroaki_Okoshi 0:fffc9412550a 2
Hiroaki_Okoshi 0:fffc9412550a 3 Wi-Fi example for Mbed OS
Hiroaki_Okoshi 0:fffc9412550a 4
Hiroaki_Okoshi 0:fffc9412550a 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).)
Hiroaki_Okoshi 0:fffc9412550a 6
Hiroaki_Okoshi 0:fffc9412550a 7 ## Getting started with the Wi-Fi API ##
Hiroaki_Okoshi 0:fffc9412550a 8
Hiroaki_Okoshi 0:fffc9412550a 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.
Hiroaki_Okoshi 0:fffc9412550a 10
Hiroaki_Okoshi 0:fffc9412550a 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.
Hiroaki_Okoshi 0:fffc9412550a 12
Hiroaki_Okoshi 0:fffc9412550a 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.
Hiroaki_Okoshi 0:fffc9412550a 14
Hiroaki_Okoshi 0:fffc9412550a 15 ### Supported hardware ###
Hiroaki_Okoshi 0:fffc9412550a 16
Hiroaki_Okoshi 0:fffc9412550a 17 * All Mbed OS boards with build-in Wi-Fi module:
Hiroaki_Okoshi 0:fffc9412550a 18 * [u-blox ODIN-W2](https://os.mbed.com/platforms/ublox-EVK-ODIN-W2/)
Hiroaki_Okoshi 0:fffc9412550a 19 * [Realtek RTL8195AM](https://os.mbed.com/platforms/REALTEK-RTL8195AM/)
Hiroaki_Okoshi 0:fffc9412550a 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).
Hiroaki_Okoshi 0:fffc9412550a 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).
Hiroaki_Okoshi 0:fffc9412550a 22 * [Advantech WISE-150](https://os.mbed.com/modules/advantech-wise-1530/)
Hiroaki_Okoshi 0:fffc9412550a 23 * USI WM-BN-BM-22
Hiroaki_Okoshi 0:fffc9412550a 24 * MxChip EMW3166
Hiroaki_Okoshi 0:fffc9412550a 25 * Boards with external WiFi shields.
Hiroaki_Okoshi 0:fffc9412550a 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)_.
Hiroaki_Okoshi 0:fffc9412550a 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)_.
Hiroaki_Okoshi 0:fffc9412550a 28 * [NUCLEO-F429ZI](https://os.mbed.com/platforms/ST-Nucleo-F429ZI/) with ESP8266-01 module using pins D1 and D0.
Hiroaki_Okoshi 0:fffc9412550a 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.
Hiroaki_Okoshi 0:fffc9412550a 30
Hiroaki_Okoshi 0:fffc9412550a 31 #### Adding connectivity driver
Hiroaki_Okoshi 0:fffc9412550a 32
Hiroaki_Okoshi 0:fffc9412550a 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.
Hiroaki_Okoshi 0:fffc9412550a 34
Hiroaki_Okoshi 0:fffc9412550a 35 ```
Hiroaki_Okoshi 0:fffc9412550a 36 mbed add <driver>
Hiroaki_Okoshi 0:fffc9412550a 37 ```
Hiroaki_Okoshi 0:fffc9412550a 38
Hiroaki_Okoshi 0:fffc9412550a 39 For example adding ISM43362 driver `mbed add wifi-ism43362` or X-Nucleo-IDW01M1 driver `mbed add wifi-x-nucleo-idw01m1`
Hiroaki_Okoshi 0:fffc9412550a 40 The ESP8266 driver is already suplied by Mbed OS.
Hiroaki_Okoshi 0:fffc9412550a 41
Hiroaki_Okoshi 0:fffc9412550a 42 Then pin names need to be configured as instructed in the drivers README file.
Hiroaki_Okoshi 0:fffc9412550a 43
Hiroaki_Okoshi 0:fffc9412550a 44 ## Getting started ##
Hiroaki_Okoshi 0:fffc9412550a 45
Hiroaki_Okoshi 0:fffc9412550a 46 1. Import the example.
Hiroaki_Okoshi 0:fffc9412550a 47
Hiroaki_Okoshi 0:fffc9412550a 48 ```
Hiroaki_Okoshi 0:fffc9412550a 49 mbed import mbed-os-example-wifi
Hiroaki_Okoshi 0:fffc9412550a 50 cd mbed-os-example-wifi
Hiroaki_Okoshi 0:fffc9412550a 51 ```
Hiroaki_Okoshi 0:fffc9412550a 52
Hiroaki_Okoshi 0:fffc9412550a 53 1. Configure the Wi-Fi shield and settings.
Hiroaki_Okoshi 0:fffc9412550a 54 Edit ```mbed_app.json``` to include the correct Wi-Fi shield, SSID and password:
Hiroaki_Okoshi 0:fffc9412550a 55
Hiroaki_Okoshi 0:fffc9412550a 56 ```json
Hiroaki_Okoshi 0:fffc9412550a 57 {
Hiroaki_Okoshi 0:fffc9412550a 58 "config": {
Hiroaki_Okoshi 0:fffc9412550a 59 "wifi-ssid": {
Hiroaki_Okoshi 0:fffc9412550a 60 "help": "WiFi SSID",
Hiroaki_Okoshi 0:fffc9412550a 61 "value": "\"SSID\""
Hiroaki_Okoshi 0:fffc9412550a 62 },
Hiroaki_Okoshi 0:fffc9412550a 63 "wifi-password": {
Hiroaki_Okoshi 0:fffc9412550a 64 "help": "WiFi Password",
Hiroaki_Okoshi 0:fffc9412550a 65 "value": "\"PASSWORD\""
Hiroaki_Okoshi 0:fffc9412550a 66 }
Hiroaki_Okoshi 0:fffc9412550a 67 },
Hiroaki_Okoshi 0:fffc9412550a 68 "target_overrides": {
Hiroaki_Okoshi 0:fffc9412550a 69 "*": {
Hiroaki_Okoshi 0:fffc9412550a 70 "platform.stdio-convert-newlines": true,
Hiroaki_Okoshi 0:fffc9412550a 71 "esp8266.provide-default" : false
Hiroaki_Okoshi 0:fffc9412550a 72 }
Hiroaki_Okoshi 0:fffc9412550a 73 }
Hiroaki_Okoshi 0:fffc9412550a 74 }
Hiroaki_Okoshi 0:fffc9412550a 75 ```
Hiroaki_Okoshi 0:fffc9412550a 76
Hiroaki_Okoshi 0:fffc9412550a 77 For build-in WiFi, you do not need to set any `provide-default` values. Those are required
Hiroaki_Okoshi 0:fffc9412550a 78 if you use external WiFi shield.
Hiroaki_Okoshi 0:fffc9412550a 79
Hiroaki_Okoshi 0:fffc9412550a 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```).
Hiroaki_Okoshi 0:fffc9412550a 81
Hiroaki_Okoshi 0:fffc9412550a 82
Hiroaki_Okoshi 0:fffc9412550a 83 1. Compile and generate binary.
Hiroaki_Okoshi 0:fffc9412550a 84 For example, for `GCC`:
Hiroaki_Okoshi 0:fffc9412550a 85 ```
Hiroaki_Okoshi 0:fffc9412550a 86 mbed compile -t GCC_ARM -m UBLOX_EVK_ODIN_W2
Hiroaki_Okoshi 0:fffc9412550a 87 ```
Hiroaki_Okoshi 0:fffc9412550a 88
Hiroaki_Okoshi 0:fffc9412550a 89 1. Open a serial console session with the target platform using the following parameters:
Hiroaki_Okoshi 0:fffc9412550a 90 * **Baud rate:** 9600
Hiroaki_Okoshi 0:fffc9412550a 91 * **Data bits:** 8
Hiroaki_Okoshi 0:fffc9412550a 92 * **Stop bits:** 1
Hiroaki_Okoshi 0:fffc9412550a 93 * **Parity:** None
Hiroaki_Okoshi 0:fffc9412550a 94
Hiroaki_Okoshi 0:fffc9412550a 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.
Hiroaki_Okoshi 0:fffc9412550a 96
Hiroaki_Okoshi 0:fffc9412550a 97 1. The serial console should display a similar output to below, indicating a successful Wi-Fi connection:
Hiroaki_Okoshi 0:fffc9412550a 98 ```
Hiroaki_Okoshi 0:fffc9412550a 99 WiFi example
Hiroaki_Okoshi 0:fffc9412550a 100
Hiroaki_Okoshi 0:fffc9412550a 101 Scan:
Hiroaki_Okoshi 0:fffc9412550a 102 Network: Dave Hot Spot secured: Unknown BSSID: 00:01:02:03:04:05 RSSI: -58 Ch: 1
Hiroaki_Okoshi 0:fffc9412550a 103 1 network available.
Hiroaki_Okoshi 0:fffc9412550a 104
Hiroaki_Okoshi 0:fffc9412550a 105 Connecting...
Hiroaki_Okoshi 0:fffc9412550a 106 Success
Hiroaki_Okoshi 0:fffc9412550a 107
Hiroaki_Okoshi 0:fffc9412550a 108 MAC: 00:01:02:03:04:05
Hiroaki_Okoshi 0:fffc9412550a 109 IP: 192.168.0.5
Hiroaki_Okoshi 0:fffc9412550a 110 Netmask: 255.255.255.0
Hiroaki_Okoshi 0:fffc9412550a 111 Gateway: 192.168.0.1
Hiroaki_Okoshi 0:fffc9412550a 112 RSSI: -27
Hiroaki_Okoshi 0:fffc9412550a 113
Hiroaki_Okoshi 0:fffc9412550a 114 Done
Hiroaki_Okoshi 0:fffc9412550a 115 ```
Hiroaki_Okoshi 0:fffc9412550a 116
Hiroaki_Okoshi 0:fffc9412550a 117 ## Troubleshooting
Hiroaki_Okoshi 0:fffc9412550a 118
Hiroaki_Okoshi 0:fffc9412550a 119 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.
Hiroaki_Okoshi 0:fffc9412550a 120
Hiroaki_Okoshi 0:fffc9412550a 121 ### License and contributions
Hiroaki_Okoshi 0:fffc9412550a 122
Hiroaki_Okoshi 0:fffc9412550a 123 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.
Hiroaki_Okoshi 0:fffc9412550a 124
Hiroaki_Okoshi 0:fffc9412550a 125 This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.