mbed Open Thread example with nRF52-DK (nRF52840 SoC).

Files at this revision

API Documentation at this revision

Comitter:
djabi
Date:
Fri Jan 04 23:55:03 2019 +0000
Parent:
119:b2035fc77033
Commit message:
Removed unused parts of the example code.

Changed in this revision

Hardware.md Show diff for this revision Revisions of this file
Jenkinsfile Show diff for this revision Revisions of this file
README.md Show diff for this revision Revisions of this file
configs/mesh_6lowpan.json Show diff for this revision Revisions of this file
configs/mesh_6lowpan_ATMEL.json Show diff for this revision Revisions of this file
configs/mesh_6lowpan_MCR20A.json Show diff for this revision Revisions of this file
configs/mesh_thread.json Show diff for this revision Revisions of this file
configs/mesh_thread_ATMEL.json Show diff for this revision Revisions of this file
configs/mesh_thread_MCR20A.json Show diff for this revision Revisions of this file
exporter_test.sh Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
mesh_led_control_example.cpp Show diff for this revision Revisions of this file
mesh_led_control_example.h Show diff for this revision Revisions of this file
--- a/Hardware.md	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-# Notes on different hardware
-
-As this example runs on multiple different mbed OS development boards there might be combinations of board and RF shields that may, or may not, work together due to pin collision or other reasons.
-
-This page aims to collect information regarding different hardware combinations.
-
-## RF shields
-
-Following RF shield have been used with mbed OS mesh examples.
-
-* [FIREFLY 6LOWPAN ARDUINO SHIELD](https://firefly-iot.com/product/firefly-arduino-shield-2-4ghz/)
-* [Freedom Development Board for MCR20A](http://www.nxp.com/products/software-and-tools/hardware-development-tools/freedom-development-boards/freedom-development-board-for-mcr20a-wireless-transceiver:FRDM-CR20A)
-* [X-NUCLEO-IDS01A4](http://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32-nucleo-expansion-boards/stm32-ode-connect-hw/x-nucleo-ids01a4.html)
-* [DVK-NCS36510-MBED-GEVB](https://developer.mbed.org/platforms/NCS36510/) Development board, contains internal RF chip.
-
-## Tested development boards
-
-Following table shows which development boards have been tested. It does not present our current testing infrastructure, so we cannot guarantee all combinations but we do our best to ensure it is up to date.
-
-| board / RF shield | Atmel | MCR20A | X-NUCLEO-IDS01A4 |
-|-------------------|-------|-----|------------------|
-| K64F | <span style='background-color: #5f5;'>Yes</span> | <span style='background-color: #5f5;'>Yes</span> | |
-| <span style='background-color: #ff5;'>NUCLEO_F429ZI **(1)**</span> | <span style='background-color: #5f5;'>Yes</span> | <span style='background-color: #5f5;'>Yes</span> | <span style='background-color: #ff5;'>Modified, **(3)**</span> |
-| NUCLEO_F401RE | <span style='background-color: #5f5;'>Yes</span> | | |
-| UBLOX_EVK_ODIN_W2 | <span style='background-color: #5f5;'>Yes</span> | <span style='background-color: #f00;'>No. **(2)**</span> | |
-| Onsemi NCS36510 <span style='background-color: #5f5;'>(internal RF)</span> | | | |
-| NXP KW24D <span style='background-color: #5f5;'>(internal RF)</span> | | <span style='background-color: #5f5;'>Yes **(4)**</span> | |
-| <span style='background-color: #ff5;'>NUCLEO_L476RG **(6)**</span> | <span style='background-color: #5f5;'>Yes</span> | | |
-
-
-**Notes:**
-
-1. If ethernet driver is enabled, requires HW modifications if RF shield uses SPI1. See [Driver notes](https://github.com/ARMmbed/sal-nanostack-driver-stm32-eth) and [nanostack-borderrouter-private Issue #17](https://github.com/ARMmbed/nanostack-border-router-private/issues/17)
-2. Pin collision, see [mesh-minimal Issue 55](https://github.com/ARMmbed/mbed-os-example-mesh-minimal/issues/55)
-3. X-NUCLEO-IDS01A4 expansion board required modifications to be used in mbed OS. See [Driver readme](https://github.com/ARMmbed/stm-spirit1-rf-driver)
-4. KW24D have MCR20A chip integrated. Use the same driver.
-5. KW24D has limited amount of memory (two banks of 32 RAM). For example, for the Thread end device use ARM or GCC_ARM. And for GCC_ARM use [this heap configuration](https://github.com/ARMmbed/mbed-os-example-mesh-minimal/#move-nanostacks-heap-inside-the-system-heap).
-6. NUCLEO_L476RF have LEDs on same pins that are used by Atmel RF shield so those should not be used in Light control demo. (LED1 & SPI_SCK == PA_5)
--- a/Jenkinsfile	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,225 +0,0 @@
-properties ([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
-  [$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'],
-  [$class: 'BooleanParameterDefinition', name: 'smoke_test', defaultValue: false, description: 'Enable to run HW smoke test after building']
-  ]]])
-
-if (params.mbed_os_revision == '') {
-  echo 'Use mbed OS revision from mbed-os.lib'
-} else {
-  echo "Use mbed OS revisiong ${params.mbed_os_revision}"
-  if (params.mbed_os_revision.matches('pull/\\d+/head')) {
-    echo "Revision is a Pull Request"
-  }
-}
-echo "Run smoke tests: ${params.smoke_test}"
-
-
-// Map RaaS instances to corresponding test suites
-// Run only selected set of tests.
-// Board: K64F
-// Radios: Atmel & MCR20A
-// configurations: 6LP + Thread
-def raas = [
-  "lowpan_mesh_minimal_smoke_k64f_atmel.json": "8001",
-//  "lowpan_mesh_minimal_smoke_k64f_mcr20.json": "8034",
-//  "lowpan_mesh_minimal_smoke_429zi_atmel.json": "8030",
-//  "lowpan_mesh_minimal_smoke_429zi_mcr20.json": "8033",
-//  "lowpan_mesh_minimal_smoke_ublox_atmel.json": "8031",
-//  "thread_mesh_minimal_smoke_k64f_atmel.json": "8007"
-  "thread_mesh_minimal_smoke_k64f_mcr20.json": "8034",
-//  "thread_mesh_minimal_smoke_429zi_atmel.json": "8030",
-//  "thread_mesh_minimal_smoke_429zi_mcr20.json": "8033",
-//  "thread_mesh_minimal_smoke_ublox_atmel.json": "8031"
-  ]
-
-// List of targets with supported RF shields to compile
-def targets = [
-  "K64F": ["ATMEL", "MCR20A"],
-  "NUCLEO_F401RE": ["ATMEL", "MCR20A"],
-  "NUCLEO_F429ZI": ["ATMEL", "MCR20A"],
-  //"NCS36510": ["internal"],
-  "UBLOX_EVK_ODIN_W2": ["ATMEL"],
-  "KW24D": ["internal"]
-  ]
-
-// Map toolchains to compilers
-def toolchains = [
-  ARM: "armcc",
-  GCC_ARM: "arm-none-eabi-gcc",
-  IAR: "IAR-linux"
-  ]
-
-// Supported RF shields
-def radioshields = [
-  "ATMEL",
-  "MCR20A",
-  "internal"
-  ]
-
-// Mesh interfaces: 6LoWPAN and Thread
-def meshinterfaces = [
-  "6lp",
-  "thd"
-  ]
-
-def stepsForParallel = [:]
-
-// Jenkins pipeline does not support map.each, we need to use oldschool for loop
-for (int i = 0; i < targets.size(); i++) {
-  for(int j = 0; j < toolchains.size(); j++) {
-    for(int k = 0; k < radioshields.size(); k++) {
-      for(int l = 0; l < meshinterfaces.size(); l++) {
-        def target = targets.keySet().asList().get(i)
-        def allowed_shields = targets.get(target)
-        def toolchain = toolchains.keySet().asList().get(j)
-        def compilerLabel = toolchains.get(toolchain)
-        def radioshield = radioshields.get(k)
-        def meshInterface = meshinterfaces.get(l)
-
-        def stepName = "${target} ${toolchain} ${radioshield} ${meshInterface}"
-        if(allowed_shields.contains(radioshield)) {
-          stepsForParallel[stepName] = buildStep(target, compilerLabel, toolchain, radioshield, meshInterface)
-        }
-      }
-    }
-  }
-}
-
-def parallelRunSmoke = [:]
-
-// Need to compare boolean against string value
-if ( params.smoke_test == true ) {
-  // Generate smoke tests based on suite amount
-  for(int i = 0; i < raas.size(); i++) {
-    def suite_to_run = raas.keySet().asList().get(i)
-    def raasPort = raas.get(suite_to_run)
-    // Parallel execution needs unique step names. Remove .json file ending.
-    def smokeStep = "${raasPort} ${suite_to_run.substring(0, suite_to_run.indexOf('.'))}"
-    parallelRunSmoke[smokeStep] = run_smoke(targets, toolchains, radioshields, meshinterfaces, raasPort, suite_to_run)
-  }
-}
-
-timestamps {
-  parallel stepsForParallel
-  parallel parallelRunSmoke
-}
-
-def buildStep(target, compilerLabel, toolchain, radioShield, meshInterface) {
-  return {
-    stage ("${target}_${compilerLabel}_${radioShield}_${meshInterface}") {
-      node ("${compilerLabel}") {
-        deleteDir()
-        dir("mbed-os-example-mesh-minimal") {
-          checkout scm
-          def config_file = "mbed_app.json"
-          def config_suffix = ""
-
-          if ("${radioShield}" != "internal") {
-            config_suffix = "_${radioShield}"
-          }
-
-          if ("${meshInterface}" == "thd") {
-            config_file = "./configs/mesh_thread${config_suffix}.json"
-            // Use systest Thread Border Router for testing (CH=26, PANID=BAAB)
-            execute("sed -i '/mbed-mesh-api.thread-device-type\":/a \"mbed-mesh-api.thread-config-channel\": 26,' ${config_file}")
-            execute("sed -i '/mbed-mesh-api.thread-device-type\":/a \"mbed-mesh-api.thread-config-panid\": \"0xBAAB\",' ${config_file}")
-            execute("sed -i 's/\"nanostack.configuration\": \"thread_router\"/\"nanostack.configuration\": \"thread_end_device\"/'  ${config_file}")
-            execute("sed -i 's/\"mbed-mesh-api.thread-device-type\": \"MESH_DEVICE_TYPE_THREAD_ROUTER\"/\"mbed-mesh-api.thread-device-type\": \"MESH_DEVICE_TYPE_THREAD_MINIMAL_END_DEVICE\"/' ${config_file}")
-            }
-
-          if ("${meshInterface}" == "6lp") {
-            config_file = "./configs/mesh_6lowpan${config_suffix}.json"
-            // Use systest 6LoWPAN Border Router for testing (CH=17, PANID=ABBA)
-            execute("sed -i 's/\"mbed-mesh-api.6lowpan-nd-channel\": 12/\"mbed-mesh-api.6lowpan-nd-channel\": 17/' ${config_file}")
-            execute("sed -i 's/\"mbed-mesh-api.6lowpan-nd-panid-filter\": \"0xffff\"/\"mbed-mesh-api.6lowpan-nd-panid-filter\": \"0xABBA\"/' ${config_file}")
-          }
-
-          // For KW24D, we need to optimize for low memory
-          if ("${target}" == "KW24D") {
-            // Use optimal mbed TLS config file, need double escaping of '\' characters, first ones to escape Grooy, second ones to escape shell
-            // Need to use SH shells
-            sh("sed -i '/\"target_overrides\"/ i \"macros\": [\"MBEDTLS_USER_CONFIG_FILE=\\\\\"mbedtls_config.h\\\\\"\"],' ${config_file}")
-            // Limit mesh heap size to 15kB
-            execute("sed -i 's/mbed-mesh-api.heap-size\": .*,/mbed-mesh-api.heap-size\": 15000,/' ${config_file}")
-            // Limit event loop heap size
-            execute("sed -i '/target.features_add/ i \"nanostack-hal.event_loop_thread_stack_size\": 2048,' ${config_file}")
-            execute("sed -i '/mbed-mesh-api.thread-device-type\":/a \"mbed-mesh-api.use-malloc-for-heap\": true,' ${config_file}")
-          }
-
-          // Activate traces
-          execute("sed -i 's/\"mbed-trace.enable\": false/\"mbed-trace.enable\": true/' ${config_file}")
-
-          // Set mbed-os to revision received as parameter
-          execute ("mbed deploy --protocol ssh")
-          if (params.mbed_os_revision != '') {
-            dir ("mbed-os") {
-              if (params.mbed_os_revision.matches('pull/\\d+/head')) {
-                execute("git fetch origin ${params.mbed_os_revision}:PR")
-                execute("git checkout PR")
-              } else {
-                execute ("git checkout ${params.mbed_os_revision}")
-              }
-            }
-          }
-
-          execute ("mbed compile --build out/${target}_${toolchain}_${radioShield}_${meshInterface}/ -m ${target} -t ${toolchain} -c --app-config ${config_file}")
-        }
-        stash name: "${target}_${toolchain}_${radioShield}_${meshInterface}", includes: '**/mbed-os-example-mesh-minimal.bin'
-        archive '**/mbed-os-example-mesh-minimal.bin'
-        step([$class: 'WsCleanup'])
-      }
-    }
-  }
-}
-
-def run_smoke(targets, toolchains, radioshields, meshinterfaces, raasPort, suite_to_run) {
-  return {
-    // Remove .json from suite name
-    def suiteName = suite_to_run.substring(0, suite_to_run.indexOf('.'))
-    stage ("smoke_${raasPort}_${suiteName}") {
-      node ("mesh-test") {
-        deleteDir()
-        dir("mbed-clitest") {
-          git "git@github.com:ARMmbed/mbed-clitest.git"
-          execute("git checkout ${env.LATEST_CLITEST_STABLE_REL}")
-        }
-        dir("testcases") {
-          git "git@github.com:ARMmbed/mbed-clitest-suites.git"
-          execute("git checkout master")
-          execute("git submodule update --init --recursive")
-          dir("6lowpan") {
-            execute("git checkout master")
-          }
-          dir("thread-tests") {
-            execute("git checkout master")
-          }
-        }
-
-        for (int i = 0; i < targets.size(); i++) {
-          for(int j = 0; j < toolchains.size(); j++) {
-            for(int k = 0; k < radioshields.size(); k++) {
-              for(int l = 0; l < meshinterfaces.size(); l++) {
-                def target = targets.keySet().asList().get(i)
-                def allowed_shields = targets.get(target)
-                def toolchain = toolchains.keySet().asList().get(j)
-                def radioshield = radioshields.get(k)
-                def meshInterface = meshinterfaces.get(l)
-                // Skip unwanted combination
-                if (target == "NUCLEO_F401RE" && toolchain == "IAR") {
-                  continue
-                }
-                if(allowed_shields.contains(radioshield)) {
-                  unstash "${target}_${toolchain}_${radioshield}_${meshInterface}"
-                }
-              }
-            }
-          }
-        }
-        env.RAAS_USERNAME = "user"
-        env.RAAS_PASSWORD = "user"
-        execute("./mbed-clitest/clitest.py --tcdir testcases --suitedir testcases/suites/ --suite ${suite_to_run} --type hardware --reset --raas http://rauni.mbedcloudtesting.com/ --raas_share_allocs --failure_return_value -vvv -w --log log_${raasPort}_${suiteName}")
-        archive "log_${raasPort}_${suiteName}/**/*"
-      }
-    }
-  }
-}
--- a/README.md	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,235 +0,0 @@
-# Example mesh application for Mbed OS
-
-With this application, you can use the [mesh networking API](https://os.mbed.com/docs/latest/apis/mesh-api.html) that [Mbed OS](https://github.com/ARMmbed/mbed-os) provides.
-
-The application demonstrates a light control application, where devices can control the LED status of all devices in the network.
-The application can be built for the unsecure 6LoWPAN-ND or Thread network.
-
-See the [6LoWPAN overview](https://os.mbed.com/docs/latest/reference/mesh-tech.html) for the definition of star and mesh networks. These same principles apply also to Thread protocol.
-
-## Setup
-
-### Download the application
-
-```
-mbed import mbed-os-example-mesh-minimal
-cd mbed-os-example-mesh-minimal
-```
-
-### Change the channel settings (optional)
-
-See the file `mbed_app.json` for an example of defining an IEEE 802.15.4 channel to use.
-
-### Selecting optimal Nanostack configuration
-
-To optimize the flash usage, select a proper configuration for Nanostack. The configuration depends mostly on the preferred use case.
-
-Select the protocol the network is based on:
-
-- 6LoWPAN-ND.
-- Thread.
-
-Select the device role:
-
-- Mesh network. A router. (default)
-- Star network. Nonrouting device. Also known as a host or sleepy host.
-
-Modify your `mbed_app.json` file to see which Nanostack and [Mbed Mesh API](https://os.mbed.com/docs/latest/apis/mesh-api.html) configuration to use.
-
-Example configuration files are provide under `configs/` directory. You may override the `mbed_app.json` with either of these.
-
-|configuration file|Use for|
-|------------------|-------|
-|`configs/mesh_6lowpan.json` | 6LoWPAN-ND based mesh network. |
-|`configs/mesh_thread.json` | Thread based mesh network. |
-
-An example of the `mbed_app.json` file:
-
-```
-...
-    "target_overrides": {
-        "*": {
-            "nanostack.configuration": "lowpan_router",
-            "nsapi.default-mesh-type": "LOWPAN",
-            "mbed-mesh-api.6lowpan-nd-panid-filter": "0xffff",
-            "mbed-mesh-api.6lowpan-nd-channel-page": 0,
-            "mbed-mesh-api.6lowpan-nd-channel": 12,
-            "mbed-mesh-api.6lowpan-nd-channel-mask": "(1<<12)",
-            "mbed-mesh-api.heap-size": 14000,
-            "mbed-trace.enable": false,
-            "platform.stdio-convert-newlines": true,
-            "platform.stdio-baud-rate": 115200,
-            "atmel-rf.provide-default": true,
-            "mcr20a.provide-default": false,
-            "target.device_has_add": ["802_15_4_PHY"],
-            "target.network-default-interface-type": "MESH"
-        },
-```
-
-The following tables show the values to use in the `mbed_app.json` file for your devices in different networks.
-
-- For a 6LoWPAN-ND based network, use `nsapi.default-mesh-type: LOWPAN`.
-- For a Thread-based network, use `nsapi.default-mesh-type: THREAD`.
-
-#### 6LoWPAN-ND
-
-**nsapi.default-mesh-type: LOWPAN**
-
-|Device role|`nanostack.configuration` value|`mbed-mesh-api.6lowpan-nd-device-type` value|
-|-----------|-------------------------|------------------------------------|
-|Mesh router (default) | lowpan_router | NET_6LOWPAN_ROUTER |
-|Nonrouting device | lowpan_host | NET_6LOWPAN_HOST |
-
-#### Thread
-
-**nsapi.default-mesh-type: THREAD**
-
-|Device role|`nanostack.configuration` value|`mbed-mesh-api.thread-device-type` value|
-|-----------|-------------------------|------------------------------------|
-|Mesh router (default) | thread_router | MESH_DEVICE_TYPE_THREAD_ROUTER |
-|Nonrouting device | thread_end_device | MESH_DEVICE_TYPE_THREAD_SLEEPY_END_DEVICE |
-
-##### Thread commissioning
-
-By default, the Thread application uses the static network link configuration defined in the [mesh API configuration file](https://github.com/ARMmbed/mbed-os/blob/master/features/nanostack/mbed-mesh-api/mbed_lib.json).
-If you want to commission a Thread device, see [how to commission a Thread device in practice](https://os.mbed.com/docs/latest/reference/mesh-tech.html#thread-commissioning).
-
-The Thread stack learns the network settings from the commissioning process and saves them to RAM memory. Therefore, the learned network settings are lost when you restart the device next time. To prevent re-commissioning, you can save the Thread configuration settings to an SD card as follows (only in `K64F`):
-
-- Change `storage-device` to `MESH_NVM_SD_CARD` in the `./configs/mesh_thread.json` file.
-- Enable commissioning as descibed in the referred instructions.
-- Compile and program the application.
-- Insert an erased or FAT-formatted SD card to the `K64F` memory card slot. The application will initialize the SD card with the appropriate file system on first use.
-- Commission the device to the Thread network.
-- When you restart the device next time, the device reads the Thread configuration settings from the SD card and tries to attach to an existing network.
-
-### Requirements for hardware
-
-The networking stack used in this example requires TLS functionality to be enabled on Mbed TLS.
-On devices where hardware entropy is not present, TLS is disabled by default. This results in compile time failures or linking failures.
-
-To learn why entropy is required, read the [TLS Porting guide](https://os.mbed.com/docs/latest/reference/mbed-tls-entropy.html).
-
-See [Notes on different hardware](https://github.com/ARMmbed/mbed-os-example-mesh-minimal/blob/master/Hardware.md) for known combinations of development boards and RF shields that have been tested.
-
-You also need to check how LEDs and buttons are configured for your hardware, and update .json accordingly.
-
-### Changing the radio driver
-
-To run a 6LoWPAN-ND network, you need a working RF driver for Nanostack. This example uses the Atmel AT86RF233 by default.
-
-To change the RF driver modify the `mbed_app.json` file by setting preferred RF driver `provide_default` value to true, For example, to use MCR20a RF driver: 
-
-```json
-"atmel-rf.provide-default": false,
-"mcr20a.provide-default": true,
-```
-
-### Compile the application
-
-```
-mbed compile -m K64F -t GCC_ARM
-```
-
-A binary is generated in the end of the build process.
-
-### Connect the RF shield to the board
-
-We are using the Atmel AT86RF233, which you can [purchase](https://firefly-iot.com/product/firefly-arduino-shield-2-4ghz/). Place the shield on top of your board, and power it up.
-
-### Program the target
-
-Drag and drop the binary to the target to program the application.
-
-### Update the firmware of the border router
-
-This example supports the following border router:
-
-- [Nanostack-border-router](https://github.com/ARMmbed/nanostack-border-router).
-
-The border router supports static and dynamic backhaul configuration. The static configuration is good for testing, but the dynamic one works if your network infrastructure is supplying an IPv6 address. Make sure that you use the appropiate mode.
-
-Remember to connect the Ethernet cable between the border router and your home/office router. Then power on the board.
-
-## Testing
-
-By default the application is built for the LED control demo, in which the device sends a multicast message to all devices in the network when the button is pressed. All devices that receive the multicast message will change the LED status (red LED on/off) to the state defined in the message. Note, that the Thread devices can form a network without the existance of the border router. The following applies only to the case when the border router is set-up.
-
-As soon as both the border router and the target are up and running you can verify the correct behaviour. Open a serial console and see the IP address obtained by the device.
-
-<span class="notes">**Note:** This application uses the baud rate of 115200.</span>
-
-```
-connected. IP = 2001:db8:a0b:12f0::1
-```
-
-You can use this IP address to `ping` from your PC and verify that the connection is working correctly.
-
-
-## Memory optimizations
-
-On some limited platforms, for example NCS36510 or KW24D, building this application might run out of RAM or ROM.
-In those cases, you might try following these instructions to optimize the memory usage.
-
-### Mbed TLS configuration
-
-The custom Mbed TLS configuration can be set by adding `"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_config.h\""]` to the `.json` file. The [example Mbed TLS config](https://github.com/ARMmbed/mbed-os-example-mesh-minimal/blob/master/mbedtls_config.h) minimizes the RAM and ROM usage of the application. The configuration works on K64F, but it is not guaranteed to work on every Mbed Enabled platform.
-
-This configuration file saves you 8.7 kB of RAM but uses 6.8 kB of more flash.
-
-### Disabling the LED control example
-
-You can disable the LED control example by specifying `enable-led-control-example": false` in the `mbed_app.json`
-
-This saves you about 2.5 kB of flash.
-
-### Change network stack's event loop stack size
-
-Nanostack's internal event-loop is shared with Mbed Client and therefore requires lots of stack to complete the security hanshakes using TLS protocols.
-In case client functionality is not used, you can define the following to use 2kB of stack
-
-`"nanostack-hal.event_loop_thread_stack_size": 2048`
-
-This saves you 4kB of RAM.
-
-### Change Nanostack's heap size
-
-Nanostack uses internal heap, which you can configure in the .json. A thread end device with comissioning enabled requires at least 15kB to run.
-
-In `mbed_app.json`, you find the following line:
-
-```
-"mbed-mesh-api.heap-size": 15000,
-```
-
-For 6LoWPAN, you can try 12kB. For the smallest memory usage, configure the node to be in nonrouting mode. See [module-configuration](https://github.com/ARMmbed/mbed-os/tree/master/features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api#module-configuration) for more detail.
-
-### Move Nanostack's heap inside the system heap
-
-Nanostack's internal heap can be moved within the system heap.
-This helps on devices that have split RAM and compiler fails to fit statically allocated symbols into one section, for example, the NXP KW24D device.
-
-Mesh API has the [use-malloc-for-heap](https://github.com/ARMmbed/mbed-os/blob/master/features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/README.md#configurable-parameters-in-section-mbed-mesh-api) option to help this.
-
-Add the following line to `mbed_app.json` to test:
-
-```
-"mbed-mesh-api.use-malloc-for-heap": true,
-```
-
-### Use release profile
-
-For devices with small memory, we recommend using release profiles for building and exporting. Please see the documentation about [Build profiles](https://os.mbed.com/docs/latest/tools/build-profiles.html).
-
-Examples:
-
-```
-$ mbed export -m KW24D -i make_iar --profile release
-OR
-$ mbed compile -m KW24D -t IAR --profile release
-```
-
-## Troubleshooting
-
-If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
-
--- a/configs/mesh_6lowpan.json	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-{
-    "config": {
-        "enable-led-control-example": true,
-        "LED": "NC",
-        "BUTTON": "NC",
-        "BUTTON_MODE": "PullUp"
-    },
-    "target_overrides": {
-        "*": {
-            "nanostack.configuration": "lowpan_router",
-            "nsapi.default-mesh-type": "LOWPAN",
-            "mbed-mesh-api.6lowpan-nd-panid-filter": "0xffff",
-            "mbed-mesh-api.6lowpan-nd-channel-page": 0,
-            "mbed-mesh-api.6lowpan-nd-channel": 12,
-            "mbed-mesh-api.6lowpan-nd-channel-mask": "(1<<12)",
-            "mbed-mesh-api.heap-size": 14000,
-            "mbed-trace.enable": false,
-            "platform.stdio-convert-newlines": true,
-            "platform.stdio-baud-rate": 115200,
-            "atmel-rf.provide-default": false,
-            "mcr20a.provide-default": false,
-            "target.device_has_add": ["802_15_4_PHY"],
-            "target.network-default-interface-type": "MESH"
-        },
-        "K64F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "K66F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "KW24D": {
-            "LED": "LED1",
-            "BUTTON": "SW1"
-        },
-        "NUCLEO_F401RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NUCLEO_F429ZI":  {
-            "LED": "LED_RED",
-            "BUTTON": "USER_BUTTON",
-            "BUTTON_MODE": "PullDown"
-        },
-        "NUCLEO_F411RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NCS36510": {
-            "LED": "LED1",
-            "BUTTON": "SW2"
-        }
-    }
-}
--- a/configs/mesh_6lowpan_ATMEL.json	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-{
-    "config": {
-        "enable-led-control-example": true,
-        "LED": "NC",
-        "BUTTON": "NC",
-        "BUTTON_MODE": "PullUp"
-    },
-    "target_overrides": {
-        "*": {
-            "nanostack.configuration": "lowpan_router",
-            "nsapi.default-mesh-type": "LOWPAN",
-            "mbed-mesh-api.6lowpan-nd-panid-filter": "0xffff",
-            "mbed-mesh-api.6lowpan-nd-channel-page": 0,
-            "mbed-mesh-api.6lowpan-nd-channel": 12,
-            "mbed-mesh-api.6lowpan-nd-channel-mask": "(1<<12)",
-            "mbed-mesh-api.heap-size": 14000,
-            "mbed-trace.enable": false,
-            "platform.stdio-convert-newlines": true,
-            "platform.stdio-baud-rate": 115200,
-            "atmel-rf.provide-default": true,
-            "mcr20a.provide-default": false,
-            "target.device_has_add": ["802_15_4_PHY"],
-            "target.network-default-interface-type": "MESH"
-        },
-        "K64F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "K66F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "KW24D": {
-            "LED": "LED1",
-            "BUTTON": "SW1"
-        },
-        "NUCLEO_F401RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NUCLEO_F429ZI":  {
-            "LED": "LED_RED",
-            "BUTTON": "USER_BUTTON",
-            "BUTTON_MODE": "PullDown"
-        },
-        "NUCLEO_F411RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NCS36510": {
-            "LED": "LED1",
-            "BUTTON": "SW2"
-        }
-    }
-}
--- a/configs/mesh_6lowpan_MCR20A.json	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-{
-    "config": {
-        "enable-led-control-example": true,
-        "LED": "NC",
-        "BUTTON": "NC",
-        "BUTTON_MODE": "PullUp"
-    },
-    "target_overrides": {
-        "*": {
-            "nanostack.configuration": "lowpan_router",
-            "nsapi.default-mesh-type": "LOWPAN",
-            "mbed-mesh-api.6lowpan-nd-panid-filter": "0xffff",
-            "mbed-mesh-api.6lowpan-nd-channel-page": 0,
-            "mbed-mesh-api.6lowpan-nd-channel": 12,
-            "mbed-mesh-api.6lowpan-nd-channel-mask": "(1<<12)",
-            "mbed-mesh-api.heap-size": 14000,
-            "mbed-trace.enable": false,
-            "platform.stdio-convert-newlines": true,
-            "platform.stdio-baud-rate": 115200,
-            "atmel-rf.provide-default": false,
-            "mcr20a.provide-default": true,
-            "target.device_has_add": ["802_15_4_PHY"],
-            "target.network-default-interface-type": "MESH"
-        },
-      	"K64F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "K66F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-		},
-        "KW24D": {
-            "LED": "LED1",
-            "BUTTON": "SW1"
-        },
-        "NUCLEO_F401RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NUCLEO_F429ZI":  {
-            "LED": "LED_RED",
-            "BUTTON": "USER_BUTTON",
-            "BUTTON_MODE": "PullDown"
-        },
-        "NUCLEO_F411RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NCS36510": {
-            "LED": "LED1",
-            "BUTTON": "SW2"
-        }
-    }
-}
--- a/configs/mesh_thread.json	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-{
-    "config": {
-        "storage-device":{
-            "help": "Values for storage (Thread) devices are: MESH_NVM_HEAP, MESH_NVM_SD_CARD and MESH_NVM_NONE",
-            "value": "MESH_NVM_NONE"
-        },
-        "enable-led-control-example": true,
-        "LED": "NC",
-        "BUTTON": "NC",
-        "BUTTON_MODE": "PullUp"
-    },
-    "target_overrides": {
-        "*": {
-            "nanostack.configuration": "thread_router",
-            "nsapi.default-mesh-type": "THREAD",
-            "mbed-trace.enable": false,
-            "mbed-mesh-api.heap-size": 30000,
-            "mbed-mesh-api.thread-device-type": "MESH_DEVICE_TYPE_THREAD_ROUTER",
-            "platform.stdio-convert-newlines": true,
-            "platform.stdio-baud-rate": 115200,
-            "mbed-mesh-api.thread-use-static-link-config": true,
-            "atmel-rf.provide-default": false,
-            "mcr20a.provide-default": false,
-            "target.device_has_add": ["802_15_4_PHY"],
-            "target.network-default-interface-type": "MESH"
-        },
-        "K64F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "K66F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "KW24D": {
-            "LED": "LED1",
-            "BUTTON": "SW1"
-        },
-        "NUCLEO_F401RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NUCLEO_F429ZI":  {
-            "LED": "LED_RED",
-            "BUTTON": "USER_BUTTON",
-            "BUTTON_MODE": "PullDown"
-        },
-        "NUCLEO_F411RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NCS36510": {
-            "LED": "LED1",
-            "BUTTON": "SW2"
-        }
-    }
-
-}
--- a/configs/mesh_thread_ATMEL.json	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-{
-    "config": {
-        "storage-device":{
-            "help": "Values for storage (Thread) devices are: MESH_NVM_HEAP, MESH_NVM_SD_CARD and MESH_NVM_NONE",
-            "value": "MESH_NVM_NONE"
-        },
-        "enable-led-control-example": true,
-        "LED": "NC",
-        "BUTTON": "NC",
-        "BUTTON_MODE": "PullUp"
-    },
-    "target_overrides": {
-        "*": {
-            "nanostack.configuration": "thread_router",
-            "nsapi.default-mesh-type": "THREAD",
-            "mbed-trace.enable": false,
-            "mbed-mesh-api.heap-size": 30000,
-            "mbed-mesh-api.thread-device-type": "MESH_DEVICE_TYPE_THREAD_ROUTER",
-            "platform.stdio-convert-newlines": true,
-            "platform.stdio-baud-rate": 115200,
-            "mbed-mesh-api.thread-use-static-link-config": true,
-            "atmel-rf.provide-default": true,
-            "mcr20a.provide-default": false,
-            "target.device_has_add": ["802_15_4_PHY"],
-            "target.network-default-interface-type": "MESH"
-        },
-        "K64F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "K66F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "KW24D": {
-            "LED": "LED1",
-            "BUTTON": "SW1"
-        },
-        "NUCLEO_F401RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NUCLEO_F429ZI":  {
-            "LED": "LED_RED",
-            "BUTTON": "USER_BUTTON",
-            "BUTTON_MODE": "PullDown"
-        },
-        "NUCLEO_F411RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NCS36510": {
-            "LED": "LED1",
-            "BUTTON": "SW2"
-        }
-    }
-
-}
--- a/configs/mesh_thread_MCR20A.json	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-{
-    "config": {
-        "storage-device":{
-            "help": "Values for storage (Thread) devices are: MESH_NVM_HEAP, MESH_NVM_SD_CARD and MESH_NVM_NONE",
-            "value": "MESH_NVM_NONE"
-        },
-        "enable-led-control-example": true,
-        "LED": "NC",
-        "BUTTON": "NC",
-        "BUTTON_MODE": "PullUp"
-    },
-    "target_overrides": {
-        "*": {
-            "nanostack.configuration": "thread_router",
-            "nsapi.default-mesh-type": "THREAD",
-            "mbed-trace.enable": false,
-            "mbed-mesh-api.heap-size": 30000,
-            "mbed-mesh-api.thread-device-type": "MESH_DEVICE_TYPE_THREAD_ROUTER",
-            "platform.stdio-convert-newlines": true,
-            "platform.stdio-baud-rate": 115200,
-            "mbed-mesh-api.thread-use-static-link-config": true,
-            "atmel-rf.provide-default": false,
-            "mcr20a.provide-default": true,
-            "target.device_has_add": ["802_15_4_PHY"],
-            "target.network-default-interface-type": "MESH"
-        },
-        "K64F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "K66F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "KW24D": {
-            "LED": "LED1",
-            "BUTTON": "SW1"
-        },
-        "NUCLEO_F401RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NUCLEO_F429ZI":  {
-            "LED": "LED_RED",
-            "BUTTON": "USER_BUTTON",
-            "BUTTON_MODE": "PullDown"
-        },
-        "NUCLEO_F411RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NCS36510": {
-            "LED": "LED1",
-            "BUTTON": "SW2"
-        }
-    }
-
-}
--- a/exporter_test.sh	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#!/bin/bash
-
-# Stop on failure
-set -eu
-
-EXPORTERS=(make_armc5 make_gcc_arm make_iar uvision5 iar)
-PASSED=()
-FAILED=()
-
-fail() {
-	FAILED+=($1)
-	return 0
-}
-
-pass() {
-	PASSED+=($1)
-}
-
-for tool in ${EXPORTERS[*]};do
-	echo "Testing on $tool"
-	if ! mbed export -m K64F -i $tool; then
-		fail $tool
-		continue
-	fi
-	# Makefile builds
-	if [[ $tool = make_* ]]; then
-		make && pass $tool || fail $tool
-	elif [[ $tool = uvision5 ]]; then
-		# Keil return ERRORLEVEL 0, when build OK without warnings
-		# ERRORLEVEL 1, when there was warnings. 2 or over, is not OK.
-		"c:/Keil_v5/UV4/UV4.exe" -b mbed-os-example-mesh-minimal.uvprojx || \
-		test $? -lt 2 && pass $tool || fail $tool
-	elif [[ $tool = iar ]]; then
-		"C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.5/common/bin/IarBuild.exe" mbed-os-example-mesh-minimal.ewp mbed-os-example-mesh-minimal \
-			&& pass $tool || fail $tool
-	fi
-	mv BUILD BUILD_$tool
-done
-
-printf "\n|%15s |%6s |\n" "Tool" "Result"
-printf "|----------------|-------|\n"
-for tool in ${PASSED[@]-};do
-	printf "|%15s |%6s |\n" $tool PASS
-done
-for tool in ${FAILED[@]-};do
-	printf "|%15s |%6s |\n" $tool FAIL
-done
--- a/main.cpp	Fri Jan 04 23:49:48 2019 +0000
+++ b/main.cpp	Fri Jan 04 23:55:03 2019 +0000
@@ -19,9 +19,6 @@
 #include "mbed-trace/mbed_trace.h"
 #include "mesh_nvm.h"
 
-#if MBED_CONF_APP_ENABLE_LED_CONTROL_EXAMPLE
-#include "mesh_led_control_example.h"
-#endif
 
 void trace_printer(const char* str) {
     printf("%s\n", str);
@@ -33,13 +30,9 @@
 
 void thread_eui64_trace()
 {
-#define LOWPAN 1
-#define THREAD 2
-#if MBED_CONF_NSAPI_DEFAULT_MESH_TYPE == THREAD && (MBED_VERSION >= MBED_ENCODE_VERSION(5,10,0))
    uint8_t eui64[8] = {0};
    static_cast<ThreadInterface*>(mesh)->device_eui64_get(eui64);
    printf("Device EUI64 address = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", eui64[0], eui64[1], eui64[2], eui64[3], eui64[4], eui64[5], eui64[6], eui64[7]);
-#endif
 }
 
 void serial_out_mutex_wait()
@@ -67,13 +60,6 @@
     printf("Mbed OS version: %d.%d.%d\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
 #endif
 
-#if MBED_CONF_APP_ENABLE_LED_CONTROL_EXAMPLE
-    if (MBED_CONF_APP_BUTTON != NC && MBED_CONF_APP_LED != NC) {
-        start_blinking();
-    } else {
-        printf("pins not configured. Skipping the LED control.\n");
-    }
-#endif
     mesh = MeshInterface::get_default_instance();
     if (!mesh) {
         printf("Error! MeshInterface not found!\n");
@@ -93,12 +79,4 @@
         ThisThread::sleep_for(500);
 
     printf("Connected. IP = %s\n", mesh->get_ip_address());
-
-#if MBED_CONF_APP_ENABLE_LED_CONTROL_EXAMPLE
-    // Network found, start socket example
-    if (MBED_CONF_APP_BUTTON != NC && MBED_CONF_APP_LED != NC) {
-        cancel_blinking();
-        start_mesh_led_control_example((NetworkInterface *)mesh);
-    }
-#endif
 }
--- a/mbed_app.json	Fri Jan 04 23:49:48 2019 +0000
+++ b/mbed_app.json	Fri Jan 04 23:55:03 2019 +0000
@@ -4,7 +4,6 @@
             "help": "Values for storage (Thread) devices are: MESH_NVM_HEAP, MESH_NVM_SD_CARD and MESH_NVM_NONE",
             "value": "MESH_NVM_NONE"
         },
-        "enable-led-control-example": true,
         "LED": "NC",
         "BUTTON": "NC",
         "BUTTON_MODE": "PullUp"
@@ -13,7 +12,7 @@
         "*": {
             "nanostack.configuration": "thread_router",
             "nsapi.default-mesh-type": "THREAD",
-            "mbed-trace.enable": false,
+            "mbed-trace.enable": true,
             "mbed-mesh-api.heap-size": 30000,
             "mbed-mesh-api.thread-device-type": "MESH_DEVICE_TYPE_THREAD_ROUTER",
             "platform.stdio-convert-newlines": true,
@@ -25,37 +24,8 @@
         },
         "NRF52_DK": {
             "LED": "LED1",
-            "BUTTON": "BUTTON1"
-        },
-        "K64F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "K66F": {
-            "LED": "LED_RED",
-            "BUTTON": "SW2"
-        },
-        "KW24D": {
-            "LED": "LED1",
-            "BUTTON": "SW1"
-        },
-        "NUCLEO_F401RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NUCLEO_F429ZI":  {
-            "LED": "LED_RED",
-            "BUTTON": "USER_BUTTON",
-            "BUTTON_MODE": "PullDown"
-        },
-        "NUCLEO_F411RE": {
-            "LED": "NC",
-            "BUTTON": "USER_BUTTON"
-        },
-        "NCS36510": {
-            "LED": "LED1",
-            "BUTTON": "SW2"
+            "BUTTON": "BUTTON1",
+            "storage-device": "MESH_NVM_SD_CARD"
         }
     }
-
 }
--- a/mesh_led_control_example.cpp	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2016 ARM Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- * Licensed under the Apache License, Version 2.0 (the License); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "mbed.h"
-#include "nanostack/socket_api.h"
-#include "mesh_led_control_example.h"
-#include "common_functions.h"
-#include "ip6string.h"
-#include "mbed-trace/mbed_trace.h"
-
-static void init_socket();
-static void handle_socket();
-static void receive();
-static void my_button_isr();
-static void send_message();
-static void blink();
-static void update_state(uint8_t state);
-static void handle_message(char* msg);
-
-#define multicast_addr_str "ff15::810a:64d1"
-#define TRACE_GROUP "example"
-#define UDP_PORT 1234
-#define MESSAGE_WAIT_TIMEOUT (30.0)
-#define MASTER_GROUP 0
-#define MY_GROUP 1
-
-DigitalOut led_1(MBED_CONF_APP_LED, 1);
-InterruptIn my_button(MBED_CONF_APP_BUTTON);
-DigitalOut output(D3, 1);
-
-NetworkInterface * network_if;
-UDPSocket* my_socket;
-// queue for sending messages from button press.
-EventQueue queue;
-// for LED blinking
-Ticker ticker;
-// Handle for delayed message send
-int queue_handle = 0;
-
-uint8_t multi_cast_addr[16] = {0};
-uint8_t receive_buffer[20];
-// how many hops the multicast message can go
-static const int16_t multicast_hops = 10;
-bool button_status = 0;
-
-void start_mesh_led_control_example(NetworkInterface * interface){
-    tr_debug("start_mesh_led_control_example()");
-    MBED_ASSERT(MBED_CONF_APP_LED != NC);
-    MBED_ASSERT(MBED_CONF_APP_BUTTON != NC);
-
-    network_if = interface;
-    stoip6(multicast_addr_str, strlen(multicast_addr_str), multi_cast_addr);
-    init_socket();
-}
-
-static void blink() {
-    led_1 = !led_1;
-}
-
-void start_blinking() {
-    ticker.attach(blink, 1.0);
-}
-
-void cancel_blinking() {
-    ticker.detach();
-    led_1=1;
-}
-
-static void send_message() {
-    tr_debug("send msg %d", button_status);
-
-    char buf[20];
-    int length;
-
-    /**
-    * Multicast control message is a NUL terminated string of semicolon separated
-    * <field identifier>:<value> pairs.
-    *
-    * Light control message format:
-    * t:lights;g:<group_id>;s:<1|0>;\0
-    */
-    length = snprintf(buf, sizeof(buf), "t:lights;g:%03d;s:%s;", MY_GROUP, (button_status ? "1" : "0")) + 1;
-    MBED_ASSERT(length > 0);
-    tr_debug("Sending lightcontrol message, %d bytes: %s", length, buf);
-    SocketAddress send_sockAddr(multi_cast_addr, NSAPI_IPv6, UDP_PORT);
-    my_socket->sendto(send_sockAddr, buf, 20);
-    //After message is sent, it is received from the network
-}
-
-// As this comes from isr, we cannot use printing or network functions directly from here.
-static void my_button_isr() {
-    button_status = !button_status;
-    queue.call(send_message);
-}
-
-static void update_state(uint8_t state) {
-    if (state == 1) {
-       tr_debug("Turning led on\n");
-       led_1 = 0;
-       button_status=1;
-       output = 0;
-       }
-    else {
-       tr_debug("Turning led off\n");
-       led_1 = 1;
-       button_status=0;
-       output = 1;
-   }
-}
-
-static void handle_message(char* msg) {
-    // Check if this is lights message
-    uint8_t state=button_status;
-    uint16_t group=0xffff;
-
-    if (strstr(msg, "t:lights;") == NULL) {
-       return;
-    }
-
-    if (strstr(msg, "s:1;") != NULL) {
-        state = 1;
-    }
-    else if (strstr(msg, "s:0;") != NULL) {
-        state = 0;
-    }
-
-    // 0==master, 1==default group
-    char *msg_ptr = strstr(msg, "g:");
-    if (msg_ptr) {
-        char *ptr;
-        group = strtol(msg_ptr, &ptr, 10);
-    }
-
-    // in this example we only use one group
-    if (group==MASTER_GROUP || group==MY_GROUP) {
-        update_state(state);
-    }
-}
-
-static void receive() {
-    // Read data from the socket
-    SocketAddress source_addr;
-    memset(receive_buffer, 0, sizeof(receive_buffer));
-    bool something_in_socket=true;
-    // read all messages
-    while (something_in_socket) {
-        int length = my_socket->recvfrom(&source_addr, receive_buffer, sizeof(receive_buffer) - 1);
-        if (length > 0) {
-            int timeout_value = MESSAGE_WAIT_TIMEOUT;
-            tr_debug("Packet from %s\n", source_addr.get_ip_address());
-            timeout_value += rand() % 30;
-            tr_debug("Advertisiment after %d seconds", timeout_value);
-            queue.cancel(queue_handle);
-            queue_handle = queue.call_in((timeout_value * 1000), send_message);
-            // Handle command - "on", "off"
-            handle_message((char*)receive_buffer);
-        }
-        else if (length!=NSAPI_ERROR_WOULD_BLOCK) {
-            tr_error("Error happened when receiving %d\n", length);
-            something_in_socket=false;
-        }
-        else {
-            // there was nothing to read.
-            something_in_socket=false;
-        }
-    }
-}
-
-static void handle_socket() {
-    // call-back might come from ISR
-    queue.call(receive);
-}
-
-static void init_socket()
-{
-    my_socket = new UDPSocket();
-    my_socket->open(network_if);
-    my_socket->set_blocking(false);
-    my_socket->bind(UDP_PORT);
-    my_socket->setsockopt(SOCKET_IPPROTO_IPV6, SOCKET_IPV6_MULTICAST_HOPS, &multicast_hops, sizeof(multicast_hops));
-
-    ns_ipv6_mreq_t mreq;
-    memcpy(mreq.ipv6mr_multiaddr, multi_cast_addr, 16);
-    mreq.ipv6mr_interface = 0;
-
-    my_socket->setsockopt(SOCKET_IPPROTO_IPV6, SOCKET_IPV6_JOIN_GROUP, &mreq, sizeof mreq);
-
-    if (MBED_CONF_APP_BUTTON != NC) {
-        my_button.fall(&my_button_isr);
-        my_button.mode(MBED_CONF_APP_BUTTON_MODE);
-    }
-    //let's register the call-back function.
-    //If something happens in socket (packets in or out), the call-back is called.
-    my_socket->sigio(callback(handle_socket));
-    // dispatch forever
-    queue.dispatch();
-}
--- a/mesh_led_control_example.h	Fri Jan 04 23:49:48 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2016 ARM Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- * Licensed under the Apache License, Version 2.0 (the License); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef SOCKET_EXAMPLE_H
-#define SOCKET_EXAMPLE_H
-
-#include "NetworkInterface.h"
-
-void start_mesh_led_control_example(NetworkInterface * interface);
-void start_blinking();
-void cancel_blinking();   
-   
-#endif