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.

Getting started with mbed Client on mbed OS

This is the mbed Client example for mbed OS. It demonstrates how to register a device with mbed Device Connector, how to read and write values, and how to deregister. If you are unfamiliar with mbed Device Connector, we recommend that you read the introduction to the data model first.

The application:

  • Connects to network with WiFi, Ethernet, 6LoWPAN ND or Thread connection.
  • Registers with mbed Device Connector.
  • Gives mbed Device Connector access to its resources (read and write).
  • Records the number of clicks on the device’s button and sends the number to mbed Device Connector.
  • Lets you control the blink pattern of the LED on the device (through mbed Device Connector).

Required hardware

  • K64F board.
  • 1-2 micro-USB cables.
  • mbed 6LoWPAN gateway router for 6LoWPAN ND and Thread.
  • mbed 6LoWPAN shield (AT86RF212B/AT86RF233 for 6LoWPAN ND and Thread.
  • Ethernet cable and connection to the internet.

Requirements for non K64F board

This example application is primarily designed for FRDM-K64F board but you can also use other mbed OS supported boards to run this example application , with some minor modifications for setup.

  • To get the application registering successfully on non K64F boards , you need Edit the mbed_app.json file to add NULL_ENTROPY feature for mbedTLS:

""macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\"",
            "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES",
            "MBEDTLS_TEST_NULL_ENTROPY"],
  • On non K64F boards, there is no unregistration functionality and button press is simulated through timer ticks incrementing every 15 seconds.

Application setup

To configure the example application, please check following:

Connection type

The application uses Ethernet as the default connection type. To change the connection type, set one of them in mbed_app.json. For example, to enable 6LoWPAN ND mode:

    "network-interface": {
        "help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD.",
        "value": "MESH_LOWPAN_ND"
    }

Client credentials

To register the application to the Connector service, you need to create and set the client side certificate.

  • Go to mbed Device Connector and log in with your mbed account.
  • On mbed Device Connector, go to My Devices > Security credentials and click the Get my device security credentials button to get new credentials for your device.
  • Replace the contents in `security.h` of this project's directory with content copied above.

6LoWPAN ND and Thread settings

First you need to select the RF driver to be used by 6LoWPAN/Thread stack.

For example Atmel AT86RF233/212B driver is located in https://github.com/ARMmbed/atmel-rf-driver

To add that driver to you application , import library from following URL:

https://github.com/ARMmbed/atmel-rf-driver

Then you need to enable the IPV6 functionality as the 6LoWPAN and Thread are part of IPv6 stack. Edit the mbed_app.json file to add IPV6 feature:

"target.features_add": ["CLIENT", "IPV6", "COMMON_PAL"],

6LoWPAN ND and Thread use IPv6 for connectivity. Therefore, you need to verify first that you have a working IPv6 connection. To do that, ping the Connector IPv6 address 2607:f0d0:2601:52::20 from your network.

mbed gateway

To connect the example application in 6LoWPAN ND or Thread mode to Connector, you need to set up an mbed 6LoWPAN gateway router as follows:

  • Use an Ethernet cable to connect the mbed 6LoWPAN gateway router to the internet.
  • Use a micro-USB cable to connect the mbed 6LoWPAN gateway router to your computer. The computer will list the router as removable storage.
  • The firmware for the gateway is located in the `GW_Binary` folder in the root of this example. Select the binary matching your application bootstrap mode:
  • For the 6LoWPAN ND bootstrap, use `gateway6LoWPANDynamic.bin`.
  • For the Thread bootstrap, use `gatewayThreadDynamic.bin`.

The dynamic binaries use IPv6 autoconfiguration and enable the client to connect to the Connector service. The static binaries create a site-local IPv6 network and packets cannot be routed outside.

  • Copy the gateway binary file to the mbed 6LoWPAN gateway router to flash the device. The device reboots automatically after flashing. If that does not happen, press the Reset button on the board.

You can view debug traces from the gateway with a serial port monitor. The gateway uses baud rate 460800. The gateway IPv6 address is correctly configured when the following trace is visible: `Eth bootstrap ready, IP=XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX`.

Channel settings

The default 2.4GHz channel settings are already defined by the mbed-mesh-api to match the mbed gateway settings. The application can override these settings by adding them to the mbed_app.json file in the main project directory. For example:

    "target_overrides": {
        "*": {
            "mbed-mesh-api.6lowpan-nd-channel-page": 0,
            "mbed-mesh-api.6lowpan-nd-channel": 12,
            "mbed-mesh-api.thread-config-channel-page": 0,
            "mbed-mesh-api.thread-config-channel": 12
        }
    }

For sub-GHz shields (AT86RF212B) use the following overrides, 6LoWPAN ND only:

"mbed-mesh-api.6lowpan-nd-channel-page": 2,
"mbed-mesh-api.6lowpan-nd-channel": 1

For more information about the radio shields, see [the related documentation](docs/radio_module_identify.md). All the configurable settings can be found in the mbed-os-example-client/mbed-os/features/FEATURE_IPV6/mbed-mesh-api/mbed_lib.json file.

Thread-specific settings

With Thread, you can change the operating mode of the client from the default router mode to a sleepy end device by adding the following override to the `mbed_app.json` file:

    "mbed-mesh-api.thread-device-type": "MESH_DEVICE_TYPE_THREAD_SLEEPY_END_DEVICE"

Ethernet settings

For running the example application using Ethernet, you need:

  • An Ethernet cable.
  • An Ethernet connection to the internet.

Wi-Fi settings

The example application uses ESP8266 WiFi Interface for managing the wireless connectivity. To run this application using WiFi, you need:

    "network-interface": {
        "help": "options are ETHERNET,WIFI,MESH_LOWPAN_ND,MESH_THREAD.",
        "value": "WIFI"
    }

Provide your WiFi SSID and password here and leave `\"` in the beginning and end of your SSID and password (as shown in the example below). Otherwise, the example cannot pick up the SSID and password in correct format.

    "wifi-ssid": {
        "help": "WiFi SSID",
        "value": "\"SSID\""
    },
    "wifi-password": {
        "help": "WiFi Password",
        "value": "\"Password\""
    }

IP address setup

This example uses IPv4 to communicate with the mbed Device Connector Server except for 6LoWPAN ND and Thread. The example program should automatically get an IPv4 address from the router when connected over Ethernet.

If your network does not have DHCP enabled, you have to manually assign a static IP address to the board. We recommend having DHCP enabled to make everything run smoothly.

Changing socket type

Your device can connect to mbed Device Connector via UDP or TCP binding mode. The default is UDP. The binding mode cannot be changed in 6LoWPAN ND or Thread mode.

To change the binding mode:

  • In the `simpleclient.h` file, find the parameter `SOCKET_MODE`. The default is `M2MInterface::UDP`.
  • To switch to TCP, change it to `M2MInterface::TCP`.
  • Rebuild and flash the application.

Tip: The instructions in this document remain the same, irrespective of the socket mode you select.

Monitoring the application

The application prints debug messages over the serial port, so you can monitor its activity with a serial port monitor. The application uses baud rate 115200.

SerialPC

After connecting, you should see messages about connecting to mbed Device Connector:

In app_start()
IP address 10.2.15.222
Device name 6868df22-d353-4150-b90a-a878130859d9

When you click the `SW2` button on your board you should see messages about the value changes:

handle_button_click, new value of counter is 1

Testing the application

  • Flash the application.
  • Verify that the registration succeeded. You should see `Registered object successfully!` printed to the serial port.
  • On mbed Device Connector, go to My devices > Connected devices. Your device should be listed here.
  • Press the `SW2` button on the device a number of times (make a note of how many times you did that).
  • Go to Device Connector > API Console.
  • Enter https://api.connector.mbed.com/endpoints/DEVICE_NAME/3200/0/5501 in the URI field and click TEST API. Replace DEVICE_NAME with your actual endpoint name. The device name can be found in the security.h file, see variable MBED_ENDPOINT_NAME or it can be found from the traces.
  • The number of times you pressed SW2 is shown.
  • Press the SW3 button to unregister from mbed Device Connector. You should see Unregistered Object Successfully printed to the serial port and the LED starts blinking. This will also stop your application. Press the `RESET` button to run the program again.

For more methods check the mbed Device Connector Quick Start.

Application resources

The application exposes three resources:

  • 3200/0/5501. Number of presses of SW2 (GET).
  • 3201/0/5850. Blink function, blinks LED1 when executed (POST).
  • 3201/0/5853. Blink pattern, used by the blink function to determine how to blink. In the format of 1000:500:1000:500:1000:500 (PUT).

For information on how to get notifications when resource 1 changes, or how to use resources 2 and 3, take a look at the mbed Device Connector Quick Start.

Building this example

Building with mbed CLI

If you'd like to use mbed CLI to build this, then you should follow the instructions in the Handbook TODO - new link. The instructions here relate to using the developer.mbed.org Online Compiler

If you'd like to use the online Compiler, then you can Import this code into your compiler, select your platform from the top right, compile the code using the compile button, load it onto your board, press the reset button on the board and you code will run. See the client go online!

More instructions for using the mbed Online Compiler can be found at TODO - update this

Committer:
mbed_official
Date:
Tue Jul 17 08:00:07 2018 +0100
Revision:
158:79ba4b42ce83
Parent:
128:86c8e85c0df0
Merge pull request #414 from cmonr/master

Updating mbed-os to mbed-os-5.9.3
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-client

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 21:b88cdeb5b302 1 /*
mbed_official 44:2b472e66a942 2 * Copyright (c) 2015, 2016 ARM Limited. All rights reserved.
mbed_official 21:b88cdeb5b302 3 * SPDX-License-Identifier: Apache-2.0
mbed_official 21:b88cdeb5b302 4 * Licensed under the Apache License, Version 2.0 (the License); you may
mbed_official 21:b88cdeb5b302 5 * not use this file except in compliance with the License.
mbed_official 21:b88cdeb5b302 6 * You may obtain a copy of the License at
mbed_official 21:b88cdeb5b302 7 *
mbed_official 21:b88cdeb5b302 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 21:b88cdeb5b302 9 *
mbed_official 21:b88cdeb5b302 10 * Unless required by applicable law or agreed to in writing, software
mbed_official 21:b88cdeb5b302 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
mbed_official 21:b88cdeb5b302 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 21:b88cdeb5b302 13 * See the License for the specific language governing permissions and
mbed_official 21:b88cdeb5b302 14 * limitations under the License.
mbed_official 21:b88cdeb5b302 15 */
mbed_official 63:c73f78fd7982 16 #define __STDC_FORMAT_MACROS
mbed_official 63:c73f78fd7982 17 #include <inttypes.h>
mbed_official 21:b88cdeb5b302 18 #include <string>
mbed_official 21:b88cdeb5b302 19 #include <sstream>
mbed_official 21:b88cdeb5b302 20 #include <vector>
mbed_official 21:b88cdeb5b302 21 #include "mbed-trace/mbed_trace.h"
mbed_official 21:b88cdeb5b302 22 #include "mbedtls/entropy_poll.h"
mbed_official 21:b88cdeb5b302 23
mbed_official 21:b88cdeb5b302 24 #include "security.h"
mbed_official 21:b88cdeb5b302 25
mbed_official 21:b88cdeb5b302 26 #include "mbed.h"
mbed_official 21:b88cdeb5b302 27
mbed_official 63:c73f78fd7982 28 // easy-connect compliancy, it has 2 sets of wifi pins we have only one
mbed_official 63:c73f78fd7982 29 #define MBED_CONF_APP_ESP8266_TX MBED_CONF_APP_WIFI_TX
mbed_official 63:c73f78fd7982 30 #define MBED_CONF_APP_ESP8266_RX MBED_CONF_APP_WIFI_RX
mbed_official 63:c73f78fd7982 31 #include "easy-connect/easy-connect.h"
mbed_official 21:b88cdeb5b302 32
mbed_official 128:86c8e85c0df0 33 // Should be defined after easy-connect.h
mbed_official 128:86c8e85c0df0 34 #include "simpleclient.h"
mbed_official 128:86c8e85c0df0 35
mbed_official 71:ec259c9b02ea 36 #ifdef TARGET_STM
mbed_official 71:ec259c9b02ea 37 #define RED_LED (LED3)
mbed_official 71:ec259c9b02ea 38 #define GREEN_LED (LED1)
mbed_official 71:ec259c9b02ea 39 #define BLUE_LED (LED2)
mbed_official 117:81e1ff2179d0 40 #define LED_ON (1)
mbed_official 71:ec259c9b02ea 41 #else // !TARGET_STM
mbed_official 71:ec259c9b02ea 42 #define RED_LED (LED1)
mbed_official 71:ec259c9b02ea 43 #define GREEN_LED (LED2)
mbed_official 117:81e1ff2179d0 44 #define BLUE_LED (LED3)
mbed_official 117:81e1ff2179d0 45 #define LED_ON (0)
mbed_official 71:ec259c9b02ea 46 #endif // !TARGET_STM
mbed_official 71:ec259c9b02ea 47 #define LED_OFF (!LED_ON)
mbed_official 71:ec259c9b02ea 48
mbed_official 117:81e1ff2179d0 49 #define BLINK_SIGNAL 0x1
mbed_official 117:81e1ff2179d0 50
mbed_official 21:b88cdeb5b302 51 // Status indication
mbed_official 71:ec259c9b02ea 52 DigitalOut red_led(RED_LED);
mbed_official 71:ec259c9b02ea 53 DigitalOut green_led(GREEN_LED);
mbed_official 71:ec259c9b02ea 54 DigitalOut blue_led(BLUE_LED);
mbed_official 71:ec259c9b02ea 55
mbed_official 21:b88cdeb5b302 56 Ticker status_ticker;
mbed_official 21:b88cdeb5b302 57 void blinky() {
mbed_official 21:b88cdeb5b302 58 green_led = !green_led;
mbed_official 21:b88cdeb5b302 59 }
mbed_official 21:b88cdeb5b302 60
mbed_official 21:b88cdeb5b302 61 // These are example resource values for the Device Object
mbed_official 21:b88cdeb5b302 62 struct MbedClientDevice device = {
mbed_official 21:b88cdeb5b302 63 "Manufacturer_String", // Manufacturer
mbed_official 21:b88cdeb5b302 64 "Type_String", // Type
mbed_official 21:b88cdeb5b302 65 "ModelNumber_String", // ModelNumber
mbed_official 21:b88cdeb5b302 66 "SerialNumber_String" // SerialNumber
mbed_official 21:b88cdeb5b302 67 };
mbed_official 21:b88cdeb5b302 68
mbed_official 21:b88cdeb5b302 69 // Instantiate the class which implements LWM2M Client API (from simpleclient.h)
mbed_official 21:b88cdeb5b302 70 MbedClient mbed_client(device);
mbed_official 21:b88cdeb5b302 71
mbed_official 118:0b784e889605 72 // Set up a button interrupt for user interaction
mbed_official 118:0b784e889605 73 #ifdef MBED_CONF_APP_BUTTON1
mbed_official 118:0b784e889605 74 InterruptIn counter_btn(MBED_CONF_APP_BUTTON1);
mbed_official 118:0b784e889605 75 #endif
mbed_official 21:b88cdeb5b302 76
mbed_official 118:0b784e889605 77
mbed_official 118:0b784e889605 78 /**
mbed_official 118:0b784e889605 79 * User interaction handler / simulator. Sets up physical button handler and a ticker
mbed_official 118:0b784e889605 80 * for regular updates for the resources.
mbed_official 118:0b784e889605 81 *
mbed_official 118:0b784e889605 82 * MBED_CONF_APP_BUTTON1 is mapped to actual button pin the mbed_app.json file, where you need to
mbed_official 118:0b784e889605 83 * specify board-specific value or leave it undefined if the board does not have buttons.
mbed_official 118:0b784e889605 84 */
mbed_official 118:0b784e889605 85 class InteractionProvider {
mbed_official 118:0b784e889605 86
mbed_official 118:0b784e889605 87 public:
mbed_official 118:0b784e889605 88 InteractionProvider(Semaphore& updates_sem) : updates(updates_sem) {
mbed_official 118:0b784e889605 89
mbed_official 118:0b784e889605 90 timer_ticked = false;
mbed_official 118:0b784e889605 91 clicked = false;
mbed_official 118:0b784e889605 92
mbed_official 118:0b784e889605 93 // Set up handler function for the interaction button, if available
mbed_official 118:0b784e889605 94
mbed_official 118:0b784e889605 95 #ifdef MBED_CONF_APP_BUTTON1
mbed_official 118:0b784e889605 96 counter_btn.fall(this, &InteractionProvider::counter_button_handler);
mbed_official 21:b88cdeb5b302 97 #endif
mbed_official 21:b88cdeb5b302 98
mbed_official 118:0b784e889605 99 // Use the counter button handler to send an update of endpoint resource values
mbed_official 118:0b784e889605 100 // to connector every 15 seconds periodically.
mbed_official 118:0b784e889605 101 timer.attach(this, &InteractionProvider::timer_handler, 15.0);
mbed_official 118:0b784e889605 102 }
mbed_official 118:0b784e889605 103
mbed_official 118:0b784e889605 104 // flags for interaction, these are read from outside interrupt context
mbed_official 118:0b784e889605 105 volatile bool timer_ticked;
mbed_official 118:0b784e889605 106 volatile bool clicked;
mbed_official 118:0b784e889605 107
mbed_official 118:0b784e889605 108
mbed_official 118:0b784e889605 109 private:
mbed_official 118:0b784e889605 110
mbed_official 118:0b784e889605 111 void timer_handler() {
mbed_official 118:0b784e889605 112 timer_ticked = true;
mbed_official 118:0b784e889605 113 updates.release();
mbed_official 118:0b784e889605 114 }
mbed_official 118:0b784e889605 115
mbed_official 118:0b784e889605 116 void counter_button_handler() {
mbed_official 118:0b784e889605 117 clicked = true;
mbed_official 118:0b784e889605 118 updates.release();
mbed_official 118:0b784e889605 119 }
mbed_official 118:0b784e889605 120
mbed_official 118:0b784e889605 121 // time-based event source for regular resource updates
mbed_official 118:0b784e889605 122 Ticker timer;
mbed_official 118:0b784e889605 123
mbed_official 118:0b784e889605 124 // Network interaction must be performed outside of interrupt context
mbed_official 118:0b784e889605 125 Semaphore& updates;
mbed_official 118:0b784e889605 126
mbed_official 118:0b784e889605 127 };
mbed_official 118:0b784e889605 128
mbed_official 21:b88cdeb5b302 129 /*
mbed_official 21:b88cdeb5b302 130 * Arguments for running "blink" in it's own thread.
mbed_official 21:b88cdeb5b302 131 */
mbed_official 21:b88cdeb5b302 132 class BlinkArgs {
mbed_official 21:b88cdeb5b302 133 public:
mbed_official 21:b88cdeb5b302 134 BlinkArgs() {
mbed_official 21:b88cdeb5b302 135 clear();
mbed_official 21:b88cdeb5b302 136 }
mbed_official 21:b88cdeb5b302 137 void clear() {
mbed_official 21:b88cdeb5b302 138 position = 0;
mbed_official 21:b88cdeb5b302 139 blink_pattern.clear();
mbed_official 21:b88cdeb5b302 140 }
mbed_official 21:b88cdeb5b302 141 uint16_t position;
mbed_official 21:b88cdeb5b302 142 std::vector<uint32_t> blink_pattern;
mbed_official 21:b88cdeb5b302 143 };
mbed_official 21:b88cdeb5b302 144
mbed_official 21:b88cdeb5b302 145 /*
mbed_official 21:b88cdeb5b302 146 * The Led contains one property (pattern) and a function (blink).
mbed_official 21:b88cdeb5b302 147 * When the function blink is executed, the pattern is read, and the LED
mbed_official 21:b88cdeb5b302 148 * will blink based on the pattern.
mbed_official 21:b88cdeb5b302 149 */
mbed_official 21:b88cdeb5b302 150 class LedResource {
mbed_official 21:b88cdeb5b302 151 public:
mbed_official 21:b88cdeb5b302 152 LedResource() {
mbed_official 21:b88cdeb5b302 153 // create ObjectID with metadata tag of '3201', which is 'digital output'
mbed_official 117:81e1ff2179d0 154 blinky_thread.start(callback(this, &LedResource::do_blink));
mbed_official 21:b88cdeb5b302 155 led_object = M2MInterfaceFactory::create_object("3201");
mbed_official 21:b88cdeb5b302 156 M2MObjectInstance* led_inst = led_object->create_object_instance();
mbed_official 21:b88cdeb5b302 157
mbed_official 21:b88cdeb5b302 158 // 5853 = Multi-state output
mbed_official 21:b88cdeb5b302 159 M2MResource* pattern_res = led_inst->create_dynamic_resource("5853", "Pattern",
mbed_official 21:b88cdeb5b302 160 M2MResourceInstance::STRING, false);
mbed_official 21:b88cdeb5b302 161 // read and write
mbed_official 21:b88cdeb5b302 162 pattern_res->set_operation(M2MBase::GET_PUT_ALLOWED);
mbed_official 21:b88cdeb5b302 163 // set initial pattern (toggle every 200ms. 7 toggles in total)
mbed_official 21:b88cdeb5b302 164 pattern_res->set_value((const uint8_t*)"500:500:500:500:500:500:500", 27);
mbed_official 21:b88cdeb5b302 165
mbed_official 21:b88cdeb5b302 166 // there's not really an execute LWM2M ID that matches... hmm...
mbed_official 21:b88cdeb5b302 167 M2MResource* led_res = led_inst->create_dynamic_resource("5850", "Blink",
mbed_official 21:b88cdeb5b302 168 M2MResourceInstance::OPAQUE, false);
mbed_official 21:b88cdeb5b302 169 // we allow executing a function here...
mbed_official 21:b88cdeb5b302 170 led_res->set_operation(M2MBase::POST_ALLOWED);
mbed_official 21:b88cdeb5b302 171 // when a POST comes in, we want to execute the led_execute_callback
mbed_official 21:b88cdeb5b302 172 led_res->set_execute_function(execute_callback(this, &LedResource::blink));
mbed_official 21:b88cdeb5b302 173 // Completion of execute function can take a time, that's why delayed response is used
mbed_official 21:b88cdeb5b302 174 led_res->set_delayed_response(true);
mbed_official 21:b88cdeb5b302 175 blink_args = new BlinkArgs();
mbed_official 21:b88cdeb5b302 176 }
mbed_official 21:b88cdeb5b302 177
mbed_official 21:b88cdeb5b302 178 ~LedResource() {
mbed_official 21:b88cdeb5b302 179 delete blink_args;
mbed_official 21:b88cdeb5b302 180 }
mbed_official 21:b88cdeb5b302 181
mbed_official 21:b88cdeb5b302 182 M2MObject* get_object() {
mbed_official 21:b88cdeb5b302 183 return led_object;
mbed_official 21:b88cdeb5b302 184 }
mbed_official 21:b88cdeb5b302 185
mbed_official 21:b88cdeb5b302 186 void blink(void *argument) {
mbed_official 21:b88cdeb5b302 187 // read the value of 'Pattern'
mbed_official 21:b88cdeb5b302 188 status_ticker.detach();
mbed_official 71:ec259c9b02ea 189 green_led = LED_OFF;
mbed_official 21:b88cdeb5b302 190
mbed_official 21:b88cdeb5b302 191 M2MObjectInstance* inst = led_object->object_instance();
mbed_official 21:b88cdeb5b302 192 M2MResource* res = inst->resource("5853");
mbed_official 21:b88cdeb5b302 193 // Clear previous blink data
mbed_official 21:b88cdeb5b302 194 blink_args->clear();
mbed_official 21:b88cdeb5b302 195
mbed_official 21:b88cdeb5b302 196 // values in mbed Client are all buffers, and we need a vector of int's
mbed_official 21:b88cdeb5b302 197 uint8_t* buffIn = NULL;
mbed_official 21:b88cdeb5b302 198 uint32_t sizeIn;
mbed_official 21:b88cdeb5b302 199 res->get_value(buffIn, sizeIn);
mbed_official 21:b88cdeb5b302 200
mbed_official 21:b88cdeb5b302 201 // turn the buffer into a string, and initialize a vector<int> on the heap
mbed_official 21:b88cdeb5b302 202 std::string s((char*)buffIn, sizeIn);
mbed_official 21:b88cdeb5b302 203 free(buffIn);
mbed_official 63:c73f78fd7982 204 printf("led_execute_callback pattern=%s\n", s.c_str());
mbed_official 21:b88cdeb5b302 205
mbed_official 21:b88cdeb5b302 206 // our pattern is something like 500:200:500, so parse that
mbed_official 21:b88cdeb5b302 207 std::size_t found = s.find_first_of(":");
mbed_official 21:b88cdeb5b302 208 while (found!=std::string::npos) {
mbed_official 21:b88cdeb5b302 209 blink_args->blink_pattern.push_back(atoi((const char*)s.substr(0,found).c_str()));
mbed_official 21:b88cdeb5b302 210 s = s.substr(found+1);
mbed_official 21:b88cdeb5b302 211 found=s.find_first_of(":");
mbed_official 21:b88cdeb5b302 212 if(found == std::string::npos) {
mbed_official 21:b88cdeb5b302 213 blink_args->blink_pattern.push_back(atoi((const char*)s.c_str()));
mbed_official 21:b88cdeb5b302 214 }
mbed_official 21:b88cdeb5b302 215 }
mbed_official 21:b88cdeb5b302 216 // check if POST contains payload
mbed_official 21:b88cdeb5b302 217 if (argument) {
mbed_official 21:b88cdeb5b302 218 M2MResource::M2MExecuteParameter* param = (M2MResource::M2MExecuteParameter*)argument;
mbed_official 21:b88cdeb5b302 219 String object_name = param->get_argument_object_name();
mbed_official 21:b88cdeb5b302 220 uint16_t object_instance_id = param->get_argument_object_instance_id();
mbed_official 21:b88cdeb5b302 221 String resource_name = param->get_argument_resource_name();
mbed_official 21:b88cdeb5b302 222 int payload_length = param->get_argument_value_length();
mbed_official 110:c6ef55b9498a 223 const uint8_t* payload = param->get_argument_value();
mbed_official 63:c73f78fd7982 224 printf("Resource: %s/%d/%s executed\n", object_name.c_str(), object_instance_id, resource_name.c_str());
mbed_official 63:c73f78fd7982 225 printf("Payload: %.*s\n", payload_length, payload);
mbed_official 21:b88cdeb5b302 226 }
mbed_official 21:b88cdeb5b302 227 // do_blink is called with the vector, and starting at -1
mbed_official 117:81e1ff2179d0 228 blinky_thread.signal_set(BLINK_SIGNAL);
mbed_official 21:b88cdeb5b302 229 }
mbed_official 21:b88cdeb5b302 230
mbed_official 21:b88cdeb5b302 231 private:
mbed_official 21:b88cdeb5b302 232 M2MObject* led_object;
mbed_official 21:b88cdeb5b302 233 Thread blinky_thread;
mbed_official 21:b88cdeb5b302 234 BlinkArgs *blink_args;
mbed_official 21:b88cdeb5b302 235 void do_blink() {
mbed_official 117:81e1ff2179d0 236 for(;;) {
mbed_official 117:81e1ff2179d0 237 blinky_thread.signal_wait(BLINK_SIGNAL);
mbed_official 117:81e1ff2179d0 238 for (;;) {
mbed_official 117:81e1ff2179d0 239 // blink the LED
mbed_official 117:81e1ff2179d0 240 red_led = !red_led;
mbed_official 117:81e1ff2179d0 241 // up the position, if we reached the end of the vector
mbed_official 117:81e1ff2179d0 242 if (blink_args->position >= blink_args->blink_pattern.size()) {
mbed_official 117:81e1ff2179d0 243 // send delayed response after blink is done
mbed_official 117:81e1ff2179d0 244 M2MObjectInstance* inst = led_object->object_instance();
mbed_official 117:81e1ff2179d0 245 M2MResource* led_res = inst->resource("5850");
mbed_official 117:81e1ff2179d0 246 led_res->send_delayed_post_response();
mbed_official 117:81e1ff2179d0 247 red_led = LED_OFF;
mbed_official 117:81e1ff2179d0 248 status_ticker.attach_us(blinky, 250000);
mbed_official 117:81e1ff2179d0 249 break;
mbed_official 117:81e1ff2179d0 250 }
mbed_official 117:81e1ff2179d0 251 // Wait requested time, then continue prosessing the blink pattern from next position.
mbed_official 117:81e1ff2179d0 252 Thread::wait(blink_args->blink_pattern.at(blink_args->position));
mbed_official 117:81e1ff2179d0 253 blink_args->position++;
mbed_official 117:81e1ff2179d0 254 }
mbed_official 21:b88cdeb5b302 255 }
mbed_official 21:b88cdeb5b302 256 }
mbed_official 21:b88cdeb5b302 257 };
mbed_official 21:b88cdeb5b302 258
mbed_official 21:b88cdeb5b302 259 /*
mbed_official 21:b88cdeb5b302 260 * The button contains one property (click count).
mbed_official 21:b88cdeb5b302 261 * When `handle_button_click` is executed, the counter updates.
mbed_official 21:b88cdeb5b302 262 */
mbed_official 21:b88cdeb5b302 263 class ButtonResource {
mbed_official 21:b88cdeb5b302 264 public:
mbed_official 21:b88cdeb5b302 265 ButtonResource(): counter(0) {
mbed_official 21:b88cdeb5b302 266 // create ObjectID with metadata tag of '3200', which is 'digital input'
mbed_official 21:b88cdeb5b302 267 btn_object = M2MInterfaceFactory::create_object("3200");
mbed_official 21:b88cdeb5b302 268 M2MObjectInstance* btn_inst = btn_object->create_object_instance();
mbed_official 21:b88cdeb5b302 269 // create resource with ID '5501', which is digital input counter
mbed_official 21:b88cdeb5b302 270 M2MResource* btn_res = btn_inst->create_dynamic_resource("5501", "Button",
mbed_official 21:b88cdeb5b302 271 M2MResourceInstance::INTEGER, true /* observable */);
mbed_official 21:b88cdeb5b302 272 // we can read this value
mbed_official 21:b88cdeb5b302 273 btn_res->set_operation(M2MBase::GET_ALLOWED);
mbed_official 21:b88cdeb5b302 274 // set initial value (all values in mbed Client are buffers)
mbed_official 21:b88cdeb5b302 275 // to be able to read this data easily in the Connector console, we'll use a string
mbed_official 21:b88cdeb5b302 276 btn_res->set_value((uint8_t*)"0", 1);
mbed_official 21:b88cdeb5b302 277 }
mbed_official 21:b88cdeb5b302 278
mbed_official 21:b88cdeb5b302 279 ~ButtonResource() {
mbed_official 21:b88cdeb5b302 280 }
mbed_official 21:b88cdeb5b302 281
mbed_official 21:b88cdeb5b302 282 M2MObject* get_object() {
mbed_official 21:b88cdeb5b302 283 return btn_object;
mbed_official 21:b88cdeb5b302 284 }
mbed_official 21:b88cdeb5b302 285
mbed_official 21:b88cdeb5b302 286 /*
mbed_official 21:b88cdeb5b302 287 * When you press the button, we read the current value of the click counter
mbed_official 21:b88cdeb5b302 288 * from mbed Device Connector, then up the value with one.
mbed_official 21:b88cdeb5b302 289 */
mbed_official 21:b88cdeb5b302 290 void handle_button_click() {
mbed_official 65:ea64e559b7d3 291 if (mbed_client.register_successful()) {
mbed_official 65:ea64e559b7d3 292 M2MObjectInstance* inst = btn_object->object_instance();
mbed_official 65:ea64e559b7d3 293 M2MResource* res = inst->resource("5501");
mbed_official 21:b88cdeb5b302 294
mbed_official 65:ea64e559b7d3 295 // up counter
mbed_official 65:ea64e559b7d3 296 counter++;
mbed_official 65:ea64e559b7d3 297 printf("handle_button_click, new value of counter is %d\n", counter);
mbed_official 65:ea64e559b7d3 298 // serialize the value of counter as a string, and tell connector
mbed_official 65:ea64e559b7d3 299 char buffer[20];
mbed_official 65:ea64e559b7d3 300 int size = sprintf(buffer,"%d",counter);
mbed_official 65:ea64e559b7d3 301 res->set_value((uint8_t*)buffer, size);
mbed_official 65:ea64e559b7d3 302 } else {
mbed_official 65:ea64e559b7d3 303 printf("simulate button_click, device not registered\n");
mbed_official 65:ea64e559b7d3 304 }
mbed_official 21:b88cdeb5b302 305 }
mbed_official 21:b88cdeb5b302 306
mbed_official 21:b88cdeb5b302 307 private:
mbed_official 21:b88cdeb5b302 308 M2MObject* btn_object;
mbed_official 21:b88cdeb5b302 309 uint16_t counter;
mbed_official 21:b88cdeb5b302 310 };
mbed_official 21:b88cdeb5b302 311
mbed_official 118:0b784e889605 312 /*
mbed_official 118:0b784e889605 313 * The timer contains one property: counter.
mbed_official 118:0b784e889605 314 * When `handle_timer_tick` is executed, the counter updates.
mbed_official 118:0b784e889605 315 */
mbed_official 118:0b784e889605 316 class TimerResource {
mbed_official 118:0b784e889605 317 public:
mbed_official 118:0b784e889605 318 TimerResource(): counter(0) {
mbed_official 118:0b784e889605 319 // create ObjectID with metadata tag of '3200', which is 'digital input'
mbed_official 118:0b784e889605 320 btn_object = M2MInterfaceFactory::create_object("3200");
mbed_official 118:0b784e889605 321 M2MObjectInstance* btn_inst = btn_object->create_object_instance();
mbed_official 118:0b784e889605 322 // create resource with ID '5502', which is digital input counter
mbed_official 118:0b784e889605 323 M2MResource* btn_res = btn_inst->create_dynamic_resource("5502", "Timer",
mbed_official 118:0b784e889605 324 M2MResourceInstance::INTEGER, true /* observable */);
mbed_official 118:0b784e889605 325 // we can read this value
mbed_official 118:0b784e889605 326 btn_res->set_operation(M2MBase::GET_ALLOWED);
mbed_official 118:0b784e889605 327 // set initial value (all values in mbed Client are buffers)
mbed_official 118:0b784e889605 328 // to be able to read this data easily in the Connector console, we'll use a string
mbed_official 118:0b784e889605 329 btn_res->set_value((uint8_t*)"0", 1);
mbed_official 118:0b784e889605 330 }
mbed_official 118:0b784e889605 331
mbed_official 118:0b784e889605 332 ~TimerResource() {
mbed_official 118:0b784e889605 333 }
mbed_official 118:0b784e889605 334
mbed_official 118:0b784e889605 335 M2MObject* get_object() {
mbed_official 118:0b784e889605 336 return btn_object;
mbed_official 118:0b784e889605 337 }
mbed_official 118:0b784e889605 338
mbed_official 118:0b784e889605 339 /*
mbed_official 118:0b784e889605 340 * When the timer ticks, we read the current value of the click counter
mbed_official 118:0b784e889605 341 * from mbed Device Connector, then up the value with one.l
mbed_official 118:0b784e889605 342 */
mbed_official 118:0b784e889605 343 void handle_timer_tick() {
mbed_official 118:0b784e889605 344 if (mbed_client.register_successful()) {
mbed_official 118:0b784e889605 345 M2MObjectInstance* inst = btn_object->object_instance();
mbed_official 118:0b784e889605 346 M2MResource* res = inst->resource("5502");
mbed_official 118:0b784e889605 347
mbed_official 118:0b784e889605 348 // up counter
mbed_official 118:0b784e889605 349 counter++;
mbed_official 118:0b784e889605 350 printf("handle_timer_click, new value of counter is %d\n", counter);
mbed_official 118:0b784e889605 351 // serialize the value of counter as a string, and tell connector
mbed_official 118:0b784e889605 352 char buffer[20];
mbed_official 118:0b784e889605 353 int size = sprintf(buffer,"%d",counter);
mbed_official 118:0b784e889605 354 res->set_value((uint8_t*)buffer, size);
mbed_official 118:0b784e889605 355 } else {
mbed_official 118:0b784e889605 356 printf("handle_timer_tick, device not registered\n");
mbed_official 118:0b784e889605 357 }
mbed_official 118:0b784e889605 358 }
mbed_official 118:0b784e889605 359
mbed_official 118:0b784e889605 360 private:
mbed_official 118:0b784e889605 361 M2MObject* btn_object;
mbed_official 118:0b784e889605 362 uint16_t counter;
mbed_official 118:0b784e889605 363 };
mbed_official 118:0b784e889605 364
mbed_official 118:0b784e889605 365
mbed_official 118:0b784e889605 366
mbed_official 21:b88cdeb5b302 367 class BigPayloadResource {
mbed_official 21:b88cdeb5b302 368 public:
mbed_official 21:b88cdeb5b302 369 BigPayloadResource() {
mbed_official 21:b88cdeb5b302 370 big_payload = M2MInterfaceFactory::create_object("1000");
mbed_official 21:b88cdeb5b302 371 M2MObjectInstance* payload_inst = big_payload->create_object_instance();
mbed_official 21:b88cdeb5b302 372 M2MResource* payload_res = payload_inst->create_dynamic_resource("1", "BigData",
mbed_official 21:b88cdeb5b302 373 M2MResourceInstance::STRING, true /* observable */);
mbed_official 21:b88cdeb5b302 374 payload_res->set_operation(M2MBase::GET_PUT_ALLOWED);
mbed_official 21:b88cdeb5b302 375 payload_res->set_value((uint8_t*)"0", 1);
mbed_official 21:b88cdeb5b302 376 payload_res->set_incoming_block_message_callback(
mbed_official 21:b88cdeb5b302 377 incoming_block_message_callback(this, &BigPayloadResource::block_message_received));
mbed_official 21:b88cdeb5b302 378 payload_res->set_outgoing_block_message_callback(
mbed_official 21:b88cdeb5b302 379 outgoing_block_message_callback(this, &BigPayloadResource::block_message_requested));
mbed_official 21:b88cdeb5b302 380 }
mbed_official 21:b88cdeb5b302 381
mbed_official 21:b88cdeb5b302 382 M2MObject* get_object() {
mbed_official 21:b88cdeb5b302 383 return big_payload;
mbed_official 21:b88cdeb5b302 384 }
mbed_official 21:b88cdeb5b302 385
mbed_official 21:b88cdeb5b302 386 void block_message_received(M2MBlockMessage *argument) {
mbed_official 21:b88cdeb5b302 387 if (argument) {
mbed_official 21:b88cdeb5b302 388 if (M2MBlockMessage::ErrorNone == argument->error_code()) {
mbed_official 21:b88cdeb5b302 389 if (argument->is_last_block()) {
mbed_official 63:c73f78fd7982 390 printf("Last block received\n");
mbed_official 21:b88cdeb5b302 391 }
mbed_official 63:c73f78fd7982 392 printf("Block number: %d\n", argument->block_number());
mbed_official 21:b88cdeb5b302 393 // First block received
mbed_official 21:b88cdeb5b302 394 if (argument->block_number() == 0) {
mbed_official 21:b88cdeb5b302 395 // Store block
mbed_official 21:b88cdeb5b302 396 // More blocks coming
mbed_official 21:b88cdeb5b302 397 } else {
mbed_official 21:b88cdeb5b302 398 // Store blocks
mbed_official 21:b88cdeb5b302 399 }
mbed_official 21:b88cdeb5b302 400 } else {
mbed_official 63:c73f78fd7982 401 printf("Error when receiving block message! - EntityTooLarge\n");
mbed_official 21:b88cdeb5b302 402 }
mbed_official 63:c73f78fd7982 403 printf("Total message size: %" PRIu32 "\n", argument->total_message_size());
mbed_official 21:b88cdeb5b302 404 }
mbed_official 21:b88cdeb5b302 405 }
mbed_official 21:b88cdeb5b302 406
mbed_official 21:b88cdeb5b302 407 void block_message_requested(const String& resource, uint8_t *&/*data*/, uint32_t &/*len*/) {
mbed_official 63:c73f78fd7982 408 printf("GET request received for resource: %s\n", resource.c_str());
mbed_official 21:b88cdeb5b302 409 // Copy data and length to coap response
mbed_official 21:b88cdeb5b302 410 }
mbed_official 21:b88cdeb5b302 411
mbed_official 21:b88cdeb5b302 412 private:
mbed_official 21:b88cdeb5b302 413 M2MObject* big_payload;
mbed_official 21:b88cdeb5b302 414 };
mbed_official 21:b88cdeb5b302 415
mbed_official 21:b88cdeb5b302 416
mbed_official 21:b88cdeb5b302 417
mbed_official 21:b88cdeb5b302 418
mbed_official 115:45399116b171 419 // debug printf function
mbed_official 115:45399116b171 420 void trace_printer(const char* str) {
mbed_official 115:45399116b171 421 printf("%s\r\n", str);
mbed_official 115:45399116b171 422 }
mbed_official 115:45399116b171 423
mbed_official 21:b88cdeb5b302 424 // Entry point to the program
mbed_official 21:b88cdeb5b302 425 int main() {
mbed_official 21:b88cdeb5b302 426
mbed_official 21:b88cdeb5b302 427 unsigned int seed;
mbed_official 21:b88cdeb5b302 428 size_t len;
mbed_official 21:b88cdeb5b302 429
mbed_official 21:b88cdeb5b302 430 #ifdef MBEDTLS_ENTROPY_HARDWARE_ALT
mbed_official 21:b88cdeb5b302 431 // Used to randomize source port
mbed_official 21:b88cdeb5b302 432 mbedtls_hardware_poll(NULL, (unsigned char *) &seed, sizeof seed, &len);
mbed_official 21:b88cdeb5b302 433
mbed_official 21:b88cdeb5b302 434 #elif defined MBEDTLS_TEST_NULL_ENTROPY
mbed_official 21:b88cdeb5b302 435
mbed_official 21:b88cdeb5b302 436 #warning "mbedTLS security feature is disabled. Connection will not be secure !! Implement proper hardware entropy for your selected hardware."
mbed_official 21:b88cdeb5b302 437 // Used to randomize source port
mbed_official 21:b88cdeb5b302 438 mbedtls_null_entropy_poll( NULL,(unsigned char *) &seed, sizeof seed, &len);
mbed_official 21:b88cdeb5b302 439
mbed_official 21:b88cdeb5b302 440 #else
mbed_official 21:b88cdeb5b302 441
mbed_official 21:b88cdeb5b302 442 #error "This hardware does not have entropy, endpoint will not register to Connector.\
mbed_official 21:b88cdeb5b302 443 You need to enable NULL ENTROPY for your application, but if this configuration change is made then no security is offered by mbed TLS.\
mbed_official 21:b88cdeb5b302 444 Add MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES and MBEDTLS_TEST_NULL_ENTROPY in mbed_app.json macros to register your endpoint."
mbed_official 21:b88cdeb5b302 445
mbed_official 21:b88cdeb5b302 446 #endif
mbed_official 21:b88cdeb5b302 447
mbed_official 21:b88cdeb5b302 448 srand(seed);
mbed_official 71:ec259c9b02ea 449 red_led = LED_OFF;
mbed_official 71:ec259c9b02ea 450 blue_led = LED_OFF;
mbed_official 63:c73f78fd7982 451
mbed_official 21:b88cdeb5b302 452 status_ticker.attach_us(blinky, 250000);
mbed_official 21:b88cdeb5b302 453 // Keep track of the main thread
mbed_official 118:0b784e889605 454 osThreadId mainThread = osThreadGetId();
mbed_official 21:b88cdeb5b302 455
mbed_official 87:5092f48bb68c 456 printf("\nStarting mbed Client example\n");
mbed_official 21:b88cdeb5b302 457
mbed_official 21:b88cdeb5b302 458 mbed_trace_init();
mbed_official 115:45399116b171 459 mbed_trace_print_function_set(trace_printer);
mbed_official 115:45399116b171 460 mbed_trace_config_set(TRACE_MODE_COLOR | TRACE_ACTIVE_LEVEL_INFO | TRACE_CARRIAGE_RETURN);
mbed_official 44:2b472e66a942 461
mbed_official 63:c73f78fd7982 462 NetworkInterface* network = easy_connect(true);
mbed_official 63:c73f78fd7982 463 if(network == NULL) {
mbed_official 63:c73f78fd7982 464 printf("\nConnection to Network Failed - exiting application...\n");
mbed_official 63:c73f78fd7982 465 return -1;
mbed_official 21:b88cdeb5b302 466 }
mbed_official 21:b88cdeb5b302 467
mbed_official 118:0b784e889605 468 // we create our button, timer and LED resources
mbed_official 21:b88cdeb5b302 469 ButtonResource button_resource;
mbed_official 21:b88cdeb5b302 470 LedResource led_resource;
mbed_official 21:b88cdeb5b302 471 BigPayloadResource big_payload_resource;
mbed_official 118:0b784e889605 472 TimerResource timer_resource;
mbed_official 21:b88cdeb5b302 473
mbed_official 118:0b784e889605 474 // Network interaction must be performed outside of interrupt context
mbed_official 118:0b784e889605 475 Semaphore updates(0);
mbed_official 118:0b784e889605 476
mbed_official 118:0b784e889605 477 InteractionProvider interaction_provider(updates);
mbed_official 118:0b784e889605 478
mbed_official 21:b88cdeb5b302 479
mbed_official 21:b88cdeb5b302 480 // Create endpoint interface to manage register and unregister
mbed_official 63:c73f78fd7982 481 mbed_client.create_interface(MBED_SERVER_ADDRESS, network);
mbed_official 21:b88cdeb5b302 482
mbed_official 21:b88cdeb5b302 483 // Create Objects of varying types, see simpleclient.h for more details on implementation.
mbed_official 21:b88cdeb5b302 484 M2MSecurity* register_object = mbed_client.create_register_object(); // server object specifying connector info
mbed_official 21:b88cdeb5b302 485 M2MDevice* device_object = mbed_client.create_device_object(); // device resources object
mbed_official 21:b88cdeb5b302 486
mbed_official 21:b88cdeb5b302 487 // Create list of Objects to register
mbed_official 21:b88cdeb5b302 488 M2MObjectList object_list;
mbed_official 21:b88cdeb5b302 489
mbed_official 21:b88cdeb5b302 490 // Add objects to list
mbed_official 21:b88cdeb5b302 491 object_list.push_back(device_object);
mbed_official 21:b88cdeb5b302 492 object_list.push_back(button_resource.get_object());
mbed_official 21:b88cdeb5b302 493 object_list.push_back(led_resource.get_object());
mbed_official 21:b88cdeb5b302 494 object_list.push_back(big_payload_resource.get_object());
mbed_official 118:0b784e889605 495 object_list.push_back(timer_resource.get_object());
mbed_official 21:b88cdeb5b302 496
mbed_official 21:b88cdeb5b302 497 // Set endpoint registration object
mbed_official 21:b88cdeb5b302 498 mbed_client.set_register_object(register_object);
mbed_official 21:b88cdeb5b302 499
mbed_official 21:b88cdeb5b302 500 // Register with mbed Device Connector
mbed_official 21:b88cdeb5b302 501 mbed_client.test_register(register_object, object_list);
mbed_official 118:0b784e889605 502 volatile bool registered = true;
mbed_official 21:b88cdeb5b302 503
mbed_official 21:b88cdeb5b302 504 while (true) {
mbed_official 21:b88cdeb5b302 505 updates.wait(25000);
mbed_official 21:b88cdeb5b302 506 if(registered) {
mbed_official 118:0b784e889605 507 if(!interaction_provider.clicked) {
mbed_official 21:b88cdeb5b302 508 mbed_client.test_update_register();
mbed_official 21:b88cdeb5b302 509 }
mbed_official 21:b88cdeb5b302 510 }else {
mbed_official 21:b88cdeb5b302 511 break;
mbed_official 21:b88cdeb5b302 512 }
mbed_official 118:0b784e889605 513 if(interaction_provider.clicked) {
mbed_official 118:0b784e889605 514 interaction_provider.clicked = false;
mbed_official 21:b88cdeb5b302 515 button_resource.handle_button_click();
mbed_official 21:b88cdeb5b302 516 }
mbed_official 118:0b784e889605 517 if(interaction_provider.timer_ticked) {
mbed_official 118:0b784e889605 518 interaction_provider.timer_ticked = false;
mbed_official 118:0b784e889605 519 timer_resource.handle_timer_tick();
mbed_official 118:0b784e889605 520 }
mbed_official 21:b88cdeb5b302 521 }
mbed_official 21:b88cdeb5b302 522
mbed_official 21:b88cdeb5b302 523 mbed_client.test_unregister();
mbed_official 21:b88cdeb5b302 524 status_ticker.detach();
mbed_official 21:b88cdeb5b302 525 }