Mbed OS Device Connector client pushing environmental sensor data via 6LowPan.
Dependencies: X_NUCLEO_IKS01A2
Fork of mbed-os-example-client-Sensors_6LowPan by
The application is derived from the official mbedOS client example (link) and has been tested using a X-NUCLEO-IDS01A4 SubGHz 6LowPan connectivity board and a X-NUCLEO-IKS01A2 (default) or a X-NUCLEO-IKS01A1 motion and environmental sensors expansion board connected to a ST NUCLEO-F429ZI platform.
The following steps should be performed to make the application work:
- Register and login into ARM mbed Connector.
- Replace the default and empty security.h file with the one associated with your account and provided by the Connector (Security Credentials menu).
- In order to use X-NUCLEO-IKS01A1 instead of default X-NUCLEO-IKS01A2 comment out the IKS01A2 macro definition in main.cpp file.
- Choose NUCLEO-F429ZI as a target either from online compiler or from CLI, compile and flash.
- Setup and connect a NUCLEO-F429ZI + X-NUCLEO-IDS01A4 6LowPan border router as explained here
- Open a serial terminal (params 115200N1) and wait that the client is connected to the mbed Connector via the border router.
- As soon as the client is connected it will start acquiring and pushing the environmental (pressure, temperature and humidity) data to the cloud.
Note: environmental data are expressed using IPSO representation based on OMA LWM2M standard.
Jenkinsfile@0:694e888fd1b5, 2018-01-25 (annotated)
- Committer:
- nikapov
- Date:
- Thu Jan 25 18:00:04 2018 +0100
- Revision:
- 0:694e888fd1b5
First release.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikapov | 0:694e888fd1b5 | 1 | properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [ |
nikapov | 0:694e888fd1b5 | 2 | [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: 'latest', description: 'Revision of mbed-os to build. To access mbed-os PR use format "pull/PR number/head"'] |
nikapov | 0:694e888fd1b5 | 3 | ]]]) |
nikapov | 0:694e888fd1b5 | 4 | |
nikapov | 0:694e888fd1b5 | 5 | try { |
nikapov | 0:694e888fd1b5 | 6 | echo "Verifying build with mbed-os version ${mbed_os_revision}" |
nikapov | 0:694e888fd1b5 | 7 | env.MBED_OS_REVISION = "${mbed_os_revision}" |
nikapov | 0:694e888fd1b5 | 8 | if (mbed_os_revision.matches('pull/\\d+/head')) { |
nikapov | 0:694e888fd1b5 | 9 | echo "Revision is a Pull Request" |
nikapov | 0:694e888fd1b5 | 10 | } |
nikapov | 0:694e888fd1b5 | 11 | } catch (err) { |
nikapov | 0:694e888fd1b5 | 12 | def mbed_os_revision = "latest" |
nikapov | 0:694e888fd1b5 | 13 | echo "Verifying build with mbed-os version ${mbed_os_revision}" |
nikapov | 0:694e888fd1b5 | 14 | env.MBED_OS_REVISION = "${mbed_os_revision}" |
nikapov | 0:694e888fd1b5 | 15 | } |
nikapov | 0:694e888fd1b5 | 16 | |
nikapov | 0:694e888fd1b5 | 17 | // List of targets to compile |
nikapov | 0:694e888fd1b5 | 18 | def targets = [ |
nikapov | 0:694e888fd1b5 | 19 | "K64F", |
nikapov | 0:694e888fd1b5 | 20 | "NUCLEO_F429ZI", |
nikapov | 0:694e888fd1b5 | 21 | "UBLOX_EVK_ODIN_W2" |
nikapov | 0:694e888fd1b5 | 22 | ] |
nikapov | 0:694e888fd1b5 | 23 | |
nikapov | 0:694e888fd1b5 | 24 | // Map toolchains to compilers |
nikapov | 0:694e888fd1b5 | 25 | def toolchains = [ |
nikapov | 0:694e888fd1b5 | 26 | ARM: "armcc", |
nikapov | 0:694e888fd1b5 | 27 | GCC_ARM: "arm-none-eabi-gcc", |
nikapov | 0:694e888fd1b5 | 28 | IAR: "iar_arm" |
nikapov | 0:694e888fd1b5 | 29 | ] |
nikapov | 0:694e888fd1b5 | 30 | |
nikapov | 0:694e888fd1b5 | 31 | def configurations = [ |
nikapov | 0:694e888fd1b5 | 32 | "def": ["ETH"], |
nikapov | 0:694e888fd1b5 | 33 | "thd": ["ATMEL", "MCR20"], |
nikapov | 0:694e888fd1b5 | 34 | "6lp": ["ATMEL", "MCR20"] |
nikapov | 0:694e888fd1b5 | 35 | ] |
nikapov | 0:694e888fd1b5 | 36 | |
nikapov | 0:694e888fd1b5 | 37 | def connectiontypes = [ |
nikapov | 0:694e888fd1b5 | 38 | "ETH", |
nikapov | 0:694e888fd1b5 | 39 | "ATMEL", |
nikapov | 0:694e888fd1b5 | 40 | "MCR20" |
nikapov | 0:694e888fd1b5 | 41 | ] |
nikapov | 0:694e888fd1b5 | 42 | |
nikapov | 0:694e888fd1b5 | 43 | def stepsForParallel = [:] |
nikapov | 0:694e888fd1b5 | 44 | |
nikapov | 0:694e888fd1b5 | 45 | // Jenkins pipeline does not support map.each, we need to use oldschool for loop |
nikapov | 0:694e888fd1b5 | 46 | for (int i = 0; i < targets.size(); i++) { |
nikapov | 0:694e888fd1b5 | 47 | for(int j = 0; j < toolchains.size(); j++) { |
nikapov | 0:694e888fd1b5 | 48 | for(int k = 0; k < configurations.size(); k++) { |
nikapov | 0:694e888fd1b5 | 49 | for(int l = 0; l < connectiontypes.size(); l++) { |
nikapov | 0:694e888fd1b5 | 50 | |
nikapov | 0:694e888fd1b5 | 51 | def target = targets.get(i) |
nikapov | 0:694e888fd1b5 | 52 | def toolchain = toolchains.keySet().asList().get(j) |
nikapov | 0:694e888fd1b5 | 53 | def compilerLabel = toolchains.get(toolchain) |
nikapov | 0:694e888fd1b5 | 54 | def config = configurations.keySet().asList().get(k) |
nikapov | 0:694e888fd1b5 | 55 | def allowed_configs = configurations.get(config) |
nikapov | 0:694e888fd1b5 | 56 | def connectiontype = connectiontypes.get(l) |
nikapov | 0:694e888fd1b5 | 57 | |
nikapov | 0:694e888fd1b5 | 58 | def stepName = "${target} ${toolchain} ${config} ${connectiontype}" |
nikapov | 0:694e888fd1b5 | 59 | if(allowed_configs.contains(connectiontype)) { |
nikapov | 0:694e888fd1b5 | 60 | stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, config, connectiontype) |
nikapov | 0:694e888fd1b5 | 61 | } |
nikapov | 0:694e888fd1b5 | 62 | } |
nikapov | 0:694e888fd1b5 | 63 | } |
nikapov | 0:694e888fd1b5 | 64 | } |
nikapov | 0:694e888fd1b5 | 65 | } |
nikapov | 0:694e888fd1b5 | 66 | |
nikapov | 0:694e888fd1b5 | 67 | timestamps { |
nikapov | 0:694e888fd1b5 | 68 | parallel stepsForParallel |
nikapov | 0:694e888fd1b5 | 69 | } |
nikapov | 0:694e888fd1b5 | 70 | |
nikapov | 0:694e888fd1b5 | 71 | def buildStep(target, compilerLabel, toolchain, configName, connectiontype) { |
nikapov | 0:694e888fd1b5 | 72 | return { |
nikapov | 0:694e888fd1b5 | 73 | stage ("${target}_${compilerLabel}_${configName}_${connectiontype}") { |
nikapov | 0:694e888fd1b5 | 74 | node ("${compilerLabel}") { |
nikapov | 0:694e888fd1b5 | 75 | deleteDir() |
nikapov | 0:694e888fd1b5 | 76 | dir("mbed-os-example-client") { |
nikapov | 0:694e888fd1b5 | 77 | checkout scm |
nikapov | 0:694e888fd1b5 | 78 | def config_file = "mbed_app.json" |
nikapov | 0:694e888fd1b5 | 79 | |
nikapov | 0:694e888fd1b5 | 80 | if ("${configName}" == "thd") { |
nikapov | 0:694e888fd1b5 | 81 | config_file = "./configs/mesh_thread.json" |
nikapov | 0:694e888fd1b5 | 82 | // Update Thread channel and PANID |
nikapov | 0:694e888fd1b5 | 83 | execute("sed -i 's/\"mbed-mesh-api.thread-config-channel\": 22/\"mbed-mesh-api.thread-config-channel\": 18/' ${config_file}") |
nikapov | 0:694e888fd1b5 | 84 | execute("sed -i 's/\"mbed-mesh-api.thread-config-panid\": \"0x0700\"/\"mbed-mesh-api.thread-config-panid\": \"0xBAAB\"/' ${config_file}") |
nikapov | 0:694e888fd1b5 | 85 | |
nikapov | 0:694e888fd1b5 | 86 | } |
nikapov | 0:694e888fd1b5 | 87 | |
nikapov | 0:694e888fd1b5 | 88 | if ("${configName}" == "6lp") { |
nikapov | 0:694e888fd1b5 | 89 | config_file = "./configs/mesh_6lowpan.json" |
nikapov | 0:694e888fd1b5 | 90 | |
nikapov | 0:694e888fd1b5 | 91 | // Change channel for HW tests |
nikapov | 0:694e888fd1b5 | 92 | execute ("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel\": 12/\"mbed-mesh-api.6lowpan-nd-channel\": 17/' ${config_file}") |
nikapov | 0:694e888fd1b5 | 93 | |
nikapov | 0:694e888fd1b5 | 94 | //Use PANID filter |
nikapov | 0:694e888fd1b5 | 95 | execute ("sed -i '/6lowpan-nd-channel\":/a \"mbed-mesh-api.6lowpan-nd-panid-filter\": \"0xABBA\",' ${config_file}") |
nikapov | 0:694e888fd1b5 | 96 | } |
nikapov | 0:694e888fd1b5 | 97 | |
nikapov | 0:694e888fd1b5 | 98 | if ("${connectiontype}" == "MCR20") { |
nikapov | 0:694e888fd1b5 | 99 | // Replace default rf shield |
nikapov | 0:694e888fd1b5 | 100 | execute ("sed -i 's/\"value\": \"ATMEL\"/\"value\": \"MCR20\"/' ${config_file}") |
nikapov | 0:694e888fd1b5 | 101 | } |
nikapov | 0:694e888fd1b5 | 102 | |
nikapov | 0:694e888fd1b5 | 103 | // Copy security.h to build |
nikapov | 0:694e888fd1b5 | 104 | mbed.getSecurityFile() |
nikapov | 0:694e888fd1b5 | 105 | |
nikapov | 0:694e888fd1b5 | 106 | // Set mbed-os to revision received as parameter |
nikapov | 0:694e888fd1b5 | 107 | execute ("mbed deploy --protocol ssh") |
nikapov | 0:694e888fd1b5 | 108 | dir("mbed-os") { |
nikapov | 0:694e888fd1b5 | 109 | if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) { |
nikapov | 0:694e888fd1b5 | 110 | // Use mbed-os PR and switch to branch created |
nikapov | 0:694e888fd1b5 | 111 | execute("git fetch origin ${env.MBED_OS_REVISION}:_PR_") |
nikapov | 0:694e888fd1b5 | 112 | execute("git checkout _PR_") |
nikapov | 0:694e888fd1b5 | 113 | } else { |
nikapov | 0:694e888fd1b5 | 114 | execute ("git checkout ${env.MBED_OS_REVISION}") |
nikapov | 0:694e888fd1b5 | 115 | } |
nikapov | 0:694e888fd1b5 | 116 | } |
nikapov | 0:694e888fd1b5 | 117 | execute ("mbed compile --build out/${target}_${toolchain}_${configName}_${connectiontype}/ -m ${target} -t ${toolchain} -c --app-config ${config_file}") |
nikapov | 0:694e888fd1b5 | 118 | } |
nikapov | 0:694e888fd1b5 | 119 | archive '**/mbed-os-example-client.bin' |
nikapov | 0:694e888fd1b5 | 120 | step([$class: 'WsCleanup']) |
nikapov | 0:694e888fd1b5 | 121 | } |
nikapov | 0:694e888fd1b5 | 122 | } |
nikapov | 0:694e888fd1b5 | 123 | } |
nikapov | 0:694e888fd1b5 | 124 | } |