WiFi example for mbed OS, fork from https://github.com/ARMmbed/mbed-os-example-wifi
This is an example of a Wi-Fi application using the Wi-Fi and network socket APIs that Mbed OS provides.
The program brings up the Wi-Fi and the underlying network interface and uses it to scan available networks, connects to a network, prints interface and connection details and performs an HTTP operation.
For more information about Wi-Fi APIs, please visit the Mbed OS Wi-Fi documentation.
This example has been used on the following platforms
Jenkinsfile@0:0593b97dec0b, 2018-02-22 (annotated)
- Committer:
- group-Renesas-Electronics-Corp
- Date:
- Thu Feb 22 05:44:51 2018 +0000
- Revision:
- 0:0593b97dec0b
- Child:
- 6:09f1e7ff743c
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 1 | properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [ |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 2 | [$class: 'StringParameterDefinition', name: 'mbed_os_revision', defaultValue: '', description: 'Revision of mbed-os to build. Use format "pull/PR-NUMBER/head" to access mbed-os PR'] |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 3 | ]]]) |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 4 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 5 | if (params.mbed_os_revision == '') { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 6 | echo 'Use mbed OS revision from mbed-os.lib' |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 7 | } else { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 8 | echo "Use mbed OS revisiong ${params.mbed_os_revision}" |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 9 | if (params.mbed_os_revision.matches('pull/\\d+/head')) { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 10 | echo "Revision is a Pull Request" |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 11 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 12 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 13 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 14 | // List of targets with supported RF shields to compile |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 15 | def targets = [ |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 16 | "UBLOX_EVK_ODIN_W2": ["builtin"], |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 17 | "REALTEK_RTL8195AM": ["builtin"], |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 18 | "K64F": ["WIFI_ESP8266"], |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 19 | "NUCLEO_F401RE": ["WIFI_IDW0XX1"], |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 20 | "NUCLEO_F429ZI": ["WIFI_ESP8266"] |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 21 | ] |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 22 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 23 | // Map toolchains to compilers |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 24 | def toolchains = [ |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 25 | ARM: "armcc", |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 26 | GCC_ARM: "arm-none-eabi-gcc", |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 27 | IAR: "IAR-linux" |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 28 | ] |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 29 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 30 | // Supported RF shields |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 31 | def radioshields = [ |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 32 | "builtin", |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 33 | "WIFI_IDW0XX1", |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 34 | "WIFI_ESP8266" |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 35 | ] |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 36 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 37 | def stepsForParallel = [:] |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 38 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 39 | // Jenkins pipeline does not support map.each, we need to use oldschool for loop |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 40 | for (int i = 0; i < targets.size(); i++) { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 41 | for(int j = 0; j < toolchains.size(); j++) { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 42 | for(int k = 0; k < radioshields.size(); k++) { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 43 | def target = targets.keySet().asList().get(i) |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 44 | def allowed_shields = targets.get(target) |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 45 | def toolchain = toolchains.keySet().asList().get(j) |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 46 | def compilerLabel = toolchains.get(toolchain) |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 47 | def radioshield = radioshields.get(k) |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 48 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 49 | def stepName = "${target} ${toolchain} ${radioshield}" |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 50 | if(allowed_shields.contains(radioshield)) { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 51 | stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, radioshield) |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 52 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 53 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 54 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 55 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 56 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 57 | timestamps { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 58 | parallel stepsForParallel |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 59 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 60 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 61 | def buildStep(target, compilerLabel, toolchain, radioShield) { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 62 | return { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 63 | stage ("${target}_${compilerLabel}_${radioShield}") { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 64 | node ("${compilerLabel}") { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 65 | deleteDir() |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 66 | dir("mbed-os-example-wifi") { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 67 | checkout scm |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 68 | def config_file = "mbed_app.json" |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 69 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 70 | if ("${radioShield}" != "internal") { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 71 | // Replace default rf shield |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 72 | execute("sed -i 's/\"value\": \"internal\"/\"value\": \"${radioShield}\"/' ${config_file}") |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 73 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 74 | |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 75 | // Set mbed-os to revision received as parameter |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 76 | execute ("mbed deploy --protocol ssh") |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 77 | if (params.mbed_os_revision != '') { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 78 | dir ("mbed-os") { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 79 | if (params.mbed_os_revision.matches('pull/\\d+/head')) { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 80 | execute("git fetch origin ${params.mbed_os_revision}:PR") |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 81 | execute("git checkout PR") |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 82 | } else { |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 83 | execute ("git checkout ${params.mbed_os_revision}") |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 84 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 85 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 86 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 87 | execute("mbed new .") |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 88 | execute ("mbed compile --build out/${target}_${toolchain}_${radioShield}/ -m ${target} -t ${toolchain} -c --app-config ${config_file}") |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 89 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 90 | stash name: "${target}_${toolchain}_${radioShield}", includes: '**/mbed-os-example-wifi.bin' |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 91 | archive '**/mbed-os-example-wifi.bin' |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 92 | step([$class: 'WsCleanup']) |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 93 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 94 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 95 | } |
group-Renesas-Electronics-Corp | 0:0593b97dec0b | 96 | } |