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 08:15:03 2017 +0000
Parent:
42:bc09823900d8
Child:
44:63be19b7a3db
Commit message:
Add Jenkinsfile

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

Changed in this revision

.mbedignore Show annotated file Show diff for this revision Revisions of this file
Jenkinsfile Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib 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
--- a/.mbedignore	Thu Nov 09 10:15:04 2017 +0000
+++ b/.mbedignore	Tue Nov 21 08:15:03 2017 +0000
@@ -1,2 +1,1 @@
 wifi-x-nucleo-idw01m1/*
-esp8266-driver/*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jenkinsfile	Tue Nov 21 08:15:03 2017 +0000
@@ -0,0 +1,100 @@
+properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
+  [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: '', description: 'Revision of mbed-os to build. Use format "pull/PR-NUMBER/head" to access mbed-os PR']
+  ]]])
+
+if (params.mbed_os_revision == '') {
+  echo 'Use mbed OS revision from mbed-os.lib'
+} else {
+  echo "Use mbed OS revisiong ${params.mbed_os_revision}"
+  if (params.mbed_os_revision.matches('pull/\\d+/head')) {
+    echo "Revision is a Pull Request"
+  }
+}
+
+// List of targets with supported RF shields to compile
+def targets = [
+  "UBLOX_EVK_ODIN_W2": ["builtin"],
+  "REALTEK_RTL8195AM": ["builtin"],
+  "K64F": ["WIFI_ESP8266"],
+  "NUCLEO_F401RE": ["WIFI_IDW01M1"],
+  "NUCLEO_F429ZI": ["WIFI_ESP8266"]
+  ]
+
+// Map toolchains to compilers
+def toolchains = [
+  ARM: "armcc",
+  GCC_ARM: "arm-none-eabi-gcc",
+  IAR: "IAR-linux"
+  ]
+
+// Supported RF shields
+def radioshields = [
+  "builtin",
+  "WIFI_IDW01M1",
+  "WIFI_ESP8266"
+  ]
+
+def stepsForParallel = [:]
+
+// Jenkins pipeline does not support map.each, we need to use oldschool for loop
+for (int i = 0; i < targets.size(); i++) {
+    for(int j = 0; j < toolchains.size(); j++) {
+        for(int k = 0; k < radioshields.size(); k++) {
+            def target = targets.keySet().asList().get(i)
+            def allowed_shields = targets.get(target)
+            def toolchain = toolchains.keySet().asList().get(j)
+            def compilerLabel = toolchains.get(toolchain)
+            def radioshield = radioshields.get(k)
+
+            def stepName = "${target} ${toolchain} ${radioshield}"
+            if(allowed_shields.contains(radioshield)) {
+              stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, radioshield)
+            }
+        }
+    }
+}
+
+timestamps {
+  parallel stepsForParallel
+}
+
+def buildStep(target, compilerLabel, toolchain, radioShield) {
+  return {
+    stage ("${target}_${compilerLabel}_${radioShield}") {
+      node ("${compilerLabel}") {
+        deleteDir()
+        dir("mbed-os-example-wifi") {
+          checkout scm
+          def config_file = "mbed_app.json"
+
+          if ("${radioShield}" != "internal") {
+            // Replace default rf shield
+            execute("sed -i 's/\"value\": \"internal\"/\"value\": \"${radioShield}\"/' ${config_file}")
+          }
+
+          if ("${radioShield}" == "WIFI_IDW01M1") {
+            execute("rm .mbedignore")
+          }
+
+          // Set mbed-os to revision received as parameter
+          execute ("mbed deploy --protocol ssh")
+          if (params.mbed_os_revision != '') {
+            dir ("mbed-os") {
+              if (params.mbed_os_revision.matches('pull/\\d+/head')) {
+                execute("git fetch origin ${params.mbed_os_revision}:PR")
+                execute("git checkout PR")
+              } else {
+                execute ("git checkout ${params.mbed_os_revision}")
+              }
+            }
+          }
+
+          execute ("mbed compile --build out/${target}_${toolchain}_${radioShield}/ -m ${target} -t ${toolchain} -c --app-config ${config_file}")
+        }
+        stash name: "${target}_${toolchain}_${radioShield}", includes: '**/mbed-os-example-wifi.bin'
+        archive '**/mbed-os-example-wifi.bin'
+        step([$class: 'WsCleanup'])
+      }
+    }
+  }
+}
--- a/mbed-os.lib	Thu Nov 09 10:15:04 2017 +0000
+++ b/mbed-os.lib	Tue Nov 21 08:15:03 2017 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#78474a5129e18e136cc7e872adbaa5b74fbb8f6a
+https://github.com/ARMmbed/mbed-os/#34b61d1612aaec2e5d61a8a43c9764bc2fe8aac0
--- a/mbed_app.json	Thu Nov 09 10:15:04 2017 +0000
+++ b/mbed_app.json	Tue Nov 21 08:15:03 2017 +0000
@@ -1,8 +1,8 @@
 {
     "config": {
 	"wifi-shield": {
-            "help": "Options are WIFI_ESP8266, WIFI_IDW01M1",
-            "value": "WIFI_IDW01M1"
+            "help": "Options are internal, WIFI_ESP8266, WIFI_IDW01M1",
+            "value": "internal"
 	},
         "wifi-ssid": {
             "help": "WiFi SSID",