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 05:50:25 2018 +0000
Revision:
20:d4695f4ddc8d
Parent:
18:0ab91e767950
Child:
21:ac3a0d5b2c5d
Minor tweaks main.cpp.

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