This is a mbed Client sample where ZXing is incorporated, and works on GR-PEACH and GR-LYCHEE.

Dependencies:   DisplayApp AsciiFont

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/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Connection-type.
  2. Set the client credentials. For details, please refer to the following wiki:
    https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Client-credentials.
  3. Change Ethernet settings. For details, please refer to the following wiki:
    https://developer.mbed.org/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Ethernet-settings.
  4. Change Wifi settings. For details, please refer to the following wiki:
    https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/Wifi-settings.
  5. Set up an IP address. (This step is optional.) For details, please refer to the following wiki:
    https://os.mbed.com/teams/Renesas/code/GR-PEACH_mbed-os-client-ZXingSample/wiki/IP-address-setup.

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 Ethernet cable into GR-PEACH or GR-LYCHEE if you are using Ethernet mode.
  5. Plug the micro-USB cable into the OpenSDA port which lies on the next to the RESET button.
  6. Copy the binary previously downloaded to your PC to GR-PEACH or GR-LYCHEE to flash this example. When the copy is successfully completed, the board is ready to work.
  7. Press the RESET button on the board to run the example.
  8. For verification, please refer to the following wiki:
    https://developer.mbed.org/teams/Renesas/code/GR-PEACH_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 red, green, blue, cyan, yellow and magenta is acceptable if you are using GR-PEACH board (PUT).
  5. 3201/0/5855. Blink color, used by the blink function. Any of green, yellow, orange and red is acceptable if you are using GR-LYCHEE board (PUT).

For more info on how to get notifications when resource 1 changes, or how to use resource 2, 3 and 4, please look at

Import programGR-PEACH_mbed-connector-ZXingSample-node

Node.js based Web Application for mbed Device Connector specific to GR-PEACH_mbed-os-client-ZXingSample

Committer:
1050186
Date:
Mon Apr 17 05:28:29 2017 +0000
Revision:
5:6b6540e303f2
Parent:
2:6ec5c1c1d41c
Child:
6:ea24d9271ff1
Support GCC_ARM, and update libraries.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 0:eb73febb2bba 1 /*
<> 0:eb73febb2bba 2 * Copyright (c) 2015 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 */
<> 0:eb73febb2bba 16
<> 0:eb73febb2bba 17 #ifndef __SIMPLECLIENT_H__
<> 0:eb73febb2bba 18 #define __SIMPLECLIENT_H__
<> 0:eb73febb2bba 19
<> 0:eb73febb2bba 20 #include "mbed-client/m2minterfacefactory.h"
<> 0:eb73febb2bba 21 #include "mbed-client/m2mdevice.h"
<> 0:eb73febb2bba 22 #include "mbed-client/m2minterfaceobserver.h"
<> 0:eb73febb2bba 23 #include "mbed-client/m2minterface.h"
<> 0:eb73febb2bba 24 #include "mbed-client/m2mobject.h"
<> 0:eb73febb2bba 25 #include "mbed-client/m2mobjectinstance.h"
<> 0:eb73febb2bba 26 #include "mbed-client/m2mresource.h"
<> 0:eb73febb2bba 27 #include "mbed-client/m2mconfig.h"
dkato 2:6ec5c1c1d41c 28 #include "mbed-client/m2mblockmessage.h"
<> 0:eb73febb2bba 29 #include "security.h"
<> 0:eb73febb2bba 30 #include "mbed.h"
<> 0:eb73febb2bba 31
dkato 2:6ec5c1c1d41c 32 #define ETHERNET 1
dkato 2:6ec5c1c1d41c 33 #define WIFI 2
dkato 2:6ec5c1c1d41c 34 #define MESH_LOWPAN_ND 3
dkato 2:6ec5c1c1d41c 35 #define MESH_THREAD 4
dkato 2:6ec5c1c1d41c 36 #define ATMEL 5
dkato 2:6ec5c1c1d41c 37 #define MCR20 6
dkato 2:6ec5c1c1d41c 38
dkato 2:6ec5c1c1d41c 39 #define STRINGIFY(s) #s
dkato 2:6ec5c1c1d41c 40
dkato 2:6ec5c1c1d41c 41 // Check if using mesh networking, define helper
dkato 2:6ec5c1c1d41c 42 #if MBED_CONF_APP_NETWORK_INTERFACE == MESH_LOWPAN_ND
dkato 2:6ec5c1c1d41c 43 #define MESH
dkato 2:6ec5c1c1d41c 44 #elif MBED_CONF_APP_NETWORK_INTERFACE == MESH_THREAD
dkato 2:6ec5c1c1d41c 45 #define MESH
dkato 2:6ec5c1c1d41c 46 #endif
dkato 2:6ec5c1c1d41c 47
dkato 2:6ec5c1c1d41c 48 #if defined (MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true)
dkato 2:6ec5c1c1d41c 49 // Mesh is always IPV6 - also WiFi and ETH can be IPV6 if IPV6 is enabled
dkato 2:6ec5c1c1d41c 50 M2MInterface::NetworkStack NETWORK_STACK = M2MInterface::LwIP_IPv6;
dkato 2:6ec5c1c1d41c 51 #else
dkato 2:6ec5c1c1d41c 52 // Everything else - we assume it's IPv4
dkato 2:6ec5c1c1d41c 53 M2MInterface::NetworkStack NETWORK_STACK = M2MInterface::LwIP_IPv4;
dkato 2:6ec5c1c1d41c 54 #endif
dkato 2:6ec5c1c1d41c 55
dkato 2:6ec5c1c1d41c 56 //Select binding mode: UDP or TCP -- note - Mesh networking is IPv6 UDP ONLY
dkato 2:6ec5c1c1d41c 57 #ifdef MESH
dkato 2:6ec5c1c1d41c 58 M2MInterface::BindingMode SOCKET_MODE = M2MInterface::UDP;
dkato 2:6ec5c1c1d41c 59 #else
dkato 2:6ec5c1c1d41c 60 // WiFi or Ethernet supports both - TCP by default to avoid
dkato 2:6ec5c1c1d41c 61 // NAT problems, but UDP will also work - IF you configure
dkato 2:6ec5c1c1d41c 62 // your network right.
dkato 2:6ec5c1c1d41c 63 M2MInterface::BindingMode SOCKET_MODE = M2MInterface::TCP;
dkato 2:6ec5c1c1d41c 64 #endif
dkato 2:6ec5c1c1d41c 65
<> 0:eb73febb2bba 66
<> 0:eb73febb2bba 67 // MBED_DOMAIN and MBED_ENDPOINT_NAME come
<> 0:eb73febb2bba 68 // from the security.h file copied from connector.mbed.com
<> 0:eb73febb2bba 69
<> 0:eb73febb2bba 70 struct MbedClientDevice {
<> 0:eb73febb2bba 71 const char* Manufacturer;
<> 0:eb73febb2bba 72 const char* Type;
<> 0:eb73febb2bba 73 const char* ModelNumber;
<> 0:eb73febb2bba 74 const char* SerialNumber;
<> 0:eb73febb2bba 75 };
<> 0:eb73febb2bba 76
<> 0:eb73febb2bba 77 /*
<> 0:eb73febb2bba 78 * Wrapper for mbed client stack that handles all callbacks, error handling, and
<> 0:eb73febb2bba 79 * other shenanigans to make the mbed client stack easier to use.
<> 0:eb73febb2bba 80 *
<> 0:eb73febb2bba 81 * The end user should only have to care about configuring the parameters at the
<> 0:eb73febb2bba 82 * top of this file and making sure they add the security.h file correctly.
<> 0:eb73febb2bba 83 * To add resources you can copy the _TODO__ function and add as many instances as
<> 0:eb73febb2bba 84 * you want.
<> 0:eb73febb2bba 85 *
<> 0:eb73febb2bba 86 */
<> 0:eb73febb2bba 87 class MbedClient: public M2MInterfaceObserver {
<> 0:eb73febb2bba 88 public:
<> 0:eb73febb2bba 89
<> 0:eb73febb2bba 90 // constructor for MbedClient object, initialize private variables
<> 0:eb73febb2bba 91 MbedClient(struct MbedClientDevice device) {
<> 0:eb73febb2bba 92 _interface = NULL;
<> 0:eb73febb2bba 93 _bootstrapped = false;
<> 0:eb73febb2bba 94 _error = false;
<> 0:eb73febb2bba 95 _registered = false;
<> 0:eb73febb2bba 96 _unregistered = false;
<> 0:eb73febb2bba 97 _register_security = NULL;
<> 0:eb73febb2bba 98 _value = 0;
<> 0:eb73febb2bba 99 _object = NULL;
<> 0:eb73febb2bba 100 _device = device;
<> 0:eb73febb2bba 101 }
<> 0:eb73febb2bba 102
<> 0:eb73febb2bba 103 // de-constructor for MbedClient object, you can ignore this
<> 0:eb73febb2bba 104 ~MbedClient() {
<> 0:eb73febb2bba 105 if(_interface) {
<> 0:eb73febb2bba 106 delete _interface;
<> 0:eb73febb2bba 107 }
<> 0:eb73febb2bba 108 if(_register_security){
<> 0:eb73febb2bba 109 delete _register_security;
<> 0:eb73febb2bba 110 }
<> 0:eb73febb2bba 111 }
<> 0:eb73febb2bba 112
<> 0:eb73febb2bba 113 // debug printf function
<> 0:eb73febb2bba 114 void trace_printer(const char* str) {
<> 0:eb73febb2bba 115 printf("\r\n%s\r\n", str);
<> 0:eb73febb2bba 116 }
<> 0:eb73febb2bba 117
<> 0:eb73febb2bba 118 /*
<> 0:eb73febb2bba 119 * Creates M2MInterface using which endpoint can
<> 0:eb73febb2bba 120 * setup its name, resource type, life time, connection mode,
<> 0:eb73febb2bba 121 * Currently only LwIPv4 is supported.
<> 0:eb73febb2bba 122 */
<> 0:eb73febb2bba 123 void create_interface(const char *server_address,
<> 0:eb73febb2bba 124 void *handler=NULL) {
dkato 2:6ec5c1c1d41c 125 // Randomizing listening port for Certificate mode connectivity
<> 0:eb73febb2bba 126 _server_address = server_address;
dkato 2:6ec5c1c1d41c 127 uint16_t port = 0; // Network interface will randomize with port 0
<> 0:eb73febb2bba 128
<> 0:eb73febb2bba 129 // create mDS interface object, this is the base object everything else attaches to
<> 0:eb73febb2bba 130 _interface = M2MInterfaceFactory::create_interface(*this,
<> 0:eb73febb2bba 131 MBED_ENDPOINT_NAME, // endpoint name string
<> 0:eb73febb2bba 132 "test", // endpoint type string
<> 0:eb73febb2bba 133 100, // lifetime
<> 0:eb73febb2bba 134 port, // listen port
<> 0:eb73febb2bba 135 MBED_DOMAIN, // domain string
<> 0:eb73febb2bba 136 SOCKET_MODE, // binding mode
dkato 2:6ec5c1c1d41c 137 NETWORK_STACK, // network stack
<> 0:eb73febb2bba 138 ""); // context address string
<> 0:eb73febb2bba 139 const char *binding_mode = (SOCKET_MODE == M2MInterface::UDP) ? "UDP" : "TCP";
<> 0:eb73febb2bba 140 printf("\r\nSOCKET_MODE : %s\r\n", binding_mode);
<> 0:eb73febb2bba 141 printf("Connecting to %s\r\n", server_address);
<> 0:eb73febb2bba 142
<> 0:eb73febb2bba 143 if(_interface) {
<> 0:eb73febb2bba 144 _interface->set_platform_network_handler(handler);
<> 0:eb73febb2bba 145 }
<> 0:eb73febb2bba 146
<> 0:eb73febb2bba 147 }
<> 0:eb73febb2bba 148
<> 0:eb73febb2bba 149 /*
<> 0:eb73febb2bba 150 * check private variable to see if the registration was sucessful or not
<> 0:eb73febb2bba 151 */
<> 0:eb73febb2bba 152 bool register_successful() {
<> 0:eb73febb2bba 153 return _registered;
<> 0:eb73febb2bba 154 }
<> 0:eb73febb2bba 155
<> 0:eb73febb2bba 156 /*
<> 0:eb73febb2bba 157 * check private variable to see if un-registration was sucessful or not
<> 0:eb73febb2bba 158 */
<> 0:eb73febb2bba 159 bool unregister_successful() {
<> 0:eb73febb2bba 160 return _unregistered;
<> 0:eb73febb2bba 161 }
<> 0:eb73febb2bba 162
<> 0:eb73febb2bba 163 /*
<> 0:eb73febb2bba 164 * Creates register server object with mbed device server address and other parameters
<> 0:eb73febb2bba 165 * required for client to connect to mbed device server.
<> 0:eb73febb2bba 166 */
<> 0:eb73febb2bba 167 M2MSecurity* create_register_object() {
<> 0:eb73febb2bba 168 // create security object using the interface factory.
<> 0:eb73febb2bba 169 // this will generate a security ObjectID and ObjectInstance
<> 0:eb73febb2bba 170 M2MSecurity *security = M2MInterfaceFactory::create_security(M2MSecurity::M2MServer);
<> 0:eb73febb2bba 171
<> 0:eb73febb2bba 172 // make sure security ObjectID/ObjectInstance was created successfully
<> 0:eb73febb2bba 173 if(security) {
<> 0:eb73febb2bba 174 // Add ResourceID's and values to the security ObjectID/ObjectInstance
<> 0:eb73febb2bba 175 security->set_resource_value(M2MSecurity::M2MServerUri, _server_address);
<> 0:eb73febb2bba 176 security->set_resource_value(M2MSecurity::SecurityMode, M2MSecurity::Certificate);
dkato 2:6ec5c1c1d41c 177 security->set_resource_value(M2MSecurity::ServerPublicKey, SERVER_CERT, sizeof(SERVER_CERT) - 1);
dkato 2:6ec5c1c1d41c 178 security->set_resource_value(M2MSecurity::PublicKey, CERT, sizeof(CERT) - 1);
dkato 2:6ec5c1c1d41c 179 security->set_resource_value(M2MSecurity::Secretkey, KEY, sizeof(KEY) - 1);
<> 0:eb73febb2bba 180 }
<> 0:eb73febb2bba 181 return security;
<> 0:eb73febb2bba 182 }
<> 0:eb73febb2bba 183
<> 0:eb73febb2bba 184 /*
<> 0:eb73febb2bba 185 * Creates device object which contains mandatory resources linked with
<> 0:eb73febb2bba 186 * device endpoint.
<> 0:eb73febb2bba 187 */
<> 0:eb73febb2bba 188 M2MDevice* create_device_object() {
<> 0:eb73febb2bba 189 // create device objectID/ObjectInstance
<> 0:eb73febb2bba 190 M2MDevice *device = M2MInterfaceFactory::create_device();
<> 0:eb73febb2bba 191 // make sure device object was created successfully
<> 0:eb73febb2bba 192 if(device) {
<> 0:eb73febb2bba 193 // add resourceID's to device objectID/ObjectInstance
<> 0:eb73febb2bba 194 device->create_resource(M2MDevice::Manufacturer, _device.Manufacturer);
<> 0:eb73febb2bba 195 device->create_resource(M2MDevice::DeviceType, _device.Type);
<> 0:eb73febb2bba 196 device->create_resource(M2MDevice::ModelNumber, _device.ModelNumber);
<> 0:eb73febb2bba 197 device->create_resource(M2MDevice::SerialNumber, _device.SerialNumber);
<> 0:eb73febb2bba 198 }
<> 0:eb73febb2bba 199 return device;
<> 0:eb73febb2bba 200 }
<> 0:eb73febb2bba 201
<> 0:eb73febb2bba 202 /*
<> 0:eb73febb2bba 203 * register an object
<> 0:eb73febb2bba 204 */
<> 0:eb73febb2bba 205 void test_register(M2MSecurity *register_object, M2MObjectList object_list){
<> 0:eb73febb2bba 206 if(_interface) {
<> 0:eb73febb2bba 207 // Register function
<> 0:eb73febb2bba 208 _interface->register_object(register_object, object_list);
<> 0:eb73febb2bba 209 }
<> 0:eb73febb2bba 210 }
<> 0:eb73febb2bba 211
<> 0:eb73febb2bba 212 /*
<> 0:eb73febb2bba 213 * unregister all objects
<> 0:eb73febb2bba 214 */
<> 0:eb73febb2bba 215 void test_unregister() {
<> 0:eb73febb2bba 216 if(_interface) {
<> 0:eb73febb2bba 217 // Unregister function
<> 0:eb73febb2bba 218 _interface->unregister_object(NULL); // NULL will unregister all objects
<> 0:eb73febb2bba 219 }
<> 0:eb73febb2bba 220 }
<> 0:eb73febb2bba 221
<> 0:eb73febb2bba 222 //Callback from mbed client stack when the bootstrap
<> 0:eb73febb2bba 223 // is successful, it returns the mbed Device Server object
<> 0:eb73febb2bba 224 // which will be used for registering the resources to
<> 0:eb73febb2bba 225 // mbed Device server.
<> 0:eb73febb2bba 226 void bootstrap_done(M2MSecurity *server_object){
<> 0:eb73febb2bba 227 if(server_object) {
<> 0:eb73febb2bba 228 _bootstrapped = true;
<> 0:eb73febb2bba 229 _error = false;
<> 0:eb73febb2bba 230 trace_printer("Bootstrapped");
<> 0:eb73febb2bba 231 }
<> 0:eb73febb2bba 232 }
<> 0:eb73febb2bba 233
<> 0:eb73febb2bba 234 //Callback from mbed client stack when the registration
<> 0:eb73febb2bba 235 // is successful, it returns the mbed Device Server object
<> 0:eb73febb2bba 236 // to which the resources are registered and registered objects.
<> 0:eb73febb2bba 237 void object_registered(M2MSecurity */*security_object*/, const M2MServer &/*server_object*/){
<> 0:eb73febb2bba 238 _registered = true;
<> 0:eb73febb2bba 239 _unregistered = false;
<> 0:eb73febb2bba 240 trace_printer("Registered object successfully!");
<> 0:eb73febb2bba 241 }
<> 0:eb73febb2bba 242
<> 0:eb73febb2bba 243 //Callback from mbed client stack when the unregistration
<> 0:eb73febb2bba 244 // is successful, it returns the mbed Device Server object
<> 0:eb73febb2bba 245 // to which the resources were unregistered.
<> 0:eb73febb2bba 246 void object_unregistered(M2MSecurity */*server_object*/){
<> 0:eb73febb2bba 247 trace_printer("Unregistered Object Successfully");
<> 0:eb73febb2bba 248 _unregistered = true;
dkato 2:6ec5c1c1d41c 249 _registered = false;
<> 0:eb73febb2bba 250 }
<> 0:eb73febb2bba 251
<> 0:eb73febb2bba 252 /*
<> 0:eb73febb2bba 253 * Callback from mbed client stack when registration is updated
<> 0:eb73febb2bba 254 */
<> 0:eb73febb2bba 255 void registration_updated(M2MSecurity */*security_object*/, const M2MServer & /*server_object*/){
<> 0:eb73febb2bba 256 /* The registration is updated automatically and frequently by the
<> 0:eb73febb2bba 257 * mbed client stack. This print statement is turned off because it
<> 0:eb73febb2bba 258 * tends to happen alot.
<> 0:eb73febb2bba 259 */
<> 0:eb73febb2bba 260 //trace_printer("\r\nRegistration Updated\r\n");
<> 0:eb73febb2bba 261 }
<> 0:eb73febb2bba 262
<> 0:eb73febb2bba 263 // Callback from mbed client stack if any error is encountered
<> 0:eb73febb2bba 264 // during any of the LWM2M operations. Error type is passed in
<> 0:eb73febb2bba 265 // the callback.
<> 0:eb73febb2bba 266 void error(M2MInterface::Error error){
<> 0:eb73febb2bba 267 _error = true;
<> 0:eb73febb2bba 268 switch(error){
<> 0:eb73febb2bba 269 case M2MInterface::AlreadyExists:
<> 0:eb73febb2bba 270 trace_printer("[ERROR:] M2MInterface::AlreadyExist");
<> 0:eb73febb2bba 271 break;
<> 0:eb73febb2bba 272 case M2MInterface::BootstrapFailed:
<> 0:eb73febb2bba 273 trace_printer("[ERROR:] M2MInterface::BootstrapFailed");
<> 0:eb73febb2bba 274 break;
<> 0:eb73febb2bba 275 case M2MInterface::InvalidParameters:
<> 0:eb73febb2bba 276 trace_printer("[ERROR:] M2MInterface::InvalidParameters");
<> 0:eb73febb2bba 277 break;
<> 0:eb73febb2bba 278 case M2MInterface::NotRegistered:
<> 0:eb73febb2bba 279 trace_printer("[ERROR:] M2MInterface::NotRegistered");
<> 0:eb73febb2bba 280 break;
<> 0:eb73febb2bba 281 case M2MInterface::Timeout:
<> 0:eb73febb2bba 282 trace_printer("[ERROR:] M2MInterface::Timeout");
<> 0:eb73febb2bba 283 break;
<> 0:eb73febb2bba 284 case M2MInterface::NetworkError:
<> 0:eb73febb2bba 285 trace_printer("[ERROR:] M2MInterface::NetworkError");
<> 0:eb73febb2bba 286 break;
<> 0:eb73febb2bba 287 case M2MInterface::ResponseParseFailed:
<> 0:eb73febb2bba 288 trace_printer("[ERROR:] M2MInterface::ResponseParseFailed");
<> 0:eb73febb2bba 289 break;
<> 0:eb73febb2bba 290 case M2MInterface::UnknownError:
<> 0:eb73febb2bba 291 trace_printer("[ERROR:] M2MInterface::UnknownError");
<> 0:eb73febb2bba 292 break;
<> 0:eb73febb2bba 293 case M2MInterface::MemoryFail:
<> 0:eb73febb2bba 294 trace_printer("[ERROR:] M2MInterface::MemoryFail");
<> 0:eb73febb2bba 295 break;
<> 0:eb73febb2bba 296 case M2MInterface::NotAllowed:
<> 0:eb73febb2bba 297 trace_printer("[ERROR:] M2MInterface::NotAllowed");
<> 0:eb73febb2bba 298 break;
<> 0:eb73febb2bba 299 case M2MInterface::SecureConnectionFailed:
<> 0:eb73febb2bba 300 trace_printer("[ERROR:] M2MInterface::SecureConnectionFailed");
<> 0:eb73febb2bba 301 break;
<> 0:eb73febb2bba 302 case M2MInterface::DnsResolvingFailed:
<> 0:eb73febb2bba 303 trace_printer("[ERROR:] M2MInterface::DnsResolvingFailed");
<> 0:eb73febb2bba 304 break;
<> 0:eb73febb2bba 305
<> 0:eb73febb2bba 306 default:
<> 0:eb73febb2bba 307 break;
<> 0:eb73febb2bba 308 }
<> 0:eb73febb2bba 309 }
<> 0:eb73febb2bba 310
<> 0:eb73febb2bba 311 /* Callback from mbed client stack if any value has changed
<> 0:eb73febb2bba 312 * during PUT operation. Object and its type is passed in
<> 0:eb73febb2bba 313 * the callback.
<> 0:eb73febb2bba 314 * BaseType enum from m2mbase.h
<> 0:eb73febb2bba 315 * Object = 0x0, Resource = 0x1, ObjectInstance = 0x2, ResourceInstance = 0x3
<> 0:eb73febb2bba 316 */
<> 0:eb73febb2bba 317 void value_updated(M2MBase *base, M2MBase::BaseType type) {
<> 0:eb73febb2bba 318 printf("\r\nPUT Request Received!");
dkato 2:6ec5c1c1d41c 319 printf("\r\nName :'%s', \r\nPath : '%s', \r\nType : '%d' (0 for Object, 1 for Resource), \r\nType : '%s'\r\n",
dkato 2:6ec5c1c1d41c 320 base->name(),
dkato 2:6ec5c1c1d41c 321 base->uri_path(),
<> 0:eb73febb2bba 322 type,
dkato 2:6ec5c1c1d41c 323 base->resource_type()
<> 0:eb73febb2bba 324 );
<> 0:eb73febb2bba 325 }
<> 0:eb73febb2bba 326
<> 0:eb73febb2bba 327 /*
<> 0:eb73febb2bba 328 * update the registration period
<> 0:eb73febb2bba 329 */
<> 0:eb73febb2bba 330 void test_update_register() {
<> 0:eb73febb2bba 331 if (_registered) {
<> 0:eb73febb2bba 332 _interface->update_registration(_register_security, 100);
<> 0:eb73febb2bba 333 }
<> 0:eb73febb2bba 334 }
<> 0:eb73febb2bba 335
<> 0:eb73febb2bba 336 /*
<> 0:eb73febb2bba 337 * manually configure the security object private variable
<> 0:eb73febb2bba 338 */
<> 0:eb73febb2bba 339 void set_register_object(M2MSecurity *register_object) {
<> 0:eb73febb2bba 340 if (_register_security == NULL) {
<> 0:eb73febb2bba 341 _register_security = register_object;
<> 0:eb73febb2bba 342 }
<> 0:eb73febb2bba 343 }
<> 0:eb73febb2bba 344
<> 0:eb73febb2bba 345 private:
<> 0:eb73febb2bba 346
<> 0:eb73febb2bba 347 /*
<> 0:eb73febb2bba 348 * Private variables used in class
<> 0:eb73febb2bba 349 */
<> 0:eb73febb2bba 350 M2MInterface *_interface;
<> 0:eb73febb2bba 351 M2MSecurity *_register_security;
<> 0:eb73febb2bba 352 M2MObject *_object;
<> 0:eb73febb2bba 353 volatile bool _bootstrapped;
<> 0:eb73febb2bba 354 volatile bool _error;
<> 0:eb73febb2bba 355 volatile bool _registered;
<> 0:eb73febb2bba 356 volatile bool _unregistered;
<> 0:eb73febb2bba 357 int _value;
<> 0:eb73febb2bba 358 struct MbedClientDevice _device;
<> 0:eb73febb2bba 359 String _server_address;
<> 0:eb73febb2bba 360 };
<> 0:eb73febb2bba 361
<> 0:eb73febb2bba 362 #endif // __SIMPLECLIENT_H__