Simple mbed OS sockets example for mbed OS5 & W5500 SPI Ethernet controller. This is a quick example of a simple HTTP client program using the network-socket API that is provided as a part of mbed-os. The program brings up an underlying network interface, and uses it to perform an HTTP transaction over a TCPSocket.

Dependencies:   W5500Interface easy-connect

Fork of mbed-os-example-mbed5-sockets by mbed-os-examples

Result

  • Serial Terminal Log

/media/uploads/Bongjun/img021.png

Committer:
mbed_official
Date:
Mon Jun 18 09:15:03 2018 +0100
Revision:
48:f2739ac5cb01
Merge remote-tracking branch 'origin/mbed-os-5.9.0-oob'

* origin/mbed-os-5.9.0-oob:
Print Mbed OS version
Updating mbed-os to mbed-os-5.9.0-rc3
Updating mbed-os to mbed-os-5.9.0-rc2
Use Ethernet by default on all platforms.
Add Jenkinsfile
Use Ethernet by default on ODIN_W2
Updating mbed-os to mbed-os-5.9.0-rc1

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 48:f2739ac5cb01 1 properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
mbed_official 48:f2739ac5cb01 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']
mbed_official 48:f2739ac5cb01 3 ]]])
mbed_official 48:f2739ac5cb01 4
mbed_official 48:f2739ac5cb01 5 if (params.mbed_os_revision == '') {
mbed_official 48:f2739ac5cb01 6 echo 'Use mbed OS revision from mbed-os.lib'
mbed_official 48:f2739ac5cb01 7 } else {
mbed_official 48:f2739ac5cb01 8 echo "Use mbed OS revisiong ${params.mbed_os_revision}"
mbed_official 48:f2739ac5cb01 9 if (params.mbed_os_revision.matches('pull/\\d+/head')) {
mbed_official 48:f2739ac5cb01 10 echo "Revision is a Pull Request"
mbed_official 48:f2739ac5cb01 11 }
mbed_official 48:f2739ac5cb01 12 }
mbed_official 48:f2739ac5cb01 13
mbed_official 48:f2739ac5cb01 14 // List of targets with supported RF shields to compile
mbed_official 48:f2739ac5cb01 15 def targets = [
mbed_official 48:f2739ac5cb01 16 "UBLOX_EVK_ODIN_W2",
mbed_official 48:f2739ac5cb01 17 "K64F",
mbed_official 48:f2739ac5cb01 18 "NUCLEO_F429ZI"
mbed_official 48:f2739ac5cb01 19 ]
mbed_official 48:f2739ac5cb01 20
mbed_official 48:f2739ac5cb01 21 // Map toolchains to compilers
mbed_official 48:f2739ac5cb01 22 def toolchains = [
mbed_official 48:f2739ac5cb01 23 ARM: "armcc",
mbed_official 48:f2739ac5cb01 24 GCC_ARM: "arm-none-eabi-gcc",
mbed_official 48:f2739ac5cb01 25 IAR: "IAR-linux"
mbed_official 48:f2739ac5cb01 26 ]
mbed_official 48:f2739ac5cb01 27
mbed_official 48:f2739ac5cb01 28 def stepsForParallel = [:]
mbed_official 48:f2739ac5cb01 29
mbed_official 48:f2739ac5cb01 30 // Jenkins pipeline does not support map.each, we need to use oldschool for loop
mbed_official 48:f2739ac5cb01 31 for (int i = 0; i < targets.size(); i++) {
mbed_official 48:f2739ac5cb01 32 for(int j = 0; j < toolchains.size(); j++) {
mbed_official 48:f2739ac5cb01 33 def target = targets.get(i)
mbed_official 48:f2739ac5cb01 34 def toolchain = toolchains.keySet().asList().get(j)
mbed_official 48:f2739ac5cb01 35 def compilerLabel = toolchains.get(toolchain)
mbed_official 48:f2739ac5cb01 36
mbed_official 48:f2739ac5cb01 37 def stepName = "${target} ${toolchain}"
mbed_official 48:f2739ac5cb01 38 stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain)
mbed_official 48:f2739ac5cb01 39 }
mbed_official 48:f2739ac5cb01 40 }
mbed_official 48:f2739ac5cb01 41
mbed_official 48:f2739ac5cb01 42 timestamps {
mbed_official 48:f2739ac5cb01 43 parallel stepsForParallel
mbed_official 48:f2739ac5cb01 44 }
mbed_official 48:f2739ac5cb01 45
mbed_official 48:f2739ac5cb01 46 def buildStep(target, compilerLabel, toolchain) {
mbed_official 48:f2739ac5cb01 47 return {
mbed_official 48:f2739ac5cb01 48 stage ("${target}_${compilerLabel}") {
mbed_official 48:f2739ac5cb01 49 node ("${compilerLabel}") {
mbed_official 48:f2739ac5cb01 50 deleteDir()
mbed_official 48:f2739ac5cb01 51 dir("mbed-os-example-socket") {
mbed_official 48:f2739ac5cb01 52 checkout scm
mbed_official 48:f2739ac5cb01 53
mbed_official 48:f2739ac5cb01 54 // Set mbed-os to revision received as parameter
mbed_official 48:f2739ac5cb01 55 execute ("mbed deploy --protocol ssh")
mbed_official 48:f2739ac5cb01 56 if (params.mbed_os_revision != '') {
mbed_official 48:f2739ac5cb01 57 dir ("mbed-os") {
mbed_official 48:f2739ac5cb01 58 if (params.mbed_os_revision.matches('pull/\\d+/head')) {
mbed_official 48:f2739ac5cb01 59 execute("git fetch origin ${params.mbed_os_revision}:PR")
mbed_official 48:f2739ac5cb01 60 execute("git checkout PR")
mbed_official 48:f2739ac5cb01 61 } else {
mbed_official 48:f2739ac5cb01 62 execute ("git checkout ${params.mbed_os_revision}")
mbed_official 48:f2739ac5cb01 63 }
mbed_official 48:f2739ac5cb01 64 }
mbed_official 48:f2739ac5cb01 65 }
mbed_official 48:f2739ac5cb01 66 execute("mbed new .")
mbed_official 48:f2739ac5cb01 67 execute ("mbed compile --build out/${target}_${toolchain}/ -m ${target} -t ${toolchain}")
mbed_official 48:f2739ac5cb01 68 }
mbed_official 48:f2739ac5cb01 69 stash name: "${target}_${toolchain}", includes: '**/mbed-os-example-socket.bin'
mbed_official 48:f2739ac5cb01 70 archive '**/mbed-os-example-socket.bin'
mbed_official 48:f2739ac5cb01 71 step([$class: 'WsCleanup'])
mbed_official 48:f2739ac5cb01 72 }
mbed_official 48:f2739ac5cb01 73 }
mbed_official 48:f2739ac5cb01 74 }
mbed_official 48:f2739ac5cb01 75 }