mbedOS client example, modified to push X-Nucleo-IKS01A1/2 Environmental Sensor data to mbed Cloud Connector.
Dependencies: X_NUCLEO_IKS01A1 X_NUCLEO_IKS01A2
The application is derived from the official mbedOS client example (link) and has been tested using 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-IKS02A1 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.
- Connect the board to your ethernet network, open a serial terminal (params 115200N1) and wait that the client is connected to the mbed Connector.
- Press user button to start acquiring and pushing the environmental (pressure, temperature and humidity) data.
Note: environmental data are expressed using IPSO representation based on OMA LWM2M standard.
Jenkinsfile@0:003e60a0deb8, 2017-04-26 (annotated)
- Committer:
- nikapov
- Date:
- Wed Apr 26 18:23:56 2017 +0200
- Revision:
- 0:003e60a0deb8
First version.
Original repository: https://github.com/ARMmbed/mbed-os-example-client
Version hash: 629b972f41109fd1b54bb755ea454d736a50069b
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikapov | 0:003e60a0deb8 | 1 | properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [ |
nikapov | 0:003e60a0deb8 | 2 | [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: 'latest', description: 'Revision of mbed-os to build'] |
nikapov | 0:003e60a0deb8 | 3 | ]]]) |
nikapov | 0:003e60a0deb8 | 4 | |
nikapov | 0:003e60a0deb8 | 5 | try { |
nikapov | 0:003e60a0deb8 | 6 | echo "Verifying build with mbed-os version ${mbed_os_revision}" |
nikapov | 0:003e60a0deb8 | 7 | env.MBED_OS_REVISION = "${mbed_os_revision}" |
nikapov | 0:003e60a0deb8 | 8 | } catch (err) { |
nikapov | 0:003e60a0deb8 | 9 | def mbed_os_revision = "latest" |
nikapov | 0:003e60a0deb8 | 10 | echo "Verifying build with mbed-os version ${mbed_os_revision}" |
nikapov | 0:003e60a0deb8 | 11 | env.MBED_OS_REVISION = "${mbed_os_revision}" |
nikapov | 0:003e60a0deb8 | 12 | } |
nikapov | 0:003e60a0deb8 | 13 | |
nikapov | 0:003e60a0deb8 | 14 | // List of targets to compile |
nikapov | 0:003e60a0deb8 | 15 | def targets = [ |
nikapov | 0:003e60a0deb8 | 16 | "K64F", |
nikapov | 0:003e60a0deb8 | 17 | "NUCLEO_F429ZI", |
nikapov | 0:003e60a0deb8 | 18 | "UBLOX_EVK_ODIN_W2" |
nikapov | 0:003e60a0deb8 | 19 | ] |
nikapov | 0:003e60a0deb8 | 20 | |
nikapov | 0:003e60a0deb8 | 21 | // Map toolchains to compilers |
nikapov | 0:003e60a0deb8 | 22 | def toolchains = [ |
nikapov | 0:003e60a0deb8 | 23 | ARM: "armcc", |
nikapov | 0:003e60a0deb8 | 24 | GCC_ARM: "arm-none-eabi-gcc", |
nikapov | 0:003e60a0deb8 | 25 | IAR: "iar_arm" |
nikapov | 0:003e60a0deb8 | 26 | ] |
nikapov | 0:003e60a0deb8 | 27 | |
nikapov | 0:003e60a0deb8 | 28 | def configurations = [ |
nikapov | 0:003e60a0deb8 | 29 | "def": ["ETH"], |
nikapov | 0:003e60a0deb8 | 30 | "thd": ["ATMEL", "MCR20"], |
nikapov | 0:003e60a0deb8 | 31 | "6lp": ["ATMEL", "MCR20"] |
nikapov | 0:003e60a0deb8 | 32 | ] |
nikapov | 0:003e60a0deb8 | 33 | |
nikapov | 0:003e60a0deb8 | 34 | def connectiontypes = [ |
nikapov | 0:003e60a0deb8 | 35 | "ETH", |
nikapov | 0:003e60a0deb8 | 36 | "ATMEL", |
nikapov | 0:003e60a0deb8 | 37 | "MCR20" |
nikapov | 0:003e60a0deb8 | 38 | ] |
nikapov | 0:003e60a0deb8 | 39 | |
nikapov | 0:003e60a0deb8 | 40 | def stepsForParallel = [:] |
nikapov | 0:003e60a0deb8 | 41 | |
nikapov | 0:003e60a0deb8 | 42 | // Jenkins pipeline does not support map.each, we need to use oldschool for loop |
nikapov | 0:003e60a0deb8 | 43 | for (int i = 0; i < targets.size(); i++) { |
nikapov | 0:003e60a0deb8 | 44 | for(int j = 0; j < toolchains.size(); j++) { |
nikapov | 0:003e60a0deb8 | 45 | for(int k = 0; k < configurations.size(); k++) { |
nikapov | 0:003e60a0deb8 | 46 | for(int l = 0; l < connectiontypes.size(); l++) { |
nikapov | 0:003e60a0deb8 | 47 | |
nikapov | 0:003e60a0deb8 | 48 | def target = targets.get(i) |
nikapov | 0:003e60a0deb8 | 49 | def toolchain = toolchains.keySet().asList().get(j) |
nikapov | 0:003e60a0deb8 | 50 | def compilerLabel = toolchains.get(toolchain) |
nikapov | 0:003e60a0deb8 | 51 | def config = configurations.keySet().asList().get(k) |
nikapov | 0:003e60a0deb8 | 52 | def allowed_configs = configurations.get(config) |
nikapov | 0:003e60a0deb8 | 53 | def connectiontype = connectiontypes.get(l) |
nikapov | 0:003e60a0deb8 | 54 | |
nikapov | 0:003e60a0deb8 | 55 | def stepName = "${target} ${toolchain} ${config} ${connectiontype}" |
nikapov | 0:003e60a0deb8 | 56 | if(allowed_configs.contains(connectiontype)) { |
nikapov | 0:003e60a0deb8 | 57 | stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, config, connectiontype) |
nikapov | 0:003e60a0deb8 | 58 | } |
nikapov | 0:003e60a0deb8 | 59 | } |
nikapov | 0:003e60a0deb8 | 60 | } |
nikapov | 0:003e60a0deb8 | 61 | } |
nikapov | 0:003e60a0deb8 | 62 | } |
nikapov | 0:003e60a0deb8 | 63 | |
nikapov | 0:003e60a0deb8 | 64 | timestamps { |
nikapov | 0:003e60a0deb8 | 65 | parallel stepsForParallel |
nikapov | 0:003e60a0deb8 | 66 | } |
nikapov | 0:003e60a0deb8 | 67 | |
nikapov | 0:003e60a0deb8 | 68 | def buildStep(target, compilerLabel, toolchain, configName, connectiontype) { |
nikapov | 0:003e60a0deb8 | 69 | return { |
nikapov | 0:003e60a0deb8 | 70 | stage ("${target}_${compilerLabel}_${configName}_${connectiontype}") { |
nikapov | 0:003e60a0deb8 | 71 | node ("${compilerLabel}") { |
nikapov | 0:003e60a0deb8 | 72 | deleteDir() |
nikapov | 0:003e60a0deb8 | 73 | dir("mbed-os-example-client") { |
nikapov | 0:003e60a0deb8 | 74 | checkout scm |
nikapov | 0:003e60a0deb8 | 75 | |
nikapov | 0:003e60a0deb8 | 76 | if ("${configName}" == "thd") { |
nikapov | 0:003e60a0deb8 | 77 | // Change device type to Thread router |
nikapov | 0:003e60a0deb8 | 78 | execute("sed -i 's/\"NANOSTACK\", \"LOWPAN_ROUTER\", \"COMMON_PAL\"/\"NANOSTACK\", \"THREAD_ROUTER\", \"COMMON_PAL\"/' mbed_app.json") |
nikapov | 0:003e60a0deb8 | 79 | // Change connection type to thread |
nikapov | 0:003e60a0deb8 | 80 | execute ("sed -i 's/\"value\": \"ETHERNET\"/\"value\": \"MESH_THREAD\"/' mbed_app.json") |
nikapov | 0:003e60a0deb8 | 81 | // Reuse 6lowpan channel to Thread channel |
nikapov | 0:003e60a0deb8 | 82 | execute("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel\": 12/\"mbed-mesh-api.thread-config-channel\": 18/' mbed_app.json") |
nikapov | 0:003e60a0deb8 | 83 | // Reuse 6lowpan channel page to Thread PANID |
nikapov | 0:003e60a0deb8 | 84 | execute("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel-page\": 0/\"mbed-mesh-api.thread-config-panid\": \"0xBAAB\"/' mbed_app.json") |
nikapov | 0:003e60a0deb8 | 85 | } |
nikapov | 0:003e60a0deb8 | 86 | |
nikapov | 0:003e60a0deb8 | 87 | if ("${configName}" == "6lp") { |
nikapov | 0:003e60a0deb8 | 88 | // Change connection type to 6LoWPAN |
nikapov | 0:003e60a0deb8 | 89 | execute ("sed -i 's/\"value\": \"ETHERNET\"/\"value\": \"MESH_LOWPAN_ND\"/' mbed_app.json") |
nikapov | 0:003e60a0deb8 | 90 | |
nikapov | 0:003e60a0deb8 | 91 | // Change channel for HW tests |
nikapov | 0:003e60a0deb8 | 92 | execute ("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel\": 12/\"mbed-mesh-api.6lowpan-nd-channel\": 17/' mbed_app.json") |
nikapov | 0:003e60a0deb8 | 93 | |
nikapov | 0:003e60a0deb8 | 94 | //Use PANID filter |
nikapov | 0:003e60a0deb8 | 95 | execute ("sed -i '/6lowpan-nd-channel\":/a \"mbed-mesh-api.6lowpan-nd-panid-filter\": \"0xABBA\",' mbed_app.json") |
nikapov | 0:003e60a0deb8 | 96 | } |
nikapov | 0:003e60a0deb8 | 97 | |
nikapov | 0:003e60a0deb8 | 98 | if ("${connectiontype}" == "MCR20") { |
nikapov | 0:003e60a0deb8 | 99 | // Replace default rf shield |
nikapov | 0:003e60a0deb8 | 100 | execute ("sed -i 's/\"value\": \"ATMEL\"/\"value\": \"MCR20\"/' mbed_app.json") |
nikapov | 0:003e60a0deb8 | 101 | } |
nikapov | 0:003e60a0deb8 | 102 | |
nikapov | 0:003e60a0deb8 | 103 | // Copy security.h to build |
nikapov | 0:003e60a0deb8 | 104 | mbed.getSecurityFile() |
nikapov | 0:003e60a0deb8 | 105 | |
nikapov | 0:003e60a0deb8 | 106 | // Set mbed-os to revision received as parameter |
nikapov | 0:003e60a0deb8 | 107 | execute ("mbed deploy --protocol ssh") |
nikapov | 0:003e60a0deb8 | 108 | dir("mbed-os") { |
nikapov | 0:003e60a0deb8 | 109 | execute ("git checkout ${env.MBED_OS_REVISION}") |
nikapov | 0:003e60a0deb8 | 110 | } |
nikapov | 0:003e60a0deb8 | 111 | execute ("mbed compile --build out/${target}_${toolchain}_${configName}_${connectiontype}/ -m ${target} -t ${toolchain} -c") |
nikapov | 0:003e60a0deb8 | 112 | } |
nikapov | 0:003e60a0deb8 | 113 | archive '**/mbed-os-example-client.bin' |
nikapov | 0:003e60a0deb8 | 114 | step([$class: 'WsCleanup']) |
nikapov | 0:003e60a0deb8 | 115 | } |
nikapov | 0:003e60a0deb8 | 116 | } |
nikapov | 0:003e60a0deb8 | 117 | } |
nikapov | 0:003e60a0deb8 | 118 | } |