This application is the simplest one to utilize our mesh networking stack. It just joins your device to the unsecure 6LoWPAN-ND network. The canonical source for this example lives at https://github.com/ARMmbed/mbed-os-example-mesh-minimal

Example mesh application for Mbed OS

With this application, you can use our mesh networking stack. This application joins your device to the unsecure 6LoWPAN-ND network.

Setup

Building with Mbed CLI

If you'd like to use Mbed CLI to build this offline, then you should refer to the Mbed CLI documentation. The instructions here relate to using the Mbed Online Compiler

  1. Click `Import this application` button.
  2. Change the channel settings: See the file `mbed_app.json` for an example of defining an IEEE 802.15.4 channel to use.
  3. Compile the application

A binary is generated at the end of the build process.

Connect the RF shield to the board

By default, we are using the Atmel AT86RF233, which you can purchase. Place the shield on top of your board, and power it on.

Program the target

Drag and drop the binary to the target to program the application.

Update the firmware of the border router.

You can read the instructions on updating the firmware of your board working as 6LoWPAN border router here.

Please remember to connect the Ethernet cable between the border router and your router. Then, power up the board.

Testing

As soon as both the border router and the target are up and running, you can verify the correct behavior. Open a serial console, and see the IP address obtained by the device.

Note: This application uses a baud rate of 115200.

Quote:

connected. IP = 2001:db8:a0b:12f0::1

You can use this IP address to ping from your PC and verify that the connection is working correctly.

Changing the radio driver (optional)

To run a 6LoWPAN-ND network, you need a working RF driver for Nanostack. This example uses the Atmel AT86RF233 by default.

To change the RF driver:

  1. Uninstall the Atmel RF driver.
  2. Install the new driver. (For example, for the FRDM-CR20A radio shield based on the MCR20A device.)
  3. Recompile your application.
Revision:
21:6c1e9147037c
Child:
24:671ef092f6ca
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Jenkinsfile	Tue Oct 25 14:15:10 2016 +0100
@@ -0,0 +1,99 @@
+// List of targets with supported RF shields to compile
+def targets = [
+  "K64F": ["ATMEL", "MCR20"],
+  //"NUCLEO_F401RE": ["ATMEL", "MCR20"],
+  "NUCLEO_F429ZI": ["ATMEL", "MCR20"],
+  //"NCS36510": ["NCS36510"],
+  "UBLOX_EVK_ODIN_W2": ["ATMEL", "MCR20"]
+  ]
+  
+// Map toolchains to compilers
+def toolchains = [
+  ARM: "armcc",
+  GCC_ARM: "arm-none-eabi-gcc",
+  IAR: "iar_arm"
+  ]
+
+// Supported RF shields
+def radioshields = [
+  "ATMEL",
+  "MCR20",
+  "NCS36510"
+  ]
+
+// Mesh interfaces: 6LoWPAN and Thread
+def meshinterfaces = [
+  "6lp",
+  "thd"
+  ]
+  
+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++) {
+      for(int l = 0; l < meshinterfaces.size(); l++) {
+        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 meshInterface = meshinterfaces.get(l)
+        def stepName = "${target} ${toolchain} ${radioshield} ${meshInterface}"
+        if(allowed_shields.contains(radioshield)) {
+          stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, radioshield, meshInterface)
+        }
+      }
+    }
+  }
+}
+
+timestamps {
+  parallel stepsForParallel
+}
+
+def buildStep(target, compilerLabel, toolchain, radioShield, meshInterface) {
+  return {
+    stage ("${target}_${compilerLabel}_${radioShield}_${meshInterface}") {
+      node ("${compilerLabel}") {
+        deleteDir()
+        dir("mbed-os-example-mesh-minimal") {
+          checkout scm
+
+          if ("${radioShield}" == "MCR20") {
+            // Replace default rf shield
+            execute("sed -i 's/\"value\": \"ATMEL\"/\"value\": \"MCR20\"/' mbed_app.json")
+          }
+
+          if ("${radioShield}" == "NCS36510") {
+            // Replace default rf shield
+            execute("sed -i 's/\"value\": \"ATMEL\"/\"value\": \"NCS36510\"/' mbed_app.json")
+          }
+
+          if ("${meshInterface}" == "thd") {
+            // Change mesh interface to thread
+            execute("sed -i 's/\"value\": \"MESH_LOWPAN\"/\"value\": \"MESH_THREAD\"/' mbed_app.json")
+
+            //Change operation mode to Thread router
+            execute("sed -i 's/\"NANOSTACK\", \"LOWPAN_ROUTER\", \"COMMON_PAL\"/\"NANOSTACK\", \"THREAD_ROUTER\", \"COMMON_PAL\"/' mbed_app.json")
+          }
+
+          if ("${meshInterface}" == "6lp") {
+          // Use systest border router for testing
+            execute("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel\": 12/\"mbed-mesh-api.6lowpan-nd-channel\": 18/' mbed_app.json")
+          }
+  
+          execute ("mbed deploy --protocol ssh")
+          // Checkout latest mbed-os master
+          dir("mbed-os") {
+            execute ("git fetch origin master")
+            execute ("git checkout FETCH_HEAD")
+          }
+          execute ("mbed compile --build out/${target}_${toolchain}_${radioShield}_${meshInterface}/ -m ${target} -t ${toolchain} -c")
+        }
+        archive '**/mbed-os-example-mesh-minimal.bin'
+      }
+    }
+  }
+}