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.

Supported hardware:

Not that the mbed target board the WiFi shield gets connected to shouldn't have any other network interface e.g. Ethernet.

ESP8266 is a fallback option and will be used if the build is for unsupported platform.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Nov 21 11:30:03 2017 +0000
Parent:
43:45429aa163a0
Child:
45:e44678f8d08d
Commit message:
Add STM WiFi expansion boards `X-NUCLEO-IDW0XX1`

.
Commit copied from https://github.com/ARMmbed/mbed-os-example-wifi

Changed in this revision

.mbedignore Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
esp8266-mbedignore Show diff for this revision Revisions of this file
idw01m1-mbedignore Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
mbed_app_esp8266.json Show annotated file Show diff for this revision Revisions of this file
mbed_app_idw01m1.json Show annotated file Show diff for this revision Revisions of this file
mbed_app_idw04a1.json Show annotated file Show diff for this revision Revisions of this file
wifi-x-nucleo-idw01m1.lib Show annotated file Show diff for this revision Revisions of this file
--- a/.mbedignore	Tue Nov 21 08:15:03 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-wifi-x-nucleo-idw01m1/*
--- a/README.md	Tue Nov 21 08:15:03 2017 +0000
+++ b/README.md	Tue Nov 21 11:30:03 2017 +0000
@@ -12,10 +12,11 @@
 
 * [UBLOX Odin board](https://developer.mbed.org/platforms/ublox-EVK-ODIN-W2/) built-in WiFi module
 * [REALTEK_RTL8195AM](https://developer.mbed.org/platforms/REALTEK-RTL8195AM/) built-in WiFi module
-* [NUCLEO_F401RE](https://developer.mbed.org/platforms/ST-Nucleo-F401RE/) with [X-NUCLEO-IDW01M1](https://developer.mbed.org/components/X-NUCLEO-IDW01M1/) WiFi expansion board using pins D8 D2
+* [NUCLEO_F401RE](https://developer.mbed.org/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) WiFi expansion board using pins D8 D2 _(of the Arduino connector)_
+* [NUCLEO_F401RE](https://developer.mbed.org/platforms/ST-Nucleo-F401RE/) with [X-NUCLEO-IDW01M1](https://developer.mbed.org/components/X-NUCLEO-IDW01M1/) WiFi expansion board using pins PA_9 PA_10 _(of the Morpho connector)_
 * [NUCLEO_F429ZI](https://developer.mbed.org/platforms/ST-Nucleo-F429ZI/) with ESP8266-01 module using pins D1 D0
 * [NUCLEO_L476RG](https://developer.mbed.org/platforms/ST-Nucleo-L476RG/) with ESP8266-01 module using pins D8 D2
-* Other mbed targets with ESP8266 module or [X-NUCLEO-IDW01M1](https://developer.mbed.org/components/X-NUCLEO-IDW01M1/) expansion board
+* Other mbed targets with 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://developer.mbed.org/components/X-NUCLEO-IDW01M1/) expansion board
   *(the mbed target board the WiFi shield gets connected to shouldn't have any other network interface e.g. Ethernet)*
 
 ESP8266 is a fallback option and will be used if the build is for unsupported platform.
@@ -25,10 +26,10 @@
 
 **Note:** on NUCLEO development boards, pins `D0` and `D1` are used for serial communication with the computer. Use pins `D8` (to ESP8266 TX) and `D2` (to ESP8266 RX) instead.
 
-#### Connecting the X-NUCLEO-IDW01M1 ####
-To connect the [X-NUCLEO-IDW01M1](https://developer.mbed.org/components/X-NUCLEO-IDW01M1/) expansion board to your NUCLEO development board, just plug the expansion board on top of the NUCLEO board using the Morpho connector.
+#### Connecting the X-NUCLEO-IDW0XX1 ####
+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, just plug the expansion board on top of the NUCLEO board using the Arduino or Morpho connector, respectively.
 
-##  Getting started
+##  Getting started ##
 
 1. Import the example
 
@@ -43,8 +44,8 @@
    ```
        "config": {
  	  "wifi-shield": {
-               "help": "Options are WIFI_ESP8266, WIFI_IDW01M1",
-               "value": "WIFI_IDW01M1"
+               "help": "Options are WIFI_ESP8266, WIFI_IDW0XX1",
+               "value": "WIFI_ESP8266"
         	  },
            "wifi-ssid": {
                "help": "WiFi SSID",
@@ -57,14 +58,11 @@
        },
    ```
 
+   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```).
+   
    For built-in WiFi, ignore the value of `wifi-shield`
 
-3. Copy the respective _ignore_ file to `.mbedignore`
-   * Copy `esp8266-mbedignore` when using ESP8266 module.
-   * Copy `idw01m1-mbedignore` when using [X-NUCLEO-IDW01M1](https://developer.mbed.org/components/X-NUCLEO-IDW01M1/) expansion board.
-   * For built-in WiFi, keep the default `.mbedignore`
-
-4. Compile and generate binary
+3. Compile and generate binary
 
    For example, for `GCC`:
 
@@ -72,15 +70,15 @@
    mbed compile -t GCC_ARM -m UBLOX_EVK_ODIN_W2
    ```
    
- 5. Open a serial console session with the target platform using the following parameters:
+ 4. Open a serial console session with the target platform using the following parameters:
     * **Baud rate:** 9600
     * **Data bits:** 8
     * **Stop bits:** 1
     * **Parity:** None
  
- 6. 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.
+ 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.
  
- 7. The serial console should display a similar output to below, indicating a successful WiFi connection:
+ 6. The serial console should display a similar output to below, indicating a successful WiFi connection:
  ```
  WiFi example
 
--- a/esp8266-mbedignore	Tue Nov 21 08:15:03 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-wifi-x-nucleo-idw01m1/*
--- a/idw01m1-mbedignore	Tue Nov 21 08:15:03 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-esp8266-driver/*
--- a/main.cpp	Tue Nov 21 08:15:03 2017 +0000
+++ b/main.cpp	Tue Nov 21 11:30:03 2017 +0000
@@ -18,7 +18,7 @@
 #include "TCPSocket.h"
 
 #define WIFI_ESP8266    1
-#define WIFI_IDW01M1    2
+#define WIFI_IDW0XX1    2
 
 #if TARGET_UBLOX_EVK_ODIN_W2
 #include "OdinWiFiInterface.h"
@@ -33,10 +33,10 @@
 #if MBED_CONF_APP_WIFI_SHIELD == WIFI_ESP8266
 #include "ESP8266Interface.h"
 ESP8266Interface wifi(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX);
-#elif MBED_CONF_APP_WIFI_SHIELD == WIFI_IDW01M1
+#elif MBED_CONF_APP_WIFI_SHIELD == WIFI_IDW0XX1
 #include "SpwfSAInterface.h"
 SpwfSAInterface wifi(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX);
-#endif // MBED_CONF_APP_WIFI_SHIELD == WIFI_IDW01M1
+#endif // MBED_CONF_APP_WIFI_SHIELD == WIFI_IDW0XX1
 
 #endif
 
--- a/mbed_app.json	Tue Nov 21 08:15:03 2017 +0000
+++ b/mbed_app.json	Tue Nov 21 11:30:03 2017 +0000
@@ -1,7 +1,7 @@
 {
     "config": {
 	"wifi-shield": {
-            "help": "Options are internal, WIFI_ESP8266, WIFI_IDW01M1",
+            "help": "Options are internal, WIFI_ESP8266, WIFI_IDW0XX1",
             "value": "internal"
 	},
         "wifi-ssid": {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app_esp8266.json	Tue Nov 21 11:30:03 2017 +0000
@@ -0,0 +1,40 @@
+{
+    "config": {
+	"wifi-shield": {
+            "help": "Options are internal, WIFI_ESP8266, WIFI_IDW0XX1",
+            "value": "WIFI_ESP8266"
+	},
+        "wifi-ssid": {
+            "help": "WiFi SSID",
+            "value": "\"SSID\""
+        },
+        "wifi-password": {
+            "help": "WiFi Password",
+            "value": "\"PASSWORD\""
+        },
+        "wifi-tx": {
+            "help": "TX pin for serial connection to external device",
+            "value": "D1"
+        },
+        "wifi-rx": {
+            "help": "RX pin for serial connection to external device",
+            "value": "D0"
+        }
+    },
+    "target_overrides": {
+        "*": {
+            "platform.stdio-convert-newlines": true
+        },
+        "UBLOX_EVK_ODIN_W2": {
+            "target.device_has": ["EMAC"]
+        },
+        "NUCLEO_L476RG": {
+            "wifi-tx": "D8",
+            "wifi-rx": "D2"
+        },
+        "NUCLEO_F401RE": {
+            "wifi-tx": "D8",
+            "wifi-rx": "D2"
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app_idw01m1.json	Tue Nov 21 11:30:03 2017 +0000
@@ -0,0 +1,35 @@
+{
+    "config": {
+	"wifi-shield": {
+            "help": "Options are internal, WIFI_ESP8266, WIFI_IDW0XX1",
+            "value": "WIFI_IDW0XX1"
+	},
+        "wifi-ssid": {
+            "help": "WiFi SSID",
+            "value": "\"SSID\""
+        },
+        "wifi-password": {
+            "help": "WiFi Password",
+            "value": "\"PASSWORD\""
+        },
+        "wifi-tx": {
+            "help": "TX pin for serial connection to external device",
+            "value": "PA_9"
+        },
+        "wifi-rx": {
+            "help": "RX pin for serial connection to external device",
+            "value": "PA_10"
+        }
+    },
+    "target_overrides": {
+        "*": {
+            "platform.stdio-convert-newlines": true,
+            "idw0xx1.expansion-board": "IDW01M1",
+	    "drivers.uart-serial-txbuf-size": 730,
+	    "drivers.uart-serial-rxbuf-size": 730
+        },
+        "UBLOX_EVK_ODIN_W2": {
+            "target.device_has": ["EMAC"]
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app_idw04a1.json	Tue Nov 21 11:30:03 2017 +0000
@@ -0,0 +1,36 @@
+{
+    "config": {
+	"wifi-shield": {
+            "help": "Options are internal, WIFI_ESP8266, WIFI_IDW0XX1",
+            "value": "WIFI_IDW0XX1"
+	},
+        "wifi-ssid": {
+            "help": "WiFi SSID",
+            "value": "\"SSID\""
+        },
+        "wifi-password": {
+            "help": "WiFi Password",
+            "value": "\"PASSWORD\""
+        },
+        "wifi-tx": {
+            "help": "TX pin for serial connection to external device",
+            "value": "D8"
+        },
+        "wifi-rx": {
+            "help": "RX pin for serial connection to external device",
+            "value": "D2"
+        }
+    },
+    "target_overrides": {
+        "*": {
+            "platform.stdio-convert-newlines": true,
+            "idw0xx1.expansion-board": "IDW04A1",
+	    "drivers.uart-serial-txbuf-size": 750,
+	    "drivers.uart-serial-rxbuf-size": 750
+        },
+	"UBLOX_EVK_ODIN_W2": {
+            "target.device_has": ["EMAC"]
+	}
+    },
+    "macros": ["IDW04A1_WIFI_HW_BUG_WA"]
+}
--- a/wifi-x-nucleo-idw01m1.lib	Tue Nov 21 08:15:03 2017 +0000
+++ b/wifi-x-nucleo-idw01m1.lib	Tue Nov 21 11:30:03 2017 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/wifi-x-nucleo-idw01m1/#6ec4ac4a662fae9cca087dc3b57395da950a1ba5
\ No newline at end of file
+https://github.com/ARMmbed/wifi-x-nucleo-idw01m1/#5871f7011d7ff2c50e3faf992ebab88e9f69dc95
\ No newline at end of file