Mbed Client sample for GR-LYCHEE where ZXing is incorporated.

Dependencies:   DisplayApp AsciiFont

Fork of GR-PEACH_mbed-os-client-ZXingSample by Renesas

Overview

This sample program shows how to use mbed Client together with ZXing which is an open-source, multi-format 1D/2D barcode image processing library. For more info on ZXing, please refer to https://github.com/zxing/zxing.

Required hardware

Application setup

  1. Select the connection type. For details, please refer to the following wiki:
    https://os.mbed.com/users/1050186/code/GR-LYCHEE_mbed-os-client-ZXingSample/wiki/Connection-type.
  2. Set the client credentials. For details, please refer to the following wiki:
    https://os.mbed.com/users/1050186/code/GR-LYCHEE_mbed-os-client-ZXingSample/wiki/Client-credentials.
  3. Change Wifi settings. For details, please refer to the following wiki:
    https://os.mbed.com/users/1050186/code/GR-LYCHEE_mbed-os-client-ZXingSample/wiki/Wifi-settings.

Building the example

To build this example:

  1. Import this example onto mbed Compiler.
  2. Configure the example in accordance with Application setup.
  3. Compile the example on mbed Compiler and download the resultant binary file.
  4. Plug the micro-USB cable into the OpenSDA port which lies on the next to the RESET button.
  5. Copy the binary previously downloaded to your PC to GR-LYCHEE to flash this example. When the copy is successfully completed, the board is ready to work.
  6. Press the RESET button on the board to run the example.
  7. For verification, please refer to the following wiki:
    https://os.mbed.com/users/1050186/code/GR-LYCHEE_mbed-os-client-ZXingSample/wiki/Monitoring-the-application.

Application resources

This example exposes four resources listed below:

  1. 3202/0/5700. Decode result of barcode data input from camera (GET).
  2. 3201/0/5850. Blink function, blinks LED when executed (POST).
  3. 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).
  4. 3201/0/5855. Blink color, used by the blink function. Any of green, yellow, orange and red is acceptable (PUT).
Committer:
1050186
Date:
Thu Dec 13 06:59:14 2018 +0000
Revision:
21:ac3a0d5b2c5d
Parent:
20:d4695f4ddc8d
Modify regular blink's color.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 0:eb73febb2bba 1 /*
dkato 2:6ec5c1c1d41c 2 * Copyright (c) 2015, 2016 ARM Limited. All rights reserved.
<> 0:eb73febb2bba 3 * SPDX-License-Identifier: Apache-2.0
<> 0:eb73febb2bba 4 * Licensed under the Apache License, Version 2.0 (the License); you may
<> 0:eb73febb2bba 5 * not use this file except in compliance with the License.
<> 0:eb73febb2bba 6 * You may obtain a copy of the License at
<> 0:eb73febb2bba 7 *
<> 0:eb73febb2bba 8 * http://www.apache.org/licenses/LICENSE-2.0
<> 0:eb73febb2bba 9 *
<> 0:eb73febb2bba 10 * Unless required by applicable law or agreed to in writing, software
<> 0:eb73febb2bba 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
<> 0:eb73febb2bba 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 0:eb73febb2bba 13 * See the License for the specific language governing permissions and
<> 0:eb73febb2bba 14 * limitations under the License.
<> 0:eb73febb2bba 15 */
dkato 2:6ec5c1c1d41c 16 #include "mbed-trace/mbed_trace.h"
dkato 2:6ec5c1c1d41c 17 #include "mbed.h"
dkato 2:6ec5c1c1d41c 18 #include "zxing_main.h"
dkato 2:6ec5c1c1d41c 19
dkato 2:6ec5c1c1d41c 20 // Network interaction must be performed outside of interrupt context
dkato 2:6ec5c1c1d41c 21 osThreadId mainThread;
dkato 2:6ec5c1c1d41c 22
dkato 2:6ec5c1c1d41c 23 #define NO_CONNECT (-1)
dkato 2:6ec5c1c1d41c 24
dkato 2:6ec5c1c1d41c 25 #if MBED_CONF_APP_NETWORK_INTERFACE == NO_CONNECT
dkato 2:6ec5c1c1d41c 26
dkato 2:6ec5c1c1d41c 27 static void callback_zxing(char * addr, int size) {
dkato 2:6ec5c1c1d41c 28 printf("%s\r\n", addr);
dkato 2:6ec5c1c1d41c 29 }
dkato 2:6ec5c1c1d41c 30
dkato 2:6ec5c1c1d41c 31 // Entry point to the program
dkato 2:6ec5c1c1d41c 32 int main() {
dkato 2:6ec5c1c1d41c 33 // Keep track of the main thread
dkato 2:6ec5c1c1d41c 34 mainThread = osThreadGetId();
dkato 2:6ec5c1c1d41c 35 printf("no connect\n");
dkato 2:6ec5c1c1d41c 36 mbed_trace_init();
dkato 2:6ec5c1c1d41c 37 zxing_init(&callback_zxing);
dkato 2:6ec5c1c1d41c 38
dkato 2:6ec5c1c1d41c 39 while (1) {
dkato 2:6ec5c1c1d41c 40 zxing_loop();
dkato 2:6ec5c1c1d41c 41 Thread::wait(5);
dkato 2:6ec5c1c1d41c 42 }
dkato 2:6ec5c1c1d41c 43 }
dkato 2:6ec5c1c1d41c 44
dkato 2:6ec5c1c1d41c 45 #else // MBED_CONF_APP_NETWORK_INTERFACE != NO_CONNECT
dkato 2:6ec5c1c1d41c 46
dkato 2:6ec5c1c1d41c 47 #define __STDC_FORMAT_MACROS
1050186 12:7a199eff6988 48 #include <inttypes.h>
<> 0:eb73febb2bba 49 #include <string>
<> 0:eb73febb2bba 50 #include <sstream>
<> 0:eb73febb2bba 51 #include <vector>
1050186 12:7a199eff6988 52 #include "mbed-trace/mbed_trace.h"
1050186 12:7a199eff6988 53 #include "mbedtls/entropy_poll.h"
1050186 12:7a199eff6988 54
<> 0:eb73febb2bba 55 #include "security.h"
1050186 12:7a199eff6988 56
1050186 12:7a199eff6988 57 #include "mbed.h"
<> 0:eb73febb2bba 58
dkato 2:6ec5c1c1d41c 59 // easy-connect compliancy, it has 2 sets of wifi pins we have only one
dkato 2:6ec5c1c1d41c 60 #define MBED_CONF_APP_ESP8266_TX MBED_CONF_APP_WIFI_TX
dkato 2:6ec5c1c1d41c 61 #define MBED_CONF_APP_ESP8266_RX MBED_CONF_APP_WIFI_RX
1050186 12:7a199eff6988 62 #include "easy-connect/easy-connect.h"
1050186 12:7a199eff6988 63
1050186 12:7a199eff6988 64 // Should be defined after easy-connect.h
1050186 12:7a199eff6988 65 #include "simpleclient.h"
1050186 12:7a199eff6988 66
1050186 12:7a199eff6988 67 #ifdef TARGET_STM
1050186 20:d4695f4ddc8d 68 #define RED_LED (LED3)
1050186 20:d4695f4ddc8d 69 #define GREEN_LED (LED1)
1050186 20:d4695f4ddc8d 70 #define BLUE_LED (LED2)
1050186 20:d4695f4ddc8d 71 #define LED_ON (1)
1050186 20:d4695f4ddc8d 72 #elif TARGET_RZ_A1H
1050186 20:d4695f4ddc8d 73 #define RED_LED (LED1)
1050186 20:d4695f4ddc8d 74 #define GREEN_LED (LED2)
1050186 20:d4695f4ddc8d 75 #define BLUE_LED (LED3)
1050186 21:ac3a0d5b2c5d 76 #define USER_LED (LED4)
1050186 20:d4695f4ddc8d 77 #define LED_ON (1)
1050186 12:7a199eff6988 78 #elif TARGET_GR_LYCHEE
1050186 20:d4695f4ddc8d 79 #define GREEN_LED (LED1)
1050186 20:d4695f4ddc8d 80 #define YELLOW_LED (LED2)
1050186 20:d4695f4ddc8d 81 #define ORANGE_LED (LED3)
1050186 20:d4695f4ddc8d 82 #define RED_LED (LED4)
1050186 20:d4695f4ddc8d 83 #define LED_ON (1)
1050186 12:7a199eff6988 84 #else
1050186 20:d4695f4ddc8d 85 #define RED_LED (LED1)
1050186 20:d4695f4ddc8d 86 #define GREEN_LED (LED2)
1050186 20:d4695f4ddc8d 87 #define BLUE_LED (LED3)
1050186 20:d4695f4ddc8d 88 #define LED_ON (0)
1050186 12:7a199eff6988 89 #endif
1050186 12:7a199eff6988 90 #define LED_OFF (!LED_ON)
1050186 12:7a199eff6988 91
1050186 12:7a199eff6988 92 #define BLINK_SIGNAL 0x1
1050186 12:7a199eff6988 93
1050186 12:7a199eff6988 94 // Status indication
1050186 12:7a199eff6988 95 DigitalOut red_led(RED_LED);
1050186 12:7a199eff6988 96 DigitalOut green_led(GREEN_LED);
1050186 21:ac3a0d5b2c5d 97 #ifdef TARGET_RZ_A1H
1050186 21:ac3a0d5b2c5d 98 DigitalOut blue_led(BLUE_LED);
1050186 21:ac3a0d5b2c5d 99 DigitalOut user_led(USER_LED);
1050186 21:ac3a0d5b2c5d 100 #elif TARGET_GR_LYCHEE
1050186 12:7a199eff6988 101 DigitalOut yellow_led(YELLOW_LED);
1050186 12:7a199eff6988 102 DigitalOut orange_led(ORANGE_LED);
1050186 12:7a199eff6988 103 #else
1050186 12:7a199eff6988 104 DigitalOut blue_led(BLUE_LED);
1050186 12:7a199eff6988 105 #endif
1050186 12:7a199eff6988 106
1050186 12:7a199eff6988 107 Ticker status_ticker;
1050186 12:7a199eff6988 108 void blinky() {
1050186 21:ac3a0d5b2c5d 109 #ifdef TARGET_RZ_A1H
1050186 21:ac3a0d5b2c5d 110 user_led = !user_led;
1050186 20:d4695f4ddc8d 111 #else
1050186 12:7a199eff6988 112 green_led = !green_led;
1050186 20:d4695f4ddc8d 113 #endif
1050186 12:7a199eff6988 114 }
<> 0:eb73febb2bba 115
<> 0:eb73febb2bba 116 // These are example resource values for the Device Object
<> 0:eb73febb2bba 117 struct MbedClientDevice device = {
<> 0:eb73febb2bba 118 "Manufacturer_String", // Manufacturer
<> 0:eb73febb2bba 119 "Type_String", // Type
<> 0:eb73febb2bba 120 "ModelNumber_String", // ModelNumber
<> 0:eb73febb2bba 121 "SerialNumber_String" // SerialNumber
<> 0:eb73febb2bba 122 };
<> 0:eb73febb2bba 123
<> 0:eb73febb2bba 124 // Instantiate the class which implements LWM2M Client API (from simpleclient.h)
<> 0:eb73febb2bba 125 MbedClient mbed_client(device);
<> 0:eb73febb2bba 126
1050186 12:7a199eff6988 127 // Set up a button interrupt for user interaction
1050186 12:7a199eff6988 128 #ifdef MBED_CONF_APP_BUTTON1
1050186 12:7a199eff6988 129 InterruptIn counter_btn(MBED_CONF_APP_BUTTON1);
1050186 12:7a199eff6988 130 #endif
1050186 12:7a199eff6988 131
1050186 12:7a199eff6988 132
1050186 12:7a199eff6988 133 /**
1050186 12:7a199eff6988 134 * User interaction handler / simulator. Sets up physical button handler and a ticker
1050186 12:7a199eff6988 135 * for regular updates for the resources.
1050186 12:7a199eff6988 136 *
1050186 12:7a199eff6988 137 * MBED_CONF_APP_BUTTON1 is mapped to actual button pin the mbed_app.json file, where you need to
1050186 12:7a199eff6988 138 * specify board-specific value or leave it undefined if the board does not have buttons.
1050186 12:7a199eff6988 139 */
1050186 12:7a199eff6988 140 class InteractionProvider {
1050186 12:7a199eff6988 141
1050186 12:7a199eff6988 142 public:
1050186 12:7a199eff6988 143 InteractionProvider(Semaphore& updates_sem) : updates(updates_sem) {
1050186 12:7a199eff6988 144
1050186 12:7a199eff6988 145 timer_ticked = false;
1050186 12:7a199eff6988 146 clicked = false;
1050186 12:7a199eff6988 147
1050186 12:7a199eff6988 148 // Set up handler function for the interaction button, if available
1050186 12:7a199eff6988 149
1050186 12:7a199eff6988 150 #ifdef MBED_CONF_APP_BUTTON1
1050186 12:7a199eff6988 151 counter_btn.fall(this, &InteractionProvider::counter_button_handler);
1050186 6:4e43b6f8f772 152 #endif
1050186 12:7a199eff6988 153
1050186 12:7a199eff6988 154 // Use the counter button handler to send an update of endpoint resource values
1050186 12:7a199eff6988 155 // to connector every 15 seconds periodically.
1050186 12:7a199eff6988 156 timer.attach(this, &InteractionProvider::timer_handler, 15.0);
1050186 12:7a199eff6988 157 }
1050186 12:7a199eff6988 158
1050186 12:7a199eff6988 159 // flags for interaction, these are read from outside interrupt context
1050186 12:7a199eff6988 160 volatile bool timer_ticked;
1050186 12:7a199eff6988 161 volatile bool clicked;
1050186 12:7a199eff6988 162
1050186 12:7a199eff6988 163
1050186 12:7a199eff6988 164 private:
1050186 12:7a199eff6988 165
1050186 12:7a199eff6988 166 void timer_handler() {
1050186 12:7a199eff6988 167 timer_ticked = true;
1050186 12:7a199eff6988 168 updates.release();
1050186 12:7a199eff6988 169 }
1050186 12:7a199eff6988 170
1050186 12:7a199eff6988 171 void counter_button_handler() {
1050186 12:7a199eff6988 172 clicked = true;
1050186 12:7a199eff6988 173 updates.release();
1050186 12:7a199eff6988 174 }
1050186 12:7a199eff6988 175
1050186 12:7a199eff6988 176 // time-based event source for regular resource updates
1050186 12:7a199eff6988 177 Ticker timer;
1050186 12:7a199eff6988 178
1050186 12:7a199eff6988 179 // Network interaction must be performed outside of interrupt context
1050186 12:7a199eff6988 180 Semaphore& updates;
1050186 12:7a199eff6988 181
1050186 12:7a199eff6988 182 };
1050186 12:7a199eff6988 183
1050186 12:7a199eff6988 184 /*
1050186 12:7a199eff6988 185 * Arguments for running "blink" in it's own thread.
1050186 12:7a199eff6988 186 */
1050186 12:7a199eff6988 187 class BlinkArgs {
1050186 12:7a199eff6988 188 public:
1050186 12:7a199eff6988 189 BlinkArgs() {
1050186 12:7a199eff6988 190 clear();
1050186 12:7a199eff6988 191 }
1050186 12:7a199eff6988 192 void clear() {
1050186 12:7a199eff6988 193 position = 0;
1050186 12:7a199eff6988 194 blink_pattern.clear();
1050186 12:7a199eff6988 195 }
1050186 12:7a199eff6988 196 uint16_t position;
1050186 12:7a199eff6988 197 std::vector<uint32_t> blink_pattern;
1050186 12:7a199eff6988 198 };
1050186 12:7a199eff6988 199
<> 0:eb73febb2bba 200 /*
<> 0:eb73febb2bba 201 * The Led contains one property (pattern) and a function (blink).
<> 0:eb73febb2bba 202 * When the function blink is executed, the pattern is read, and the LED
<> 0:eb73febb2bba 203 * will blink based on the pattern.
<> 0:eb73febb2bba 204 */
<> 0:eb73febb2bba 205 class LedResource {
<> 0:eb73febb2bba 206 public:
<> 0:eb73febb2bba 207 LedResource() {
<> 0:eb73febb2bba 208 // create ObjectID with metadata tag of '3201', which is 'digital output'
1050186 12:7a199eff6988 209 // blinky_thread.start(callback(this, &LedResource::do_blink));
<> 0:eb73febb2bba 210 led_object = M2MInterfaceFactory::create_object("3201");
<> 0:eb73febb2bba 211 M2MObjectInstance* led_inst = led_object->create_object_instance();
<> 0:eb73febb2bba 212
<> 0:eb73febb2bba 213 // 5855 = Multi-state output
<> 0:eb73febb2bba 214 M2MResource* color_res = led_inst->create_dynamic_resource("5855", "Color",
<> 0:eb73febb2bba 215 M2MResourceInstance::STRING, false);
<> 0:eb73febb2bba 216 // read and write
<> 0:eb73febb2bba 217 color_res->set_operation(M2MBase::GET_PUT_ALLOWED);
<> 0:eb73febb2bba 218 // set red as initial color
<> 0:eb73febb2bba 219 color_res->set_value((const uint8_t*)"red", 3);
<> 0:eb73febb2bba 220
<> 0:eb73febb2bba 221 // 5853 = Multi-state output
<> 0:eb73febb2bba 222 M2MResource* pattern_res = led_inst->create_dynamic_resource("5853", "Pattern",
<> 0:eb73febb2bba 223 M2MResourceInstance::STRING, false);
<> 0:eb73febb2bba 224 // read and write
<> 0:eb73febb2bba 225 pattern_res->set_operation(M2MBase::GET_PUT_ALLOWED);
<> 0:eb73febb2bba 226 // set initial pattern (toggle every 200ms. 7 toggles in total)
<> 0:eb73febb2bba 227 pattern_res->set_value((const uint8_t*)"500:500:500:500:500:500:500", 27);
<> 0:eb73febb2bba 228
<> 0:eb73febb2bba 229 // there's not really an execute LWM2M ID that matches... hmm...
<> 0:eb73febb2bba 230 M2MResource* led_res = led_inst->create_dynamic_resource("5850", "Blink",
<> 0:eb73febb2bba 231 M2MResourceInstance::OPAQUE, false);
<> 0:eb73febb2bba 232 // we allow executing a function here...
<> 0:eb73febb2bba 233 led_res->set_operation(M2MBase::POST_ALLOWED);
<> 0:eb73febb2bba 234 // when a POST comes in, we want to execute the led_execute_callback
<> 0:eb73febb2bba 235 led_res->set_execute_function(execute_callback(this, &LedResource::blink));
dkato 2:6ec5c1c1d41c 236
<> 0:eb73febb2bba 237 }
<> 0:eb73febb2bba 238
<> 0:eb73febb2bba 239 M2MObject* get_object() {
<> 0:eb73febb2bba 240 return led_object;
<> 0:eb73febb2bba 241 }
<> 0:eb73febb2bba 242
dkato 2:6ec5c1c1d41c 243 void blink(void *argument) {
<> 0:eb73febb2bba 244 // read the value of 'Pattern'
<> 0:eb73febb2bba 245 M2MObjectInstance* inst = led_object->object_instance();
<> 0:eb73febb2bba 246 M2MResource* res = inst->resource("5853");
<> 0:eb73febb2bba 247 // read the value of 'Color'
<> 0:eb73febb2bba 248 M2MObjectInstance* instC = led_object->object_instance();
<> 0:eb73febb2bba 249 M2MResource* resC = instC->resource("5855");
<> 0:eb73febb2bba 250
<> 0:eb73febb2bba 251 // values in mbed Client are all buffers, and we need a vector of int's
<> 0:eb73febb2bba 252 uint8_t* buffIn = NULL;
<> 0:eb73febb2bba 253 uint32_t sizeIn;
<> 0:eb73febb2bba 254 res->get_value(buffIn, sizeIn);
1050186 12:7a199eff6988 255
<> 0:eb73febb2bba 256 uint8_t* cbuffIn = NULL;
<> 0:eb73febb2bba 257 uint32_t csizeIn;
<> 0:eb73febb2bba 258 resC->get_value(cbuffIn, csizeIn);
<> 0:eb73febb2bba 259
<> 0:eb73febb2bba 260 // turn the buffer into a string, and initialize a vector<int> on the heap
<> 0:eb73febb2bba 261 std::string s((char*)buffIn, sizeIn);
<> 0:eb73febb2bba 262 std::vector<uint32_t>* v = new std::vector<uint32_t>;
<> 0:eb73febb2bba 263
1050186 12:7a199eff6988 264 printf("led_execute_callback pattern=%s\n", s.c_str());
<> 0:eb73febb2bba 265
<> 0:eb73febb2bba 266 // our pattern is something like 500:200:500, so parse that
<> 0:eb73febb2bba 267 std::size_t found = s.find_first_of(":");
<> 0:eb73febb2bba 268 while (found!=std::string::npos) {
<> 0:eb73febb2bba 269 v->push_back(atoi((const char*)s.substr(0,found).c_str()));
<> 0:eb73febb2bba 270 s = s.substr(found+1);
<> 0:eb73febb2bba 271 found=s.find_first_of(":");
<> 0:eb73febb2bba 272 if(found == std::string::npos) {
<> 0:eb73febb2bba 273 v->push_back(atoi((const char*)s.c_str()));
<> 0:eb73febb2bba 274 }
<> 0:eb73febb2bba 275 }
dkato 2:6ec5c1c1d41c 276 int position = 0;
dkato 2:6ec5c1c1d41c 277 while (1) {
dkato 2:6ec5c1c1d41c 278 do_blink(cbuffIn);
dkato 2:6ec5c1c1d41c 279 if (position >= v->size()) {
dkato 2:6ec5c1c1d41c 280 break;
dkato 2:6ec5c1c1d41c 281 }
dkato 2:6ec5c1c1d41c 282 // how long do we need to wait before the next blink?
dkato 2:6ec5c1c1d41c 283 Thread::wait(v->at(position));
dkato 2:6ec5c1c1d41c 284 position++;
dkato 2:6ec5c1c1d41c 285 }
dkato 2:6ec5c1c1d41c 286 free(buffIn);
dkato 2:6ec5c1c1d41c 287 free(cbuffIn);
dkato 2:6ec5c1c1d41c 288 delete v;
<> 0:eb73febb2bba 289 }
<> 0:eb73febb2bba 290
<> 0:eb73febb2bba 291 private:
<> 0:eb73febb2bba 292 M2MObject* led_object;
dkato 2:6ec5c1c1d41c 293 void do_blink(uint8_t* color) {
1050186 12:7a199eff6988 294
1050186 6:4e43b6f8f772 295 #if defined(TARGET_RZ_A1H)
<> 0:eb73febb2bba 296 if (!strcmp((char *)color, "red")) {
<> 0:eb73febb2bba 297 // blink the LED in red color
1050186 12:7a199eff6988 298 red_led = !red_led;
<> 0:eb73febb2bba 299 }
<> 0:eb73febb2bba 300 else if (!strcmp((char *)color, "green")) {
<> 0:eb73febb2bba 301 // blink in green color
1050186 12:7a199eff6988 302 green_led = !green_led;
<> 0:eb73febb2bba 303 }
<> 0:eb73febb2bba 304 else if (!strcmp((char *)color, "blue")) {
<> 0:eb73febb2bba 305 // blink in blue color
1050186 12:7a199eff6988 306 blue_led = !blue_led;
<> 0:eb73febb2bba 307 }
<> 0:eb73febb2bba 308 else if (!strcmp((char *)color, "cyan")) {
<> 0:eb73febb2bba 309 // blink in cyan color
1050186 12:7a199eff6988 310 green_led = !green_led;
1050186 12:7a199eff6988 311 blue_led = !blue_led;
<> 0:eb73febb2bba 312 }
<> 0:eb73febb2bba 313 else if (!strcmp((char *)color, "yellow")) {
<> 0:eb73febb2bba 314 // blink in yellow color
1050186 12:7a199eff6988 315 red_led = !red_led;
1050186 12:7a199eff6988 316 green_led = !green_led;
<> 0:eb73febb2bba 317 }
<> 0:eb73febb2bba 318 else if (!strcmp((char *)color, "magenta")) {
<> 0:eb73febb2bba 319 // blink in magenta color
1050186 12:7a199eff6988 320 red_led = !red_led;
1050186 12:7a199eff6988 321 blue_led = !blue_led;
<> 0:eb73febb2bba 322 }
<> 0:eb73febb2bba 323 else if (!strcmp((char *)color, "white")) {
<> 0:eb73febb2bba 324 // blink in white color
1050186 12:7a199eff6988 325 red_led = !red_led;
1050186 12:7a199eff6988 326 green_led = !green_led;
1050186 12:7a199eff6988 327 blue_led = !blue_led;
<> 0:eb73febb2bba 328 }
<> 0:eb73febb2bba 329 else {
<> 0:eb73febb2bba 330 // no operation
<> 0:eb73febb2bba 331 }
1050186 6:4e43b6f8f772 332 #elif defined(TARGET_GR_LYCHEE)
1050186 6:4e43b6f8f772 333 if (!strcmp((char *)color, "green")) {
1050186 6:4e43b6f8f772 334 // blink the LED1(green color)
1050186 12:7a199eff6988 335 green_led = !green_led;
1050186 6:4e43b6f8f772 336 }
1050186 6:4e43b6f8f772 337 else if (!strcmp((char *)color, "yellow")) {
1050186 6:4e43b6f8f772 338 // blink the LED2(yellow color)
1050186 12:7a199eff6988 339 yellow_led = !yellow_led;
1050186 6:4e43b6f8f772 340 }
1050186 6:4e43b6f8f772 341 else if (!strcmp((char *)color, "orange")) {
1050186 6:4e43b6f8f772 342 // blink the LED3(orange color)
1050186 12:7a199eff6988 343 orange_led = !orange_led;
1050186 6:4e43b6f8f772 344 }
1050186 6:4e43b6f8f772 345 else if (!strcmp((char *)color, "red")) {
1050186 6:4e43b6f8f772 346 // blink the LED4(red color)
1050186 12:7a199eff6988 347 red_led = !red_led;
1050186 6:4e43b6f8f772 348 }
1050186 6:4e43b6f8f772 349 else {
1050186 6:4e43b6f8f772 350 // no operation
1050186 6:4e43b6f8f772 351 }
1050186 6:4e43b6f8f772 352 #endif
<> 0:eb73febb2bba 353 }
<> 0:eb73febb2bba 354 };
<> 0:eb73febb2bba 355
<> 0:eb73febb2bba 356 /*
1050186 12:7a199eff6988 357 * The button contains one property (click count).
1050186 12:7a199eff6988 358 * When `handle_button_click` is executed, the counter updates.
1050186 12:7a199eff6988 359 */
1050186 12:7a199eff6988 360 class ButtonResource {
1050186 12:7a199eff6988 361 public:
1050186 12:7a199eff6988 362 ButtonResource(): counter(0) {
1050186 12:7a199eff6988 363 // create ObjectID with metadata tag of '3200', which is 'digital input'
1050186 12:7a199eff6988 364 btn_object = M2MInterfaceFactory::create_object("3200");
1050186 12:7a199eff6988 365 M2MObjectInstance* btn_inst = btn_object->create_object_instance();
1050186 12:7a199eff6988 366 // create resource with ID '5501', which is digital input counter
1050186 12:7a199eff6988 367 M2MResource* btn_res = btn_inst->create_dynamic_resource("5501", "Button",
1050186 12:7a199eff6988 368 M2MResourceInstance::INTEGER, true /* observable */);
1050186 12:7a199eff6988 369 // we can read this value
1050186 12:7a199eff6988 370 btn_res->set_operation(M2MBase::GET_ALLOWED);
1050186 12:7a199eff6988 371 // set initial value (all values in mbed Client are buffers)
1050186 12:7a199eff6988 372 // to be able to read this data easily in the Connector console, we'll use a string
1050186 12:7a199eff6988 373 btn_res->set_value((uint8_t*)"0", 1);
1050186 12:7a199eff6988 374 }
1050186 12:7a199eff6988 375
1050186 12:7a199eff6988 376 ~ButtonResource() {
1050186 12:7a199eff6988 377 }
1050186 12:7a199eff6988 378
1050186 12:7a199eff6988 379 M2MObject* get_object() {
1050186 12:7a199eff6988 380 return btn_object;
1050186 12:7a199eff6988 381 }
1050186 12:7a199eff6988 382
1050186 12:7a199eff6988 383 /*
1050186 12:7a199eff6988 384 * When you press the button, we read the current value of the click counter
1050186 12:7a199eff6988 385 * from mbed Device Connector, then up the value with one.
1050186 12:7a199eff6988 386 */
1050186 12:7a199eff6988 387 void handle_button_click() {
1050186 12:7a199eff6988 388 if (mbed_client.register_successful()) {
1050186 12:7a199eff6988 389 M2MObjectInstance* inst = btn_object->object_instance();
1050186 12:7a199eff6988 390 M2MResource* res = inst->resource("5501");
1050186 12:7a199eff6988 391
1050186 12:7a199eff6988 392 // up counter
1050186 12:7a199eff6988 393 counter++;
1050186 12:7a199eff6988 394 printf("handle_button_click, new value of counter is %d\n", counter);
1050186 12:7a199eff6988 395 // serialize the value of counter as a string, and tell connector
1050186 12:7a199eff6988 396 char buffer[20];
1050186 12:7a199eff6988 397 int size = sprintf(buffer,"%d",counter);
1050186 12:7a199eff6988 398 res->set_value((uint8_t*)buffer, size);
1050186 12:7a199eff6988 399 } else {
1050186 12:7a199eff6988 400 printf("simulate button_click, device not registered\n");
1050186 12:7a199eff6988 401 }
1050186 12:7a199eff6988 402 }
1050186 12:7a199eff6988 403
1050186 12:7a199eff6988 404 private:
1050186 12:7a199eff6988 405 M2MObject* btn_object;
1050186 12:7a199eff6988 406 uint16_t counter;
1050186 12:7a199eff6988 407 };
1050186 12:7a199eff6988 408
1050186 12:7a199eff6988 409 /*
1050186 12:7a199eff6988 410 * The timer contains one property: counter.
1050186 12:7a199eff6988 411 * When `handle_timer_tick` is executed, the counter updates.
1050186 12:7a199eff6988 412 */
1050186 12:7a199eff6988 413 class TimerResource {
1050186 12:7a199eff6988 414 public:
1050186 12:7a199eff6988 415 TimerResource(): counter(0) {
1050186 12:7a199eff6988 416 // create ObjectID with metadata tag of '3200', which is 'digital input'
1050186 12:7a199eff6988 417 btn_object = M2MInterfaceFactory::create_object("3200");
1050186 12:7a199eff6988 418 M2MObjectInstance* btn_inst = btn_object->create_object_instance();
1050186 12:7a199eff6988 419 // create resource with ID '5502', which is digital input counter
1050186 12:7a199eff6988 420 M2MResource* btn_res = btn_inst->create_dynamic_resource("5502", "Timer",
1050186 12:7a199eff6988 421 M2MResourceInstance::INTEGER, true /* observable */);
1050186 12:7a199eff6988 422 // we can read this value
1050186 12:7a199eff6988 423 btn_res->set_operation(M2MBase::GET_ALLOWED);
1050186 12:7a199eff6988 424 // set initial value (all values in mbed Client are buffers)
1050186 12:7a199eff6988 425 // to be able to read this data easily in the Connector console, we'll use a string
1050186 12:7a199eff6988 426 btn_res->set_value((uint8_t*)"0", 1);
1050186 12:7a199eff6988 427 }
1050186 12:7a199eff6988 428
1050186 12:7a199eff6988 429 ~TimerResource() {
1050186 12:7a199eff6988 430 }
1050186 12:7a199eff6988 431
1050186 12:7a199eff6988 432 M2MObject* get_object() {
1050186 12:7a199eff6988 433 return btn_object;
1050186 12:7a199eff6988 434 }
1050186 12:7a199eff6988 435
1050186 12:7a199eff6988 436 /*
1050186 12:7a199eff6988 437 * When the timer ticks, we read the current value of the click counter
1050186 12:7a199eff6988 438 * from mbed Device Connector, then up the value with one.l
1050186 12:7a199eff6988 439 */
1050186 12:7a199eff6988 440 void handle_timer_tick() {
1050186 12:7a199eff6988 441 if (mbed_client.register_successful()) {
1050186 12:7a199eff6988 442 M2MObjectInstance* inst = btn_object->object_instance();
1050186 12:7a199eff6988 443 M2MResource* res = inst->resource("5502");
1050186 12:7a199eff6988 444
1050186 12:7a199eff6988 445 // up counter
1050186 12:7a199eff6988 446 counter++;
1050186 12:7a199eff6988 447 printf("handle_timer_click, new value of counter is %d\n", counter);
1050186 12:7a199eff6988 448 // serialize the value of counter as a string, and tell connector
1050186 12:7a199eff6988 449 char buffer[20];
1050186 12:7a199eff6988 450 int size = sprintf(buffer,"%d",counter);
1050186 12:7a199eff6988 451 res->set_value((uint8_t*)buffer, size);
1050186 12:7a199eff6988 452 } else {
1050186 12:7a199eff6988 453 printf("handle_timer_tick, device not registered\n");
1050186 12:7a199eff6988 454 }
1050186 12:7a199eff6988 455 }
1050186 12:7a199eff6988 456
1050186 12:7a199eff6988 457 private:
1050186 12:7a199eff6988 458 M2MObject* btn_object;
1050186 12:7a199eff6988 459 uint16_t counter;
1050186 12:7a199eff6988 460 };
1050186 12:7a199eff6988 461
1050186 12:7a199eff6988 462
1050186 12:7a199eff6988 463
1050186 12:7a199eff6988 464 class BigPayloadResource {
1050186 12:7a199eff6988 465 public:
1050186 12:7a199eff6988 466 BigPayloadResource() {
1050186 12:7a199eff6988 467 big_payload = M2MInterfaceFactory::create_object("1000");
1050186 12:7a199eff6988 468 M2MObjectInstance* payload_inst = big_payload->create_object_instance();
1050186 12:7a199eff6988 469 M2MResource* payload_res = payload_inst->create_dynamic_resource("1", "BigData",
1050186 12:7a199eff6988 470 M2MResourceInstance::STRING, true /* observable */);
1050186 12:7a199eff6988 471 payload_res->set_operation(M2MBase::GET_PUT_ALLOWED);
1050186 12:7a199eff6988 472 payload_res->set_value((uint8_t*)"0", 1);
1050186 12:7a199eff6988 473 payload_res->set_incoming_block_message_callback(
1050186 12:7a199eff6988 474 incoming_block_message_callback(this, &BigPayloadResource::block_message_received));
1050186 12:7a199eff6988 475 payload_res->set_outgoing_block_message_callback(
1050186 12:7a199eff6988 476 outgoing_block_message_callback(this, &BigPayloadResource::block_message_requested));
1050186 12:7a199eff6988 477 }
1050186 12:7a199eff6988 478
1050186 12:7a199eff6988 479 M2MObject* get_object() {
1050186 12:7a199eff6988 480 return big_payload;
1050186 12:7a199eff6988 481 }
1050186 12:7a199eff6988 482
1050186 12:7a199eff6988 483 void block_message_received(M2MBlockMessage *argument) {
1050186 12:7a199eff6988 484 if (argument) {
1050186 12:7a199eff6988 485 if (M2MBlockMessage::ErrorNone == argument->error_code()) {
1050186 12:7a199eff6988 486 if (argument->is_last_block()) {
1050186 12:7a199eff6988 487 printf("Last block received\n");
1050186 12:7a199eff6988 488 }
1050186 12:7a199eff6988 489 printf("Block number: %d\n", argument->block_number());
1050186 12:7a199eff6988 490 // First block received
1050186 12:7a199eff6988 491 if (argument->block_number() == 0) {
1050186 12:7a199eff6988 492 // Store block
1050186 12:7a199eff6988 493 // More blocks coming
1050186 12:7a199eff6988 494 } else {
1050186 12:7a199eff6988 495 // Store blocks
1050186 12:7a199eff6988 496 }
1050186 12:7a199eff6988 497 } else {
1050186 12:7a199eff6988 498 printf("Error when receiving block message! - EntityTooLarge\n");
1050186 12:7a199eff6988 499 }
1050186 12:7a199eff6988 500 // printf("Total message size: %" PRIu32 "\n", argument->total_message_size());
1050186 12:7a199eff6988 501 printf("Total message size: %PRIu32\n", argument->total_message_size());
1050186 12:7a199eff6988 502 }
1050186 12:7a199eff6988 503 }
1050186 12:7a199eff6988 504
1050186 12:7a199eff6988 505 void block_message_requested(const String& resource, uint8_t *&/*data*/, uint32_t &/*len*/) {
1050186 12:7a199eff6988 506 printf("GET request received for resource: %s\n", resource.c_str());
1050186 12:7a199eff6988 507 // Copy data and length to coap response
1050186 12:7a199eff6988 508 }
1050186 12:7a199eff6988 509
1050186 12:7a199eff6988 510 private:
1050186 12:7a199eff6988 511 M2MObject* big_payload;
1050186 12:7a199eff6988 512 };
1050186 12:7a199eff6988 513
1050186 12:7a199eff6988 514 /*
<> 0:eb73febb2bba 515 * The Zxing contains a function (send string).
<> 0:eb73febb2bba 516 * When `handle_string_send` is executed, the string after decoding is sent.
<> 0:eb73febb2bba 517 */
<> 0:eb73febb2bba 518 class ZxingResource {
<> 0:eb73febb2bba 519 public:
<> 0:eb73febb2bba 520 ZxingResource() {
<> 0:eb73febb2bba 521 // create ObjectID with metadata tag of '3202', which is 'send string'
<> 0:eb73febb2bba 522 zxing_object = M2MInterfaceFactory::create_object("3202");
<> 0:eb73febb2bba 523 M2MObjectInstance* zxing_inst = zxing_object->create_object_instance();
<> 0:eb73febb2bba 524 // create resource with ID '5700', which is 'send string'
<> 0:eb73febb2bba 525 M2MResource* zxing_res = zxing_inst->create_dynamic_resource("5700", "zxing",
<> 0:eb73febb2bba 526 M2MResourceInstance::STRING, true);
<> 0:eb73febb2bba 527 // we can read this value
<> 0:eb73febb2bba 528 zxing_res->set_operation(M2MBase::GET_ALLOWED);
<> 0:eb73febb2bba 529 // set initial value (all values in mbed Client are buffers)
<> 0:eb73febb2bba 530 // to be able to read this data easily in the Connector console, we'll use a string
dkato 2:6ec5c1c1d41c 531 zxing_res->set_value((uint8_t*)"0", 1);
<> 0:eb73febb2bba 532 }
<> 0:eb73febb2bba 533
<> 0:eb73febb2bba 534 ~ZxingResource() {
<> 0:eb73febb2bba 535 }
<> 0:eb73febb2bba 536
<> 0:eb73febb2bba 537 M2MObject* get_object() {
<> 0:eb73febb2bba 538 return zxing_object;
<> 0:eb73febb2bba 539 }
<> 0:eb73febb2bba 540
<> 0:eb73febb2bba 541 /*
<> 0:eb73febb2bba 542 * When you success the decode process of barcode, we send the string after decoding to mbed Device Connector.
<> 0:eb73febb2bba 543 */
<> 0:eb73febb2bba 544 void handle_string_send(char * addr, int size) {
1050186 12:7a199eff6988 545 if (mbed_client.register_successful()) {
1050186 12:7a199eff6988 546 M2MObjectInstance* inst = zxing_object->object_instance();
1050186 12:7a199eff6988 547 M2MResource* res = inst->resource("5700");
1050186 12:7a199eff6988 548
1050186 12:7a199eff6988 549 printf("%s\r\n", addr);
<> 0:eb73febb2bba 550
1050186 12:7a199eff6988 551 // tell the string to connector
1050186 12:7a199eff6988 552 res->set_value((uint8_t *)addr, size);
1050186 12:7a199eff6988 553 } else {
1050186 12:7a199eff6988 554 printf("handle_string_send, device not registered\n");
1050186 12:7a199eff6988 555 }
<> 0:eb73febb2bba 556 }
<> 0:eb73febb2bba 557
<> 0:eb73febb2bba 558 private:
<> 0:eb73febb2bba 559 M2MObject* zxing_object;
<> 0:eb73febb2bba 560 };
<> 0:eb73febb2bba 561
<> 0:eb73febb2bba 562 ZxingResource zxing_resource;
<> 0:eb73febb2bba 563
<> 0:eb73febb2bba 564 static void callback_zxing(char * addr, int size) {
<> 0:eb73febb2bba 565 zxing_resource.handle_string_send(addr, size);
<> 0:eb73febb2bba 566 }
dkato 2:6ec5c1c1d41c 567
dkato 2:6ec5c1c1d41c 568
1050186 12:7a199eff6988 569 // debug printf function
1050186 12:7a199eff6988 570 void trace_printer(const char* str) {
1050186 12:7a199eff6988 571 printf("%s\r\n", str);
dkato 2:6ec5c1c1d41c 572 }
<> 0:eb73febb2bba 573
<> 0:eb73febb2bba 574 // Entry point to the program
<> 0:eb73febb2bba 575 int main() {
<> 0:eb73febb2bba 576
dkato 2:6ec5c1c1d41c 577 unsigned int seed;
dkato 2:6ec5c1c1d41c 578 size_t len;
<> 0:eb73febb2bba 579
dkato 2:6ec5c1c1d41c 580 #ifdef MBEDTLS_ENTROPY_HARDWARE_ALT
dkato 2:6ec5c1c1d41c 581 // Used to randomize source port
dkato 2:6ec5c1c1d41c 582 mbedtls_hardware_poll(NULL, (unsigned char *) &seed, sizeof seed, &len);
dkato 2:6ec5c1c1d41c 583
dkato 2:6ec5c1c1d41c 584 #elif defined MBEDTLS_TEST_NULL_ENTROPY
dkato 2:6ec5c1c1d41c 585
<> 0:eb73febb2bba 586 #warning "mbedTLS security feature is disabled. Connection will not be secure !! Implement proper hardware entropy for your selected hardware."
dkato 2:6ec5c1c1d41c 587 // Used to randomize source port
dkato 2:6ec5c1c1d41c 588 mbedtls_null_entropy_poll( NULL,(unsigned char *) &seed, sizeof seed, &len);
<> 0:eb73febb2bba 589
<> 0:eb73febb2bba 590 #else
<> 0:eb73febb2bba 591
<> 0:eb73febb2bba 592 #error "This hardware does not have entropy, endpoint will not register to Connector.\
<> 0:eb73febb2bba 593 You need to enable NULL ENTROPY for your application, but if this configuration change is made then no security is offered by mbed TLS.\
<> 0:eb73febb2bba 594 Add MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES and MBEDTLS_TEST_NULL_ENTROPY in mbed_app.json macros to register your endpoint."
<> 0:eb73febb2bba 595
<> 0:eb73febb2bba 596 #endif
<> 0:eb73febb2bba 597
dkato 2:6ec5c1c1d41c 598 srand(seed);
1050186 12:7a199eff6988 599 red_led = LED_OFF;
1050186 12:7a199eff6988 600 #ifdef TARGET_GR_LYCHEE
1050186 12:7a199eff6988 601 orange_led = LED_OFF;
dkato 2:6ec5c1c1d41c 602 #else
1050186 12:7a199eff6988 603 blue_led = LED_OFF;
dkato 2:6ec5c1c1d41c 604 #endif
<> 0:eb73febb2bba 605
1050186 12:7a199eff6988 606 status_ticker.attach_us(blinky, 250000);
1050186 12:7a199eff6988 607 // Keep track of the main thread
1050186 12:7a199eff6988 608 osThreadId mainThread = osThreadGetId();
1050186 12:7a199eff6988 609
1050186 12:7a199eff6988 610 printf("\nStarting mbed Client example\n");
1050186 12:7a199eff6988 611
<> 0:eb73febb2bba 612 mbed_trace_init();
1050186 12:7a199eff6988 613 mbed_trace_print_function_set(trace_printer);
1050186 12:7a199eff6988 614 mbed_trace_config_set(TRACE_MODE_COLOR | TRACE_ACTIVE_LEVEL_INFO | TRACE_CARRIAGE_RETURN);
<> 0:eb73febb2bba 615
1050186 6:4e43b6f8f772 616 #if defined(TARGET_RZ_A1H) && (MBED_CONF_APP_NETWORK_INTERFACE == WIFI_BP3595)
dkato 2:6ec5c1c1d41c 617 DigitalOut usb1en(P3_8);
<> 0:eb73febb2bba 618 usb1en = 1;
<> 0:eb73febb2bba 619 Thread::wait(5);
<> 0:eb73febb2bba 620 usb1en = 0;
<> 0:eb73febb2bba 621 Thread::wait(5);
<> 0:eb73febb2bba 622 #endif
dkato 2:6ec5c1c1d41c 623
dkato 2:6ec5c1c1d41c 624 NetworkInterface* network = easy_connect(true);
dkato 2:6ec5c1c1d41c 625 if(network == NULL) {
dkato 2:6ec5c1c1d41c 626 printf("\nConnection to Network Failed - exiting application...\n");
dkato 2:6ec5c1c1d41c 627 return -1;
<> 0:eb73febb2bba 628 }
1050186 12:7a199eff6988 629
1050186 12:7a199eff6988 630 // we create our button, timer and LED resources
1050186 12:7a199eff6988 631 ButtonResource button_resource;
<> 0:eb73febb2bba 632 LedResource led_resource;
1050186 12:7a199eff6988 633 BigPayloadResource big_payload_resource;
1050186 12:7a199eff6988 634 TimerResource timer_resource;
1050186 12:7a199eff6988 635
1050186 12:7a199eff6988 636 // Network interaction must be performed outside of interrupt context
1050186 12:7a199eff6988 637 Semaphore updates(0);
1050186 12:7a199eff6988 638
1050186 12:7a199eff6988 639 InteractionProvider interaction_provider(updates);
1050186 12:7a199eff6988 640
<> 0:eb73febb2bba 641
<> 0:eb73febb2bba 642 // Create endpoint interface to manage register and unregister
dkato 2:6ec5c1c1d41c 643 mbed_client.create_interface(MBED_SERVER_ADDRESS, network);
<> 0:eb73febb2bba 644
<> 0:eb73febb2bba 645 // Create Objects of varying types, see simpleclient.h for more details on implementation.
<> 0:eb73febb2bba 646 M2MSecurity* register_object = mbed_client.create_register_object(); // server object specifying connector info
<> 0:eb73febb2bba 647 M2MDevice* device_object = mbed_client.create_device_object(); // device resources object
<> 0:eb73febb2bba 648
<> 0:eb73febb2bba 649 // Create list of Objects to register
<> 0:eb73febb2bba 650 M2MObjectList object_list;
<> 0:eb73febb2bba 651
<> 0:eb73febb2bba 652 // Add objects to list
<> 0:eb73febb2bba 653 object_list.push_back(device_object);
1050186 12:7a199eff6988 654 object_list.push_back(button_resource.get_object());
dkato 2:6ec5c1c1d41c 655 object_list.push_back(led_resource.get_object());
1050186 12:7a199eff6988 656 object_list.push_back(big_payload_resource.get_object());
1050186 12:7a199eff6988 657 object_list.push_back(timer_resource.get_object());
<> 0:eb73febb2bba 658 object_list.push_back(zxing_resource.get_object());
<> 0:eb73febb2bba 659
<> 0:eb73febb2bba 660 // Set endpoint registration object
<> 0:eb73febb2bba 661 mbed_client.set_register_object(register_object);
<> 0:eb73febb2bba 662
<> 0:eb73febb2bba 663 // Register with mbed Device Connector
<> 0:eb73febb2bba 664 mbed_client.test_register(register_object, object_list);
1050186 12:7a199eff6988 665 volatile bool registered = true;
<> 0:eb73febb2bba 666
1050186 20:d4695f4ddc8d 667 #if defined(TARGET_RZ_A1H) || defined(TARGET_GR_LYCHEE)
<> 0:eb73febb2bba 668 zxing_init(&callback_zxing);
dkato 2:6ec5c1c1d41c 669
<> 0:eb73febb2bba 670 Timer update_timer;
<> 0:eb73febb2bba 671 update_timer.reset();
<> 0:eb73febb2bba 672 update_timer.start();
<> 0:eb73febb2bba 673
1050186 12:7a199eff6988 674 while (true) {
<> 0:eb73febb2bba 675 if (zxing_loop() == 0) {
<> 0:eb73febb2bba 676 update_timer.reset();
<> 0:eb73febb2bba 677 } else if (update_timer.read() >= 25) {
<> 0:eb73febb2bba 678 mbed_client.test_update_register();
<> 0:eb73febb2bba 679 update_timer.reset();
<> 0:eb73febb2bba 680 } else {
<> 0:eb73febb2bba 681 // do nothing
<> 0:eb73febb2bba 682 }
<> 0:eb73febb2bba 683 Thread::wait(5);
<> 0:eb73febb2bba 684 }
1050186 12:7a199eff6988 685 #else
1050186 12:7a199eff6988 686 while (true) {
1050186 12:7a199eff6988 687 updates.wait(25000);
1050186 12:7a199eff6988 688 if(registered) {
1050186 12:7a199eff6988 689 if(!interaction_provider.clicked) {
1050186 12:7a199eff6988 690 mbed_client.test_update_register();
1050186 12:7a199eff6988 691 }
1050186 12:7a199eff6988 692 }else {
1050186 12:7a199eff6988 693 break;
1050186 12:7a199eff6988 694 }
1050186 12:7a199eff6988 695 if(interaction_provider.clicked) {
1050186 12:7a199eff6988 696 interaction_provider.clicked = false;
1050186 12:7a199eff6988 697 button_resource.handle_button_click();
1050186 12:7a199eff6988 698 }
1050186 12:7a199eff6988 699 if(interaction_provider.timer_ticked) {
1050186 12:7a199eff6988 700 interaction_provider.timer_ticked = false;
1050186 12:7a199eff6988 701 timer_resource.handle_timer_tick();
1050186 12:7a199eff6988 702 }
1050186 12:7a199eff6988 703 }
1050186 12:7a199eff6988 704 #endif
<> 0:eb73febb2bba 705
<> 0:eb73febb2bba 706 mbed_client.test_unregister();
1050186 12:7a199eff6988 707 status_ticker.detach();
<> 0:eb73febb2bba 708 }
dkato 2:6ec5c1c1d41c 709
dkato 2:6ec5c1c1d41c 710 #endif // MBED_CONF_APP_NETWORK_INTERFACE != NO_CONNECT
dkato 2:6ec5c1c1d41c 711
dkato 2:6ec5c1c1d41c 712