This is a fork due to permission issues

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of 6_songs-from-the-cloud by MakingMusicWorkshop

Committer:
maclobdell
Date:
Wed May 18 19:06:32 2016 +0000
Revision:
0:f7c60d3e7b8a
clean version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maclobdell 0:f7c60d3e7b8a 1 /*
maclobdell 0:f7c60d3e7b8a 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
maclobdell 0:f7c60d3e7b8a 3 * SPDX-License-Identifier: Apache-2.0
maclobdell 0:f7c60d3e7b8a 4 * Licensed under the Apache License, Version 2.0 (the License); you may
maclobdell 0:f7c60d3e7b8a 5 * not use this file except in compliance with the License.
maclobdell 0:f7c60d3e7b8a 6 * You may obtain a copy of the License at
maclobdell 0:f7c60d3e7b8a 7 *
maclobdell 0:f7c60d3e7b8a 8 * http://www.apache.org/licenses/LICENSE-2.0
maclobdell 0:f7c60d3e7b8a 9 *
maclobdell 0:f7c60d3e7b8a 10 * Unless required by applicable law or agreed to in writing, software
maclobdell 0:f7c60d3e7b8a 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
maclobdell 0:f7c60d3e7b8a 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
maclobdell 0:f7c60d3e7b8a 13 * See the License for the specific language governing permissions and
maclobdell 0:f7c60d3e7b8a 14 * limitations under the License.
maclobdell 0:f7c60d3e7b8a 15 */
maclobdell 0:f7c60d3e7b8a 16
maclobdell 0:f7c60d3e7b8a 17 #ifndef __SIMPLECLIENT_H__
maclobdell 0:f7c60d3e7b8a 18 #define __SIMPLECLIENT_H__
maclobdell 0:f7c60d3e7b8a 19
maclobdell 0:f7c60d3e7b8a 20 //#include "sockets/UDPSocket.h"
maclobdell 0:f7c60d3e7b8a 21 #include "EthernetInterface.h"
maclobdell 0:f7c60d3e7b8a 22 //#include "mbed-drivers/test_env.h"
maclobdell 0:f7c60d3e7b8a 23 #include "mbed-client/m2minterfacefactory.h"
maclobdell 0:f7c60d3e7b8a 24 #include "mbed-client/m2mdevice.h"
maclobdell 0:f7c60d3e7b8a 25 #include "mbed-client/m2minterfaceobserver.h"
maclobdell 0:f7c60d3e7b8a 26 #include "mbed-client/m2minterface.h"
maclobdell 0:f7c60d3e7b8a 27 #include "mbed-client/m2mobject.h"
maclobdell 0:f7c60d3e7b8a 28 #include "mbed-client/m2mobjectinstance.h"
maclobdell 0:f7c60d3e7b8a 29 #include "mbed-client/m2mresource.h"
maclobdell 0:f7c60d3e7b8a 30 //#include "minar/minar.h"
maclobdell 0:f7c60d3e7b8a 31 #include "security.h"
maclobdell 0:f7c60d3e7b8a 32
maclobdell 0:f7c60d3e7b8a 33 DigitalOut green(LED_GREEN);
maclobdell 0:f7c60d3e7b8a 34
maclobdell 0:f7c60d3e7b8a 35 //Select binding mode: UDP or TCP
maclobdell 0:f7c60d3e7b8a 36 M2MInterface::BindingMode SOCKET_MODE = M2MInterface::UDP;
maclobdell 0:f7c60d3e7b8a 37
maclobdell 0:f7c60d3e7b8a 38 // This is address to mbed Device Connector
maclobdell 0:f7c60d3e7b8a 39 const String &MBED_SERVER_ADDRESS = "coap://api.connector.mbed.com:5684";
maclobdell 0:f7c60d3e7b8a 40
maclobdell 0:f7c60d3e7b8a 41 // These come from the security.h file copied from connector.mbed.com
maclobdell 0:f7c60d3e7b8a 42 const String &MBED_USER_NAME_DOMAIN = MBED_DOMAIN;
maclobdell 0:f7c60d3e7b8a 43 const String &ENDPOINT_NAME = MBED_ENDPOINT_NAME;
maclobdell 0:f7c60d3e7b8a 44
maclobdell 0:f7c60d3e7b8a 45 struct MbedClientDevice {
maclobdell 0:f7c60d3e7b8a 46 const char* Manufacturer;
maclobdell 0:f7c60d3e7b8a 47 const char* Type;
maclobdell 0:f7c60d3e7b8a 48 const char* ModelNumber;
maclobdell 0:f7c60d3e7b8a 49 const char* SerialNumber;
maclobdell 0:f7c60d3e7b8a 50 };
maclobdell 0:f7c60d3e7b8a 51
maclobdell 0:f7c60d3e7b8a 52 /*
maclobdell 0:f7c60d3e7b8a 53 * Wrapper for mbed client stack that handles all callbacks, error handling, and
maclobdell 0:f7c60d3e7b8a 54 * other schenanigans to make the mbed client stack easier to use.
maclobdell 0:f7c60d3e7b8a 55 *
maclobdell 0:f7c60d3e7b8a 56 * The end user should only have to care about configuring the parameters at the
maclobdell 0:f7c60d3e7b8a 57 * top of this file and making sure they add the security.h file correctly.
maclobdell 0:f7c60d3e7b8a 58 * To add resources you can copy the _TODO__ function and add as many instances as
maclobdell 0:f7c60d3e7b8a 59 * you want.
maclobdell 0:f7c60d3e7b8a 60 *
maclobdell 0:f7c60d3e7b8a 61 */
maclobdell 0:f7c60d3e7b8a 62 class MbedClient: public M2MInterfaceObserver {
maclobdell 0:f7c60d3e7b8a 63 public:
maclobdell 0:f7c60d3e7b8a 64
maclobdell 0:f7c60d3e7b8a 65 // constructor for MbedClient object, initialize private variables
maclobdell 0:f7c60d3e7b8a 66 MbedClient(struct MbedClientDevice device) {
maclobdell 0:f7c60d3e7b8a 67 _interface = NULL;
maclobdell 0:f7c60d3e7b8a 68 _bootstrapped = false;
maclobdell 0:f7c60d3e7b8a 69 _error = false;
maclobdell 0:f7c60d3e7b8a 70 _registered = false;
maclobdell 0:f7c60d3e7b8a 71 _unregistered = false;
maclobdell 0:f7c60d3e7b8a 72 _register_security = NULL;
maclobdell 0:f7c60d3e7b8a 73 _value = 0;
maclobdell 0:f7c60d3e7b8a 74 _object = NULL;
maclobdell 0:f7c60d3e7b8a 75 _device = device;
maclobdell 0:f7c60d3e7b8a 76 }
maclobdell 0:f7c60d3e7b8a 77
maclobdell 0:f7c60d3e7b8a 78 // de-constructor for MbedClient object, you can ignore this
maclobdell 0:f7c60d3e7b8a 79 ~MbedClient() {
maclobdell 0:f7c60d3e7b8a 80 if(_interface) {
maclobdell 0:f7c60d3e7b8a 81 delete _interface;
maclobdell 0:f7c60d3e7b8a 82 }
maclobdell 0:f7c60d3e7b8a 83 if(_register_security){
maclobdell 0:f7c60d3e7b8a 84 delete _register_security;
maclobdell 0:f7c60d3e7b8a 85 }
maclobdell 0:f7c60d3e7b8a 86 }
maclobdell 0:f7c60d3e7b8a 87
maclobdell 0:f7c60d3e7b8a 88 // debug printf function
maclobdell 0:f7c60d3e7b8a 89 void trace_printer(const char* str) {
maclobdell 0:f7c60d3e7b8a 90 printf("\r\n%s\r\n", str);
maclobdell 0:f7c60d3e7b8a 91 }
maclobdell 0:f7c60d3e7b8a 92
maclobdell 0:f7c60d3e7b8a 93 /*
maclobdell 0:f7c60d3e7b8a 94 * Creates M2MInterface using which endpoint can
maclobdell 0:f7c60d3e7b8a 95 * setup its name, resource type, life time, connection mode,
maclobdell 0:f7c60d3e7b8a 96 * Currently only LwIPv4 is supported.
maclobdell 0:f7c60d3e7b8a 97 */
maclobdell 0:f7c60d3e7b8a 98 void create_interface() {
maclobdell 0:f7c60d3e7b8a 99 // Randomizing listening port for Certificate mode connectivity
maclobdell 0:f7c60d3e7b8a 100 srand(time(NULL));
maclobdell 0:f7c60d3e7b8a 101 uint16_t port = rand() % 65535 + 12345;
maclobdell 0:f7c60d3e7b8a 102
maclobdell 0:f7c60d3e7b8a 103 // create mDS interface object, this is the base object everything else attaches to
maclobdell 0:f7c60d3e7b8a 104 _interface = M2MInterfaceFactory::create_interface(*this,
maclobdell 0:f7c60d3e7b8a 105 ENDPOINT_NAME, // endpoint name string
maclobdell 0:f7c60d3e7b8a 106 "instrument", // endpoint type string
maclobdell 0:f7c60d3e7b8a 107 100, // lifetime
maclobdell 0:f7c60d3e7b8a 108 port, // listen port
maclobdell 0:f7c60d3e7b8a 109 MBED_USER_NAME_DOMAIN, // domain string
maclobdell 0:f7c60d3e7b8a 110 SOCKET_MODE, // binding mode
maclobdell 0:f7c60d3e7b8a 111 M2MInterface::LwIP_IPv4, // network stack
maclobdell 0:f7c60d3e7b8a 112 ""); // context address string
maclobdell 0:f7c60d3e7b8a 113 String binding_mode;
maclobdell 0:f7c60d3e7b8a 114 (SOCKET_MODE == M2MInterface::UDP) ? binding_mode = "UDP" : binding_mode = "TCP";
maclobdell 0:f7c60d3e7b8a 115 printf("\r\nSOCKET_MODE : %s\r\n", binding_mode.c_str());
maclobdell 0:f7c60d3e7b8a 116 printf("Connecting to %s\r\n", MBED_SERVER_ADDRESS.c_str());
maclobdell 0:f7c60d3e7b8a 117 }
maclobdell 0:f7c60d3e7b8a 118
maclobdell 0:f7c60d3e7b8a 119 /*
maclobdell 0:f7c60d3e7b8a 120 * check private variable to see if the registration was sucessful or not
maclobdell 0:f7c60d3e7b8a 121 */
maclobdell 0:f7c60d3e7b8a 122 bool register_successful() {
maclobdell 0:f7c60d3e7b8a 123 return _registered;
maclobdell 0:f7c60d3e7b8a 124 }
maclobdell 0:f7c60d3e7b8a 125
maclobdell 0:f7c60d3e7b8a 126 /*
maclobdell 0:f7c60d3e7b8a 127 * check private variable to see if un-registration was sucessful or not
maclobdell 0:f7c60d3e7b8a 128 */
maclobdell 0:f7c60d3e7b8a 129 bool unregister_successful() {
maclobdell 0:f7c60d3e7b8a 130 return _unregistered;
maclobdell 0:f7c60d3e7b8a 131 }
maclobdell 0:f7c60d3e7b8a 132
maclobdell 0:f7c60d3e7b8a 133 /*
maclobdell 0:f7c60d3e7b8a 134 * Creates register server object with mbed device server address and other parameters
maclobdell 0:f7c60d3e7b8a 135 * required for client to connect to mbed device server.
maclobdell 0:f7c60d3e7b8a 136 */
maclobdell 0:f7c60d3e7b8a 137 M2MSecurity* create_register_object() {
maclobdell 0:f7c60d3e7b8a 138 // create security object using the interface factory.
maclobdell 0:f7c60d3e7b8a 139 // this will generate a security ObjectID and ObjectInstance
maclobdell 0:f7c60d3e7b8a 140 M2MSecurity *security = M2MInterfaceFactory::create_security(M2MSecurity::M2MServer);
maclobdell 0:f7c60d3e7b8a 141
maclobdell 0:f7c60d3e7b8a 142 // make sure security ObjectID/ObjectInstance was created successfully
maclobdell 0:f7c60d3e7b8a 143 if(security) {
maclobdell 0:f7c60d3e7b8a 144 // Add ResourceID's and values to the security ObjectID/ObjectInstance
maclobdell 0:f7c60d3e7b8a 145 security->set_resource_value(M2MSecurity::M2MServerUri, MBED_SERVER_ADDRESS);
maclobdell 0:f7c60d3e7b8a 146 security->set_resource_value(M2MSecurity::SecurityMode, M2MSecurity::Certificate);
maclobdell 0:f7c60d3e7b8a 147 security->set_resource_value(M2MSecurity::ServerPublicKey, SERVER_CERT, sizeof(SERVER_CERT));
maclobdell 0:f7c60d3e7b8a 148 security->set_resource_value(M2MSecurity::PublicKey, CERT, sizeof(CERT));
maclobdell 0:f7c60d3e7b8a 149 security->set_resource_value(M2MSecurity::Secretkey, KEY, sizeof(KEY));
maclobdell 0:f7c60d3e7b8a 150 }
maclobdell 0:f7c60d3e7b8a 151 return security;
maclobdell 0:f7c60d3e7b8a 152 }
maclobdell 0:f7c60d3e7b8a 153
maclobdell 0:f7c60d3e7b8a 154 /*
maclobdell 0:f7c60d3e7b8a 155 * Creates device object which contains mandatory resources linked with
maclobdell 0:f7c60d3e7b8a 156 * device endpoint.
maclobdell 0:f7c60d3e7b8a 157 */
maclobdell 0:f7c60d3e7b8a 158 M2MDevice* create_device_object() {
maclobdell 0:f7c60d3e7b8a 159 // create device objectID/ObjectInstance
maclobdell 0:f7c60d3e7b8a 160 M2MDevice *device = M2MInterfaceFactory::create_device();
maclobdell 0:f7c60d3e7b8a 161 // make sure device object was created successfully
maclobdell 0:f7c60d3e7b8a 162 if(device) {
maclobdell 0:f7c60d3e7b8a 163 // add resourceID's to device objectID/ObjectInstance
maclobdell 0:f7c60d3e7b8a 164 device->create_resource(M2MDevice::Manufacturer, _device.Manufacturer);
maclobdell 0:f7c60d3e7b8a 165 device->create_resource(M2MDevice::DeviceType, _device.Type);
maclobdell 0:f7c60d3e7b8a 166 device->create_resource(M2MDevice::ModelNumber, _device.ModelNumber);
maclobdell 0:f7c60d3e7b8a 167 device->create_resource(M2MDevice::SerialNumber, _device.SerialNumber);
maclobdell 0:f7c60d3e7b8a 168 }
maclobdell 0:f7c60d3e7b8a 169 return device;
maclobdell 0:f7c60d3e7b8a 170 }
maclobdell 0:f7c60d3e7b8a 171
maclobdell 0:f7c60d3e7b8a 172 /*
maclobdell 0:f7c60d3e7b8a 173 * register an object
maclobdell 0:f7c60d3e7b8a 174 */
maclobdell 0:f7c60d3e7b8a 175 void test_register(M2MSecurity *register_object, M2MObjectList object_list){
maclobdell 0:f7c60d3e7b8a 176 if(_interface) {
maclobdell 0:f7c60d3e7b8a 177 // Register function
maclobdell 0:f7c60d3e7b8a 178 _interface->register_object(register_object, object_list);
maclobdell 0:f7c60d3e7b8a 179 }
maclobdell 0:f7c60d3e7b8a 180 }
maclobdell 0:f7c60d3e7b8a 181
maclobdell 0:f7c60d3e7b8a 182 /*
maclobdell 0:f7c60d3e7b8a 183 * unregister all objects
maclobdell 0:f7c60d3e7b8a 184 */
maclobdell 0:f7c60d3e7b8a 185 void test_unregister() {
maclobdell 0:f7c60d3e7b8a 186 if(_interface) {
maclobdell 0:f7c60d3e7b8a 187 // Unregister function
maclobdell 0:f7c60d3e7b8a 188 _interface->unregister_object(NULL); // NULL will unregister all objects
maclobdell 0:f7c60d3e7b8a 189 }
maclobdell 0:f7c60d3e7b8a 190 }
maclobdell 0:f7c60d3e7b8a 191
maclobdell 0:f7c60d3e7b8a 192 //Callback from mbed client stack when the bootstrap
maclobdell 0:f7c60d3e7b8a 193 // is successful, it returns the mbed Device Server object
maclobdell 0:f7c60d3e7b8a 194 // which will be used for registering the resources to
maclobdell 0:f7c60d3e7b8a 195 // mbed Device server.
maclobdell 0:f7c60d3e7b8a 196 void bootstrap_done(M2MSecurity *server_object){
maclobdell 0:f7c60d3e7b8a 197 if(server_object) {
maclobdell 0:f7c60d3e7b8a 198 _bootstrapped = true;
maclobdell 0:f7c60d3e7b8a 199 _error = false;
maclobdell 0:f7c60d3e7b8a 200 trace_printer("Bootstrapped");
maclobdell 0:f7c60d3e7b8a 201 }
maclobdell 0:f7c60d3e7b8a 202 }
maclobdell 0:f7c60d3e7b8a 203
maclobdell 0:f7c60d3e7b8a 204 //Callback from mbed client stack when the registration
maclobdell 0:f7c60d3e7b8a 205 // is successful, it returns the mbed Device Server object
maclobdell 0:f7c60d3e7b8a 206 // to which the resources are registered and registered objects.
maclobdell 0:f7c60d3e7b8a 207 void object_registered(M2MSecurity */*security_object*/, const M2MServer &/*server_object*/){
maclobdell 0:f7c60d3e7b8a 208 _registered = true;
maclobdell 0:f7c60d3e7b8a 209 _unregistered = false;
maclobdell 0:f7c60d3e7b8a 210 green = 0; //turn led on
maclobdell 0:f7c60d3e7b8a 211 trace_printer("Registered object successfully!");
maclobdell 0:f7c60d3e7b8a 212 }
maclobdell 0:f7c60d3e7b8a 213
maclobdell 0:f7c60d3e7b8a 214 //Callback from mbed client stack when the unregistration
maclobdell 0:f7c60d3e7b8a 215 // is successful, it returns the mbed Device Server object
maclobdell 0:f7c60d3e7b8a 216 // to which the resources were unregistered.
maclobdell 0:f7c60d3e7b8a 217 void object_unregistered(M2MSecurity */*server_object*/){
maclobdell 0:f7c60d3e7b8a 218 trace_printer("Unregistered Object Successfully");
maclobdell 0:f7c60d3e7b8a 219 _unregistered = true;
maclobdell 0:f7c60d3e7b8a 220 _registered = false;
maclobdell 0:f7c60d3e7b8a 221 green = 1; //turn led off
maclobdell 0:f7c60d3e7b8a 222 // notify_completion(_unregistered);
maclobdell 0:f7c60d3e7b8a 223 trace_printer("\nUnregistered\n");
maclobdell 0:f7c60d3e7b8a 224 }
maclobdell 0:f7c60d3e7b8a 225
maclobdell 0:f7c60d3e7b8a 226 /*
maclobdell 0:f7c60d3e7b8a 227 * Callback from mbed client stack when registration is updated
maclobdell 0:f7c60d3e7b8a 228 */
maclobdell 0:f7c60d3e7b8a 229 void registration_updated(M2MSecurity */*security_object*/, const M2MServer & /*server_object*/){
maclobdell 0:f7c60d3e7b8a 230 /* The registration is updated automatically and frequently by the
maclobdell 0:f7c60d3e7b8a 231 * mbed client stack. This print statement is turned off because it
maclobdell 0:f7c60d3e7b8a 232 * tends to happen alot.
maclobdell 0:f7c60d3e7b8a 233 */
maclobdell 0:f7c60d3e7b8a 234 //trace_printer("\r\nRegistration Updated\r\n");
maclobdell 0:f7c60d3e7b8a 235 }
maclobdell 0:f7c60d3e7b8a 236
maclobdell 0:f7c60d3e7b8a 237 // Callback from mbed client stack if any error is encountered
maclobdell 0:f7c60d3e7b8a 238 // during any of the LWM2M operations. Error type is passed in
maclobdell 0:f7c60d3e7b8a 239 // the callback.
maclobdell 0:f7c60d3e7b8a 240 void error(M2MInterface::Error error){
maclobdell 0:f7c60d3e7b8a 241 _error = true;
maclobdell 0:f7c60d3e7b8a 242 switch(error){
maclobdell 0:f7c60d3e7b8a 243 case M2MInterface::AlreadyExists:
maclobdell 0:f7c60d3e7b8a 244 trace_printer("[ERROR:] M2MInterface::AlreadyExist");
maclobdell 0:f7c60d3e7b8a 245 break;
maclobdell 0:f7c60d3e7b8a 246 case M2MInterface::BootstrapFailed:
maclobdell 0:f7c60d3e7b8a 247 trace_printer("[ERROR:] M2MInterface::BootstrapFailed");
maclobdell 0:f7c60d3e7b8a 248 break;
maclobdell 0:f7c60d3e7b8a 249 case M2MInterface::InvalidParameters:
maclobdell 0:f7c60d3e7b8a 250 trace_printer("[ERROR:] M2MInterface::InvalidParameters");
maclobdell 0:f7c60d3e7b8a 251 break;
maclobdell 0:f7c60d3e7b8a 252 case M2MInterface::NotRegistered:
maclobdell 0:f7c60d3e7b8a 253 trace_printer("[ERROR:] M2MInterface::NotRegistered");
maclobdell 0:f7c60d3e7b8a 254 break;
maclobdell 0:f7c60d3e7b8a 255 case M2MInterface::Timeout:
maclobdell 0:f7c60d3e7b8a 256 trace_printer("[ERROR:] M2MInterface::Timeout");
maclobdell 0:f7c60d3e7b8a 257 break;
maclobdell 0:f7c60d3e7b8a 258 case M2MInterface::NetworkError:
maclobdell 0:f7c60d3e7b8a 259 trace_printer("[ERROR:] M2MInterface::NetworkError");
maclobdell 0:f7c60d3e7b8a 260 break;
maclobdell 0:f7c60d3e7b8a 261 case M2MInterface::ResponseParseFailed:
maclobdell 0:f7c60d3e7b8a 262 trace_printer("[ERROR:] M2MInterface::ResponseParseFailed");
maclobdell 0:f7c60d3e7b8a 263 break;
maclobdell 0:f7c60d3e7b8a 264 case M2MInterface::UnknownError:
maclobdell 0:f7c60d3e7b8a 265 trace_printer("[ERROR:] M2MInterface::UnknownError");
maclobdell 0:f7c60d3e7b8a 266 break;
maclobdell 0:f7c60d3e7b8a 267 case M2MInterface::MemoryFail:
maclobdell 0:f7c60d3e7b8a 268 trace_printer("[ERROR:] M2MInterface::MemoryFail");
maclobdell 0:f7c60d3e7b8a 269 break;
maclobdell 0:f7c60d3e7b8a 270 case M2MInterface::NotAllowed:
maclobdell 0:f7c60d3e7b8a 271 trace_printer("[ERROR:] M2MInterface::NotAllowed");
maclobdell 0:f7c60d3e7b8a 272 break;
maclobdell 0:f7c60d3e7b8a 273 default:
maclobdell 0:f7c60d3e7b8a 274 break;
maclobdell 0:f7c60d3e7b8a 275 }
maclobdell 0:f7c60d3e7b8a 276 }
maclobdell 0:f7c60d3e7b8a 277
maclobdell 0:f7c60d3e7b8a 278 /* Callback from mbed client stack if any value has changed
maclobdell 0:f7c60d3e7b8a 279 * during PUT operation. Object and its type is passed in
maclobdell 0:f7c60d3e7b8a 280 * the callback.
maclobdell 0:f7c60d3e7b8a 281 * BaseType enum from m2mbase.h
maclobdell 0:f7c60d3e7b8a 282 * Object = 0x0, Resource = 0x1, ObjectInstance = 0x2, ResourceInstance = 0x3
maclobdell 0:f7c60d3e7b8a 283 */
maclobdell 0:f7c60d3e7b8a 284 void value_updated(M2MBase *base, M2MBase::BaseType type) {
maclobdell 0:f7c60d3e7b8a 285 printf("\r\nPUT Request Received!");
maclobdell 0:f7c60d3e7b8a 286 printf("\r\nName :'%s', \r\nType : '%d' (0 for Object, 1 for Resource), \r\nType : '%s'\r\n",
maclobdell 0:f7c60d3e7b8a 287 base->name().c_str(),
maclobdell 0:f7c60d3e7b8a 288 type,
maclobdell 0:f7c60d3e7b8a 289 base->resource_type().c_str()
maclobdell 0:f7c60d3e7b8a 290 );
maclobdell 0:f7c60d3e7b8a 291 }
maclobdell 0:f7c60d3e7b8a 292
maclobdell 0:f7c60d3e7b8a 293 /*
maclobdell 0:f7c60d3e7b8a 294 * update the registration period
maclobdell 0:f7c60d3e7b8a 295 */
maclobdell 0:f7c60d3e7b8a 296 void test_update_register() {
maclobdell 0:f7c60d3e7b8a 297 if (_registered) {
maclobdell 0:f7c60d3e7b8a 298 _interface->update_registration(_register_security, 100);
maclobdell 0:f7c60d3e7b8a 299 }
maclobdell 0:f7c60d3e7b8a 300 }
maclobdell 0:f7c60d3e7b8a 301
maclobdell 0:f7c60d3e7b8a 302 /*
maclobdell 0:f7c60d3e7b8a 303 * manually configure the security object private variable
maclobdell 0:f7c60d3e7b8a 304 */
maclobdell 0:f7c60d3e7b8a 305 void set_register_object(M2MSecurity *register_object) {
maclobdell 0:f7c60d3e7b8a 306 if (_register_security == NULL) {
maclobdell 0:f7c60d3e7b8a 307 _register_security = register_object;
maclobdell 0:f7c60d3e7b8a 308 }
maclobdell 0:f7c60d3e7b8a 309 }
maclobdell 0:f7c60d3e7b8a 310
maclobdell 0:f7c60d3e7b8a 311 private:
maclobdell 0:f7c60d3e7b8a 312
maclobdell 0:f7c60d3e7b8a 313 /*
maclobdell 0:f7c60d3e7b8a 314 * Private variables used in class
maclobdell 0:f7c60d3e7b8a 315 */
maclobdell 0:f7c60d3e7b8a 316 M2MInterface *_interface;
maclobdell 0:f7c60d3e7b8a 317 M2MSecurity *_register_security;
maclobdell 0:f7c60d3e7b8a 318 M2MObject *_object;
maclobdell 0:f7c60d3e7b8a 319 volatile bool _bootstrapped;
maclobdell 0:f7c60d3e7b8a 320 volatile bool _error;
maclobdell 0:f7c60d3e7b8a 321 volatile bool _registered;
maclobdell 0:f7c60d3e7b8a 322 volatile bool _unregistered;
maclobdell 0:f7c60d3e7b8a 323 int _value;
maclobdell 0:f7c60d3e7b8a 324 struct MbedClientDevice _device;
maclobdell 0:f7c60d3e7b8a 325 };
maclobdell 0:f7c60d3e7b8a 326
maclobdell 0:f7c60d3e7b8a 327 #endif // __SIMPLECLIENT_H__