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.
Committer:
mbed_official
Date:
Thu Mar 09 11:00:21 2017 +0000
Revision:
49:425a1889434d
Parent:
46:178b1dba32cc
Child:
50:5d4045379c2f
Merge branch 'oob_test_mbed-os-5.4'

* oob_test_mbed-os-5.4:
Update README.md
Update README.md
Update README.md
Add hardware notes
Updating mbed-os to mbed-os-5.4.0-rc2
- json config created for 6LoWPAN
Build against mbed OS 5.4 RC
Fix Thread channel configs
New Thread network configurations updated.
Add configuration file for Thread
Updating mbed-os to mbed-os-5.4.0-rc1

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 26:b28ab71ff595 1 properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
mbed_official 46:178b1dba32cc 2 [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: 'mbed-os-5.4', description: 'Revision of mbed-os to build'],
mbed_official 26:b28ab71ff595 3 [$class: 'BooleanParameterDefinition', name: 'smoke_test', defaultValue: false, description: 'Enable to run HW smoke test after building']
mbed_official 26:b28ab71ff595 4 ]]])
mbed_official 26:b28ab71ff595 5
mbed_official 32:8b28e79d2ed0 6 echo "Run smoke tests: ${params.smoke_test}"
mbed_official 26:b28ab71ff595 7
mbed_official 26:b28ab71ff595 8 try {
mbed_official 26:b28ab71ff595 9 echo "Verifying build with mbed-os version ${mbed_os_revision}"
mbed_official 26:b28ab71ff595 10 env.MBED_OS_REVISION = "${mbed_os_revision}"
mbed_official 26:b28ab71ff595 11 } catch (err) {
mbed_official 26:b28ab71ff595 12 def mbed_os_revision = "master"
mbed_official 26:b28ab71ff595 13 echo "Verifying build with mbed-os version ${mbed_os_revision}"
mbed_official 26:b28ab71ff595 14 env.MBED_OS_REVISION = "${mbed_os_revision}"
mbed_official 26:b28ab71ff595 15 }
mbed_official 26:b28ab71ff595 16
mbed_official 26:b28ab71ff595 17 // Map RaaS instances to corresponding test suites
mbed_official 26:b28ab71ff595 18 def raas = [
mbed_official 26:b28ab71ff595 19 "lowpan_mesh_minimal_smoke_k64f_atmel.json": "8001",
mbed_official 26:b28ab71ff595 20 "lowpan_mesh_minimal_smoke_k64f_mcr20.json": "8034",
mbed_official 26:b28ab71ff595 21 "lowpan_mesh_minimal_smoke_429zi_atmel.json": "8030",
mbed_official 26:b28ab71ff595 22 "lowpan_mesh_minimal_smoke_429zi_mcr20.json": "8033",
mbed_official 26:b28ab71ff595 23 "lowpan_mesh_minimal_smoke_ublox_atmel.json": "8031",
mbed_official 26:b28ab71ff595 24 "thread_mesh_minimal_smoke_k64f_atmel.json": "8007",
mbed_official 26:b28ab71ff595 25 "thread_mesh_minimal_smoke_k64f_mcr20.json": "8034",
mbed_official 26:b28ab71ff595 26 "thread_mesh_minimal_smoke_429zi_atmel.json": "8030",
mbed_official 26:b28ab71ff595 27 "thread_mesh_minimal_smoke_429zi_mcr20.json": "8033",
mbed_official 26:b28ab71ff595 28 "thread_mesh_minimal_smoke_ublox_atmel.json": "8031"
mbed_official 26:b28ab71ff595 29 ]
mbed_official 26:b28ab71ff595 30
mbed_official 21:6c1e9147037c 31 // List of targets with supported RF shields to compile
mbed_official 21:6c1e9147037c 32 def targets = [
mbed_official 21:6c1e9147037c 33 "K64F": ["ATMEL", "MCR20"],
mbed_official 27:2b3fc6ca5872 34 "NUCLEO_F401RE": ["ATMEL", "MCR20"],
mbed_official 21:6c1e9147037c 35 "NUCLEO_F429ZI": ["ATMEL", "MCR20"],
mbed_official 21:6c1e9147037c 36 //"NCS36510": ["NCS36510"],
mbed_official 26:b28ab71ff595 37 "UBLOX_EVK_ODIN_W2": ["ATMEL"]
mbed_official 21:6c1e9147037c 38 ]
mbed_official 34:bc1827b97c5e 39
mbed_official 21:6c1e9147037c 40 // Map toolchains to compilers
mbed_official 21:6c1e9147037c 41 def toolchains = [
mbed_official 21:6c1e9147037c 42 ARM: "armcc",
mbed_official 21:6c1e9147037c 43 GCC_ARM: "arm-none-eabi-gcc",
mbed_official 21:6c1e9147037c 44 IAR: "iar_arm"
mbed_official 21:6c1e9147037c 45 ]
mbed_official 21:6c1e9147037c 46
mbed_official 21:6c1e9147037c 47 // Supported RF shields
mbed_official 21:6c1e9147037c 48 def radioshields = [
mbed_official 21:6c1e9147037c 49 "ATMEL",
mbed_official 21:6c1e9147037c 50 "MCR20",
mbed_official 21:6c1e9147037c 51 "NCS36510"
mbed_official 21:6c1e9147037c 52 ]
mbed_official 21:6c1e9147037c 53
mbed_official 21:6c1e9147037c 54 // Mesh interfaces: 6LoWPAN and Thread
mbed_official 21:6c1e9147037c 55 def meshinterfaces = [
mbed_official 21:6c1e9147037c 56 "6lp",
mbed_official 21:6c1e9147037c 57 "thd"
mbed_official 21:6c1e9147037c 58 ]
mbed_official 34:bc1827b97c5e 59
mbed_official 21:6c1e9147037c 60 def stepsForParallel = [:]
mbed_official 21:6c1e9147037c 61
mbed_official 21:6c1e9147037c 62 // Jenkins pipeline does not support map.each, we need to use oldschool for loop
mbed_official 21:6c1e9147037c 63 for (int i = 0; i < targets.size(); i++) {
mbed_official 21:6c1e9147037c 64 for(int j = 0; j < toolchains.size(); j++) {
mbed_official 21:6c1e9147037c 65 for(int k = 0; k < radioshields.size(); k++) {
mbed_official 21:6c1e9147037c 66 for(int l = 0; l < meshinterfaces.size(); l++) {
mbed_official 21:6c1e9147037c 67 def target = targets.keySet().asList().get(i)
mbed_official 21:6c1e9147037c 68 def allowed_shields = targets.get(target)
mbed_official 21:6c1e9147037c 69 def toolchain = toolchains.keySet().asList().get(j)
mbed_official 21:6c1e9147037c 70 def compilerLabel = toolchains.get(toolchain)
mbed_official 21:6c1e9147037c 71 def radioshield = radioshields.get(k)
mbed_official 21:6c1e9147037c 72 def meshInterface = meshinterfaces.get(l)
mbed_official 27:2b3fc6ca5872 73
mbed_official 27:2b3fc6ca5872 74 // Skip unwanted combination
mbed_official 27:2b3fc6ca5872 75 if (target == "NUCLEO_F401RE" && toolchain == "IAR") {
mbed_official 27:2b3fc6ca5872 76 continue
mbed_official 27:2b3fc6ca5872 77 }
mbed_official 27:2b3fc6ca5872 78
mbed_official 21:6c1e9147037c 79 def stepName = "${target} ${toolchain} ${radioshield} ${meshInterface}"
mbed_official 21:6c1e9147037c 80 if(allowed_shields.contains(radioshield)) {
mbed_official 21:6c1e9147037c 81 stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, radioshield, meshInterface)
mbed_official 21:6c1e9147037c 82 }
mbed_official 21:6c1e9147037c 83 }
mbed_official 21:6c1e9147037c 84 }
mbed_official 21:6c1e9147037c 85 }
mbed_official 21:6c1e9147037c 86 }
mbed_official 21:6c1e9147037c 87
mbed_official 26:b28ab71ff595 88 def parallelRunSmoke = [:]
mbed_official 26:b28ab71ff595 89
mbed_official 26:b28ab71ff595 90 // Need to compare boolean against string value
mbed_official 34:bc1827b97c5e 91 if ( params.smoke_test == true ) {
mbed_official 26:b28ab71ff595 92 // Generate smoke tests based on suite amount
mbed_official 26:b28ab71ff595 93 for(int i = 0; i < raas.size(); i++) {
mbed_official 26:b28ab71ff595 94 def suite_to_run = raas.keySet().asList().get(i)
mbed_official 26:b28ab71ff595 95 def raasPort = raas.get(suite_to_run)
mbed_official 26:b28ab71ff595 96 // Parallel execution needs unique step names. Remove .json file ending.
mbed_official 26:b28ab71ff595 97 def smokeStep = "${raasPort} ${suite_to_run.substring(0, suite_to_run.indexOf('.'))}"
mbed_official 26:b28ab71ff595 98 parallelRunSmoke[smokeStep] = run_smoke(targets, toolchains, radioshields, meshinterfaces, raasPort, suite_to_run)
mbed_official 26:b28ab71ff595 99 }
mbed_official 26:b28ab71ff595 100 }
mbed_official 26:b28ab71ff595 101
mbed_official 21:6c1e9147037c 102 timestamps {
mbed_official 21:6c1e9147037c 103 parallel stepsForParallel
mbed_official 26:b28ab71ff595 104 parallel parallelRunSmoke
mbed_official 21:6c1e9147037c 105 }
mbed_official 21:6c1e9147037c 106
mbed_official 21:6c1e9147037c 107 def buildStep(target, compilerLabel, toolchain, radioShield, meshInterface) {
mbed_official 21:6c1e9147037c 108 return {
mbed_official 21:6c1e9147037c 109 stage ("${target}_${compilerLabel}_${radioShield}_${meshInterface}") {
mbed_official 21:6c1e9147037c 110 node ("${compilerLabel}") {
mbed_official 21:6c1e9147037c 111 deleteDir()
mbed_official 21:6c1e9147037c 112 dir("mbed-os-example-mesh-minimal") {
mbed_official 21:6c1e9147037c 113 checkout scm
mbed_official 21:6c1e9147037c 114
mbed_official 21:6c1e9147037c 115 if ("${radioShield}" == "MCR20") {
mbed_official 21:6c1e9147037c 116 // Replace default rf shield
mbed_official 21:6c1e9147037c 117 execute("sed -i 's/\"value\": \"ATMEL\"/\"value\": \"MCR20\"/' mbed_app.json")
mbed_official 21:6c1e9147037c 118 }
mbed_official 21:6c1e9147037c 119
mbed_official 21:6c1e9147037c 120 if ("${radioShield}" == "NCS36510") {
mbed_official 21:6c1e9147037c 121 // Replace default rf shield
mbed_official 21:6c1e9147037c 122 execute("sed -i 's/\"value\": \"ATMEL\"/\"value\": \"NCS36510\"/' mbed_app.json")
mbed_official 21:6c1e9147037c 123 }
mbed_official 21:6c1e9147037c 124
mbed_official 21:6c1e9147037c 125 if ("${meshInterface}" == "thd") {
mbed_official 21:6c1e9147037c 126 // Change mesh interface to thread
mbed_official 21:6c1e9147037c 127 execute("sed -i 's/\"value\": \"MESH_LOWPAN\"/\"value\": \"MESH_THREAD\"/' mbed_app.json")
mbed_official 21:6c1e9147037c 128
mbed_official 24:671ef092f6ca 129 // Change operation mode to Thread router
mbed_official 21:6c1e9147037c 130 execute("sed -i 's/\"NANOSTACK\", \"LOWPAN_ROUTER\", \"COMMON_PAL\"/\"NANOSTACK\", \"THREAD_ROUTER\", \"COMMON_PAL\"/' mbed_app.json")
mbed_official 24:671ef092f6ca 131
mbed_official 24:671ef092f6ca 132 // Increase HEAP size
mbed_official 49:425a1889434d 133 execute("sed -i 's/\"mbed-mesh-api.heap-size\": 14000/\"mbed-mesh-api.heap-size\": 32000/' mbed_app.json")
mbed_official 24:671ef092f6ca 134
mbed_official 24:671ef092f6ca 135 // Use systest Thread border router for testing (CH=18, PANID=BAAB)
mbed_official 49:425a1889434d 136 execute("sed -i 's/\"mbed-mesh-api.thread-config-channel\": 22/\"mbed-mesh-api.thread-config-channel\": 18/' mbed_app.json")
mbed_official 49:425a1889434d 137 execute("sed -i 's/\"mbed-mesh-api.thread-config-panid\": \"0x0700\"/\"mbed-mesh-api.thread-config-panid\": \"0xBAAB\"/' mbed_app.json")
mbed_official 24:671ef092f6ca 138 // Activate traces
mbed_official 24:671ef092f6ca 139 execute("sed -i 's/\"mbed-trace.enable\": false/\"mbed-trace.enable\": true/' mbed_app.json")
mbed_official 21:6c1e9147037c 140 }
mbed_official 21:6c1e9147037c 141
mbed_official 21:6c1e9147037c 142 if ("${meshInterface}" == "6lp") {
mbed_official 45:6127468411fd 143 // Use systest border router for testing (CH=17, PANID=ABBA)
mbed_official 45:6127468411fd 144 execute("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel\": 12/\"mbed-mesh-api.6lowpan-nd-channel\": 17/' mbed_app.json")
mbed_official 45:6127468411fd 145 execute("sed -i 's/\"mbed-mesh-api.6lowpan-nd-panid-filter\": \"0xffff\"/\"mbed-mesh-api.6lowpan-nd-panid-filter\": \"0xABBA\"/' mbed_app.json")
mbed_official 44:253c7094c7e9 146 // Activate traces
mbed_official 45:6127468411fd 147 execute("sed -i 's/\"mbed-trace.enable\": false/\"mbed-trace.enable\": true/' mbed_app.json")
mbed_official 21:6c1e9147037c 148 }
mbed_official 26:b28ab71ff595 149
mbed_official 26:b28ab71ff595 150 // Set mbed-os to revision received as parameter
mbed_official 21:6c1e9147037c 151 execute ("mbed deploy --protocol ssh")
mbed_official 26:b28ab71ff595 152 dir ("mbed-os") {
mbed_official 26:b28ab71ff595 153 execute ("git checkout ${env.MBED_OS_REVISION}")
mbed_official 21:6c1e9147037c 154 }
mbed_official 26:b28ab71ff595 155
mbed_official 21:6c1e9147037c 156 execute ("mbed compile --build out/${target}_${toolchain}_${radioShield}_${meshInterface}/ -m ${target} -t ${toolchain} -c")
mbed_official 21:6c1e9147037c 157 }
mbed_official 26:b28ab71ff595 158 stash name: "${target}_${toolchain}_${radioShield}_${meshInterface}", includes: '**/mbed-os-example-mesh-minimal.bin'
mbed_official 21:6c1e9147037c 159 archive '**/mbed-os-example-mesh-minimal.bin'
mbed_official 26:b28ab71ff595 160 step([$class: 'WsCleanup'])
mbed_official 21:6c1e9147037c 161 }
mbed_official 21:6c1e9147037c 162 }
mbed_official 21:6c1e9147037c 163 }
mbed_official 21:6c1e9147037c 164 }
mbed_official 26:b28ab71ff595 165
mbed_official 26:b28ab71ff595 166 def run_smoke(targets, toolchains, radioshields, meshinterfaces, raasPort, suite_to_run) {
mbed_official 26:b28ab71ff595 167 return {
mbed_official 26:b28ab71ff595 168 // Remove .json from suite name
mbed_official 26:b28ab71ff595 169 def suiteName = suite_to_run.substring(0, suite_to_run.indexOf('.'))
mbed_official 26:b28ab71ff595 170 stage ("smoke_${raasPort}_${suiteName}") {
mbed_official 30:81d713ba997d 171 node ("mesh-test") {
mbed_official 26:b28ab71ff595 172 deleteDir()
mbed_official 26:b28ab71ff595 173 dir("mbed-clitest") {
mbed_official 26:b28ab71ff595 174 git "git@github.com:ARMmbed/mbed-clitest.git"
mbed_official 26:b28ab71ff595 175 execute("git checkout ${env.LATEST_CLITEST_REL}")
mbed_official 26:b28ab71ff595 176 execute("git submodule update --init --recursive testcases")
mbed_official 26:b28ab71ff595 177
mbed_official 26:b28ab71ff595 178 dir("testcases") {
mbed_official 26:b28ab71ff595 179 execute("git checkout master")
mbed_official 26:b28ab71ff595 180 dir("6lowpan") {
mbed_official 26:b28ab71ff595 181 execute("git checkout master")
mbed_official 26:b28ab71ff595 182 }
mbed_official 26:b28ab71ff595 183 }
mbed_official 26:b28ab71ff595 184
mbed_official 26:b28ab71ff595 185 for (int i = 0; i < targets.size(); i++) {
mbed_official 26:b28ab71ff595 186 for(int j = 0; j < toolchains.size(); j++) {
mbed_official 26:b28ab71ff595 187 for(int k = 0; k < radioshields.size(); k++) {
mbed_official 26:b28ab71ff595 188 for(int l = 0; l < meshinterfaces.size(); l++) {
mbed_official 26:b28ab71ff595 189 def target = targets.keySet().asList().get(i)
mbed_official 26:b28ab71ff595 190 def allowed_shields = targets.get(target)
mbed_official 26:b28ab71ff595 191 def toolchain = toolchains.keySet().asList().get(j)
mbed_official 26:b28ab71ff595 192 def radioshield = radioshields.get(k)
mbed_official 26:b28ab71ff595 193 def meshInterface = meshinterfaces.get(l)
mbed_official 29:cb580ede505b 194 // Skip unwanted combination
mbed_official 29:cb580ede505b 195 if (target == "NUCLEO_F401RE" && toolchain == "IAR") {
mbed_official 29:cb580ede505b 196 continue
mbed_official 29:cb580ede505b 197 }
mbed_official 26:b28ab71ff595 198 if(allowed_shields.contains(radioshield)) {
mbed_official 26:b28ab71ff595 199 unstash "${target}_${toolchain}_${radioshield}_${meshInterface}"
mbed_official 26:b28ab71ff595 200 }
mbed_official 26:b28ab71ff595 201 }
mbed_official 26:b28ab71ff595 202 }
mbed_official 26:b28ab71ff595 203 }
mbed_official 26:b28ab71ff595 204 }
mbed_official 26:b28ab71ff595 205 env.RAAS_USERNAME = "user"
mbed_official 26:b28ab71ff595 206 env.RAAS_PASSWORD = "user"
mbed_official 26:b28ab71ff595 207 execute("python clitest.py --suitedir testcases/suites/ --suite ${suite_to_run} --type hardware --reset --raas 193.208.80.31:${raasPort} --failure_return_value -vvv -w --log log_${raasPort}_${suiteName}")
mbed_official 26:b28ab71ff595 208 archive "log_${raasPort}_${suiteName}/**/*"
mbed_official 26:b28ab71ff595 209 }
mbed_official 26:b28ab71ff595 210 }
mbed_official 26:b28ab71ff595 211 }
mbed_official 26:b28ab71ff595 212 }
mbed_official 26:b28ab71ff595 213 }