This is a simple mbed client example demonstrating, registration of a device with mbed Device Connector and reading and writing values as well as deregistering on different Network Interfaces including Ethernet, WiFi, 6LoWPAN ND and Thread respectively.
Fork of mbed-os-example-client by
Jenkinsfile@110:bed4b048cfd9, 2017-10-20 (annotated)
- Committer:
- davyu
- Date:
- Fri Oct 20 22:52:08 2017 +0000
- Revision:
- 110:bed4b048cfd9
- Parent:
- 101:1999b1beb68d
initial client example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 36:bfb6816a677c | 1 | properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [ |
mbed_official | 101:1999b1beb68d | 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"'] |
mbed_official | 36:bfb6816a677c | 3 | ]]]) |
mbed_official | 36:bfb6816a677c | 4 | |
mbed_official | 36:bfb6816a677c | 5 | try { |
mbed_official | 36:bfb6816a677c | 6 | echo "Verifying build with mbed-os version ${mbed_os_revision}" |
mbed_official | 36:bfb6816a677c | 7 | env.MBED_OS_REVISION = "${mbed_os_revision}" |
mbed_official | 101:1999b1beb68d | 8 | if (mbed_os_revision.matches('pull/\\d+/head')) { |
mbed_official | 101:1999b1beb68d | 9 | echo "Revision is a Pull Request" |
mbed_official | 101:1999b1beb68d | 10 | } |
mbed_official | 36:bfb6816a677c | 11 | } catch (err) { |
mbed_official | 36:bfb6816a677c | 12 | def mbed_os_revision = "latest" |
mbed_official | 36:bfb6816a677c | 13 | echo "Verifying build with mbed-os version ${mbed_os_revision}" |
mbed_official | 36:bfb6816a677c | 14 | env.MBED_OS_REVISION = "${mbed_os_revision}" |
mbed_official | 36:bfb6816a677c | 15 | } |
mbed_official | 36:bfb6816a677c | 16 | |
mbed_official | 18:628e22df9c41 | 17 | // List of targets to compile |
mbed_official | 18:628e22df9c41 | 18 | def targets = [ |
mbed_official | 27:3d32587bf8f7 | 19 | "K64F", |
mbed_official | 27:3d32587bf8f7 | 20 | "NUCLEO_F429ZI", |
mbed_official | 27:3d32587bf8f7 | 21 | "UBLOX_EVK_ODIN_W2" |
mbed_official | 18:628e22df9c41 | 22 | ] |
mbed_official | 66:8079b3572c2e | 23 | |
mbed_official | 18:628e22df9c41 | 24 | // Map toolchains to compilers |
mbed_official | 18:628e22df9c41 | 25 | def toolchains = [ |
mbed_official | 18:628e22df9c41 | 26 | ARM: "armcc", |
mbed_official | 18:628e22df9c41 | 27 | GCC_ARM: "arm-none-eabi-gcc", |
mbed_official | 18:628e22df9c41 | 28 | IAR: "iar_arm" |
mbed_official | 18:628e22df9c41 | 29 | ] |
mbed_official | 18:628e22df9c41 | 30 | |
mbed_official | 18:628e22df9c41 | 31 | def configurations = [ |
mbed_official | 27:3d32587bf8f7 | 32 | "def": ["ETH"], |
mbed_official | 27:3d32587bf8f7 | 33 | "thd": ["ATMEL", "MCR20"], |
mbed_official | 27:3d32587bf8f7 | 34 | "6lp": ["ATMEL", "MCR20"] |
mbed_official | 18:628e22df9c41 | 35 | ] |
mbed_official | 27:3d32587bf8f7 | 36 | |
mbed_official | 27:3d32587bf8f7 | 37 | def connectiontypes = [ |
mbed_official | 27:3d32587bf8f7 | 38 | "ETH", |
mbed_official | 27:3d32587bf8f7 | 39 | "ATMEL", |
mbed_official | 27:3d32587bf8f7 | 40 | "MCR20" |
mbed_official | 27:3d32587bf8f7 | 41 | ] |
mbed_official | 27:3d32587bf8f7 | 42 | |
mbed_official | 18:628e22df9c41 | 43 | def stepsForParallel = [:] |
mbed_official | 18:628e22df9c41 | 44 | |
mbed_official | 18:628e22df9c41 | 45 | // Jenkins pipeline does not support map.each, we need to use oldschool for loop |
mbed_official | 18:628e22df9c41 | 46 | for (int i = 0; i < targets.size(); i++) { |
mbed_official | 18:628e22df9c41 | 47 | for(int j = 0; j < toolchains.size(); j++) { |
mbed_official | 18:628e22df9c41 | 48 | for(int k = 0; k < configurations.size(); k++) { |
mbed_official | 27:3d32587bf8f7 | 49 | for(int l = 0; l < connectiontypes.size(); l++) { |
mbed_official | 27:3d32587bf8f7 | 50 | |
mbed_official | 27:3d32587bf8f7 | 51 | def target = targets.get(i) |
mbed_official | 27:3d32587bf8f7 | 52 | def toolchain = toolchains.keySet().asList().get(j) |
mbed_official | 27:3d32587bf8f7 | 53 | def compilerLabel = toolchains.get(toolchain) |
mbed_official | 27:3d32587bf8f7 | 54 | def config = configurations.keySet().asList().get(k) |
mbed_official | 27:3d32587bf8f7 | 55 | def allowed_configs = configurations.get(config) |
mbed_official | 27:3d32587bf8f7 | 56 | def connectiontype = connectiontypes.get(l) |
mbed_official | 27:3d32587bf8f7 | 57 | |
mbed_official | 27:3d32587bf8f7 | 58 | def stepName = "${target} ${toolchain} ${config} ${connectiontype}" |
mbed_official | 27:3d32587bf8f7 | 59 | if(allowed_configs.contains(connectiontype)) { |
mbed_official | 27:3d32587bf8f7 | 60 | stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, config, connectiontype) |
mbed_official | 27:3d32587bf8f7 | 61 | } |
mbed_official | 27:3d32587bf8f7 | 62 | } |
mbed_official | 18:628e22df9c41 | 63 | } |
mbed_official | 18:628e22df9c41 | 64 | } |
mbed_official | 18:628e22df9c41 | 65 | } |
mbed_official | 18:628e22df9c41 | 66 | |
mbed_official | 18:628e22df9c41 | 67 | timestamps { |
mbed_official | 18:628e22df9c41 | 68 | parallel stepsForParallel |
mbed_official | 18:628e22df9c41 | 69 | } |
mbed_official | 18:628e22df9c41 | 70 | |
mbed_official | 27:3d32587bf8f7 | 71 | def buildStep(target, compilerLabel, toolchain, configName, connectiontype) { |
mbed_official | 18:628e22df9c41 | 72 | return { |
mbed_official | 27:3d32587bf8f7 | 73 | stage ("${target}_${compilerLabel}_${configName}_${connectiontype}") { |
mbed_official | 18:628e22df9c41 | 74 | node ("${compilerLabel}") { |
mbed_official | 18:628e22df9c41 | 75 | deleteDir() |
mbed_official | 18:628e22df9c41 | 76 | dir("mbed-os-example-client") { |
mbed_official | 18:628e22df9c41 | 77 | checkout scm |
mbed_official | 101:1999b1beb68d | 78 | def config_file = "mbed_app.json" |
mbed_official | 66:8079b3572c2e | 79 | |
mbed_official | 27:3d32587bf8f7 | 80 | if ("${configName}" == "thd") { |
mbed_official | 101:1999b1beb68d | 81 | config_file = "./configs/mesh_thread.json" |
mbed_official | 101:1999b1beb68d | 82 | // Update Thread channel and PANID |
mbed_official | 101:1999b1beb68d | 83 | execute("sed -i 's/\"mbed-mesh-api.thread-config-channel\": 22/\"mbed-mesh-api.thread-config-channel\": 18/' ${config_file}") |
mbed_official | 101:1999b1beb68d | 84 | execute("sed -i 's/\"mbed-mesh-api.thread-config-panid\": \"0x0700\"/\"mbed-mesh-api.thread-config-panid\": \"0xBAAB\"/' ${config_file}") |
mbed_official | 101:1999b1beb68d | 85 | |
mbed_official | 18:628e22df9c41 | 86 | } |
mbed_official | 27:3d32587bf8f7 | 87 | |
mbed_official | 27:3d32587bf8f7 | 88 | if ("${configName}" == "6lp") { |
mbed_official | 101:1999b1beb68d | 89 | config_file = "./configs/mesh_6lowpan.json" |
mbed_official | 27:3d32587bf8f7 | 90 | |
mbed_official | 27:3d32587bf8f7 | 91 | // Change channel for HW tests |
mbed_official | 101:1999b1beb68d | 92 | execute ("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel\": 12/\"mbed-mesh-api.6lowpan-nd-channel\": 17/' ${config_file}") |
mbed_official | 66:8079b3572c2e | 93 | |
mbed_official | 66:8079b3572c2e | 94 | //Use PANID filter |
mbed_official | 101:1999b1beb68d | 95 | execute ("sed -i '/6lowpan-nd-channel\":/a \"mbed-mesh-api.6lowpan-nd-panid-filter\": \"0xABBA\",' ${config_file}") |
mbed_official | 27:3d32587bf8f7 | 96 | } |
mbed_official | 27:3d32587bf8f7 | 97 | |
mbed_official | 27:3d32587bf8f7 | 98 | if ("${connectiontype}" == "MCR20") { |
mbed_official | 27:3d32587bf8f7 | 99 | // Replace default rf shield |
mbed_official | 101:1999b1beb68d | 100 | execute ("sed -i 's/\"value\": \"ATMEL\"/\"value\": \"MCR20\"/' ${config_file}") |
mbed_official | 27:3d32587bf8f7 | 101 | } |
mbed_official | 27:3d32587bf8f7 | 102 | |
mbed_official | 18:628e22df9c41 | 103 | // Copy security.h to build |
mbed_official | 18:628e22df9c41 | 104 | mbed.getSecurityFile() |
mbed_official | 36:bfb6816a677c | 105 | |
mbed_official | 36:bfb6816a677c | 106 | // Set mbed-os to revision received as parameter |
mbed_official | 18:628e22df9c41 | 107 | execute ("mbed deploy --protocol ssh") |
mbed_official | 27:3d32587bf8f7 | 108 | dir("mbed-os") { |
mbed_official | 101:1999b1beb68d | 109 | if (env.MBED_OS_REVISION.matches('pull/\\d+/head')) { |
mbed_official | 101:1999b1beb68d | 110 | // Use mbed-os PR and switch to branch created |
mbed_official | 101:1999b1beb68d | 111 | execute("git fetch origin ${env.MBED_OS_REVISION}:_PR_") |
mbed_official | 101:1999b1beb68d | 112 | execute("git checkout _PR_") |
mbed_official | 101:1999b1beb68d | 113 | } else { |
mbed_official | 101:1999b1beb68d | 114 | execute ("git checkout ${env.MBED_OS_REVISION}") |
mbed_official | 101:1999b1beb68d | 115 | } |
mbed_official | 27:3d32587bf8f7 | 116 | } |
mbed_official | 101:1999b1beb68d | 117 | execute ("mbed compile --build out/${target}_${toolchain}_${configName}_${connectiontype}/ -m ${target} -t ${toolchain} -c --app-config ${config_file}") |
mbed_official | 18:628e22df9c41 | 118 | } |
mbed_official | 27:3d32587bf8f7 | 119 | archive '**/mbed-os-example-client.bin' |
mbed_official | 36:bfb6816a677c | 120 | step([$class: 'WsCleanup']) |
mbed_official | 18:628e22df9c41 | 121 | } |
mbed_official | 18:628e22df9c41 | 122 | } |
mbed_official | 18:628e22df9c41 | 123 | } |
mbed_official | 18:628e22df9c41 | 124 | } |