Ram Gandikota
/
metronome
FRDM K64F Metronome
mbed-client/test/lwm2mtestapplication/lwm2mtest.cpp@0:a2cb7295a1f7, 2017-05-14 (annotated)
- Committer:
- ram54288
- Date:
- Sun May 14 18:35:07 2017 +0000
- Revision:
- 0:a2cb7295a1f7
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ram54288 | 0:a2cb7295a1f7 | 1 | /* |
ram54288 | 0:a2cb7295a1f7 | 2 | * Copyright (c) 2015 ARM Limited. All rights reserved. |
ram54288 | 0:a2cb7295a1f7 | 3 | * SPDX-License-Identifier: Apache-2.0 |
ram54288 | 0:a2cb7295a1f7 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
ram54288 | 0:a2cb7295a1f7 | 5 | * not use this file except in compliance with the License. |
ram54288 | 0:a2cb7295a1f7 | 6 | * You may obtain a copy of the License at |
ram54288 | 0:a2cb7295a1f7 | 7 | * |
ram54288 | 0:a2cb7295a1f7 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
ram54288 | 0:a2cb7295a1f7 | 9 | * |
ram54288 | 0:a2cb7295a1f7 | 10 | * Unless required by applicable law or agreed to in writing, software |
ram54288 | 0:a2cb7295a1f7 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
ram54288 | 0:a2cb7295a1f7 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ram54288 | 0:a2cb7295a1f7 | 13 | * See the License for the specific language governing permissions and |
ram54288 | 0:a2cb7295a1f7 | 14 | * limitations under the License. |
ram54288 | 0:a2cb7295a1f7 | 15 | */ |
ram54288 | 0:a2cb7295a1f7 | 16 | #include "lwm2mtest.h" |
ram54288 | 0:a2cb7295a1f7 | 17 | #include "ns_types.h" |
ram54288 | 0:a2cb7295a1f7 | 18 | #include "ns_cmdline.h" |
ram54288 | 0:a2cb7295a1f7 | 19 | |
ram54288 | 0:a2cb7295a1f7 | 20 | M2MLWClient::M2MLWClient() |
ram54288 | 0:a2cb7295a1f7 | 21 | : _security(NULL), |
ram54288 | 0:a2cb7295a1f7 | 22 | _interface(NULL), |
ram54288 | 0:a2cb7295a1f7 | 23 | _device(NULL), |
ram54288 | 0:a2cb7295a1f7 | 24 | _bootstrapped(false), |
ram54288 | 0:a2cb7295a1f7 | 25 | _error(false), |
ram54288 | 0:a2cb7295a1f7 | 26 | _registered(false), |
ram54288 | 0:a2cb7295a1f7 | 27 | _unregistered(false), |
ram54288 | 0:a2cb7295a1f7 | 28 | _registration_updated(false) |
ram54288 | 0:a2cb7295a1f7 | 29 | { |
ram54288 | 0:a2cb7295a1f7 | 30 | } |
ram54288 | 0:a2cb7295a1f7 | 31 | |
ram54288 | 0:a2cb7295a1f7 | 32 | M2MLWClient::~M2MLWClient() |
ram54288 | 0:a2cb7295a1f7 | 33 | { |
ram54288 | 0:a2cb7295a1f7 | 34 | if(_interface) { |
ram54288 | 0:a2cb7295a1f7 | 35 | delete _interface; |
ram54288 | 0:a2cb7295a1f7 | 36 | } |
ram54288 | 0:a2cb7295a1f7 | 37 | if(_security) { |
ram54288 | 0:a2cb7295a1f7 | 38 | delete _security; |
ram54288 | 0:a2cb7295a1f7 | 39 | } |
ram54288 | 0:a2cb7295a1f7 | 40 | if( _register_security){ |
ram54288 | 0:a2cb7295a1f7 | 41 | delete _register_security; |
ram54288 | 0:a2cb7295a1f7 | 42 | } |
ram54288 | 0:a2cb7295a1f7 | 43 | } |
ram54288 | 0:a2cb7295a1f7 | 44 | |
ram54288 | 0:a2cb7295a1f7 | 45 | |
ram54288 | 0:a2cb7295a1f7 | 46 | bool M2MLWClient::create_interface(int32_t param_count, |
ram54288 | 0:a2cb7295a1f7 | 47 | const char *endpoint, |
ram54288 | 0:a2cb7295a1f7 | 48 | const char *resource_type, |
ram54288 | 0:a2cb7295a1f7 | 49 | const int32_t lifetime, |
ram54288 | 0:a2cb7295a1f7 | 50 | const uint16_t listen_port, |
ram54288 | 0:a2cb7295a1f7 | 51 | const char *domain, |
ram54288 | 0:a2cb7295a1f7 | 52 | const uint8_t binding_mode, |
ram54288 | 0:a2cb7295a1f7 | 53 | const uint8_t network_interface) |
ram54288 | 0:a2cb7295a1f7 | 54 | { |
ram54288 | 0:a2cb7295a1f7 | 55 | if(_interface) { |
ram54288 | 0:a2cb7295a1f7 | 56 | delete _interface; |
ram54288 | 0:a2cb7295a1f7 | 57 | _interface = NULL; |
ram54288 | 0:a2cb7295a1f7 | 58 | } |
ram54288 | 0:a2cb7295a1f7 | 59 | String ep; |
ram54288 | 0:a2cb7295a1f7 | 60 | String rt; |
ram54288 | 0:a2cb7295a1f7 | 61 | String dmn; |
ram54288 | 0:a2cb7295a1f7 | 62 | if(endpoint) { |
ram54288 | 0:a2cb7295a1f7 | 63 | ep += endpoint; |
ram54288 | 0:a2cb7295a1f7 | 64 | } |
ram54288 | 0:a2cb7295a1f7 | 65 | if(resource_type) { |
ram54288 | 0:a2cb7295a1f7 | 66 | rt += resource_type; |
ram54288 | 0:a2cb7295a1f7 | 67 | } |
ram54288 | 0:a2cb7295a1f7 | 68 | if(domain) { |
ram54288 | 0:a2cb7295a1f7 | 69 | dmn += domain; |
ram54288 | 0:a2cb7295a1f7 | 70 | } |
ram54288 | 0:a2cb7295a1f7 | 71 | |
ram54288 | 0:a2cb7295a1f7 | 72 | // Binding mode cannot be higher than 0x07 since it is an enum, check M2MInterface::BindingMode |
ram54288 | 0:a2cb7295a1f7 | 73 | if(binding_mode > 0x07) { |
ram54288 | 0:a2cb7295a1f7 | 74 | return false; |
ram54288 | 0:a2cb7295a1f7 | 75 | } |
ram54288 | 0:a2cb7295a1f7 | 76 | |
ram54288 | 0:a2cb7295a1f7 | 77 | switch (param_count) { |
ram54288 | 0:a2cb7295a1f7 | 78 | case 0: |
ram54288 | 0:a2cb7295a1f7 | 79 | _interface = M2MInterfaceFactory::create_interface(*this, ep, rt); |
ram54288 | 0:a2cb7295a1f7 | 80 | break; |
ram54288 | 0:a2cb7295a1f7 | 81 | case 1: |
ram54288 | 0:a2cb7295a1f7 | 82 | _interface = M2MInterfaceFactory::create_interface(*this, ep, rt, lifetime); |
ram54288 | 0:a2cb7295a1f7 | 83 | break; |
ram54288 | 0:a2cb7295a1f7 | 84 | case 2: |
ram54288 | 0:a2cb7295a1f7 | 85 | _interface = M2MInterfaceFactory::create_interface(*this, ep, rt, lifetime, listen_port); |
ram54288 | 0:a2cb7295a1f7 | 86 | break; |
ram54288 | 0:a2cb7295a1f7 | 87 | case 3: |
ram54288 | 0:a2cb7295a1f7 | 88 | _interface = M2MInterfaceFactory::create_interface(*this, ep, rt, lifetime, listen_port, dmn); |
ram54288 | 0:a2cb7295a1f7 | 89 | break; |
ram54288 | 0:a2cb7295a1f7 | 90 | case 4: |
ram54288 | 0:a2cb7295a1f7 | 91 | _interface = M2MInterfaceFactory::create_interface(*this, ep, rt, lifetime, listen_port, dmn, (M2MInterface::BindingMode)binding_mode); |
ram54288 | 0:a2cb7295a1f7 | 92 | break; |
ram54288 | 0:a2cb7295a1f7 | 93 | case 5: |
ram54288 | 0:a2cb7295a1f7 | 94 | _interface = M2MInterfaceFactory::create_interface(*this, ep, rt, lifetime, listen_port, dmn, (M2MInterface::BindingMode)binding_mode, (M2MInterface::NetworkStack)network_interface); |
ram54288 | 0:a2cb7295a1f7 | 95 | break; |
ram54288 | 0:a2cb7295a1f7 | 96 | } |
ram54288 | 0:a2cb7295a1f7 | 97 | return (_interface == NULL) ? false : true; |
ram54288 | 0:a2cb7295a1f7 | 98 | } |
ram54288 | 0:a2cb7295a1f7 | 99 | |
ram54288 | 0:a2cb7295a1f7 | 100 | bool M2MLWClient::create_bootstrap_object(const char *coap_bootstrap_address) |
ram54288 | 0:a2cb7295a1f7 | 101 | { |
ram54288 | 0:a2cb7295a1f7 | 102 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 103 | String address; |
ram54288 | 0:a2cb7295a1f7 | 104 | if(coap_bootstrap_address) { |
ram54288 | 0:a2cb7295a1f7 | 105 | address += coap_bootstrap_address; |
ram54288 | 0:a2cb7295a1f7 | 106 | } |
ram54288 | 0:a2cb7295a1f7 | 107 | if(_security) { |
ram54288 | 0:a2cb7295a1f7 | 108 | delete _security; |
ram54288 | 0:a2cb7295a1f7 | 109 | } |
ram54288 | 0:a2cb7295a1f7 | 110 | _security = M2MInterfaceFactory::create_security(M2MSecurity::Bootstrap); |
ram54288 | 0:a2cb7295a1f7 | 111 | if(_security) { |
ram54288 | 0:a2cb7295a1f7 | 112 | if(_security->set_resource_value(M2MSecurity::M2MServerUri, address) && |
ram54288 | 0:a2cb7295a1f7 | 113 | _security->set_resource_value(M2MSecurity::SecurityMode, M2MSecurity::NoSecurity)) { |
ram54288 | 0:a2cb7295a1f7 | 114 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 115 | } |
ram54288 | 0:a2cb7295a1f7 | 116 | } |
ram54288 | 0:a2cb7295a1f7 | 117 | return success; |
ram54288 | 0:a2cb7295a1f7 | 118 | } |
ram54288 | 0:a2cb7295a1f7 | 119 | |
ram54288 | 0:a2cb7295a1f7 | 120 | bool M2MLWClient::create_register_object(const char *coap_register_address, bool useSecureConn) |
ram54288 | 0:a2cb7295a1f7 | 121 | { |
ram54288 | 0:a2cb7295a1f7 | 122 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 123 | String address; |
ram54288 | 0:a2cb7295a1f7 | 124 | if(coap_register_address) { |
ram54288 | 0:a2cb7295a1f7 | 125 | address += coap_register_address; |
ram54288 | 0:a2cb7295a1f7 | 126 | } |
ram54288 | 0:a2cb7295a1f7 | 127 | if(_register_security) { |
ram54288 | 0:a2cb7295a1f7 | 128 | delete _register_security; |
ram54288 | 0:a2cb7295a1f7 | 129 | } |
ram54288 | 0:a2cb7295a1f7 | 130 | _register_security = M2MInterfaceFactory::create_security(M2MSecurity::M2MServer); |
ram54288 | 0:a2cb7295a1f7 | 131 | if(_register_security) { |
ram54288 | 0:a2cb7295a1f7 | 132 | if( !useSecureConn ){ |
ram54288 | 0:a2cb7295a1f7 | 133 | if(_register_security->set_resource_value(M2MSecurity::M2MServerUri, address) && |
ram54288 | 0:a2cb7295a1f7 | 134 | _register_security->set_resource_value(M2MSecurity::SecurityMode, M2MSecurity::NoSecurity)) { |
ram54288 | 0:a2cb7295a1f7 | 135 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 136 | } |
ram54288 | 0:a2cb7295a1f7 | 137 | }else{ |
ram54288 | 0:a2cb7295a1f7 | 138 | if(_register_security->set_resource_value(M2MSecurity::M2MServerUri, address) && |
ram54288 | 0:a2cb7295a1f7 | 139 | _register_security->set_resource_value(M2MSecurity::SecurityMode, M2MSecurity::Certificate) && |
ram54288 | 0:a2cb7295a1f7 | 140 | _register_security->set_resource_value(M2MSecurity::ServerPublicKey,server_cert,server_cert_len) && |
ram54288 | 0:a2cb7295a1f7 | 141 | _register_security->set_resource_value(M2MSecurity::PublicKey,cert,cert_len) && |
ram54288 | 0:a2cb7295a1f7 | 142 | _register_security->set_resource_value(M2MSecurity::Secretkey,key,key_len) ){ |
ram54288 | 0:a2cb7295a1f7 | 143 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 144 | } |
ram54288 | 0:a2cb7295a1f7 | 145 | } |
ram54288 | 0:a2cb7295a1f7 | 146 | } |
ram54288 | 0:a2cb7295a1f7 | 147 | return success; |
ram54288 | 0:a2cb7295a1f7 | 148 | } |
ram54288 | 0:a2cb7295a1f7 | 149 | |
ram54288 | 0:a2cb7295a1f7 | 150 | bool M2MLWClient::test_bootstrap() |
ram54288 | 0:a2cb7295a1f7 | 151 | { |
ram54288 | 0:a2cb7295a1f7 | 152 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 153 | if(_interface) { |
ram54288 | 0:a2cb7295a1f7 | 154 | _interface->bootstrap(_security); |
ram54288 | 0:a2cb7295a1f7 | 155 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 156 | } |
ram54288 | 0:a2cb7295a1f7 | 157 | return success; |
ram54288 | 0:a2cb7295a1f7 | 158 | } |
ram54288 | 0:a2cb7295a1f7 | 159 | |
ram54288 | 0:a2cb7295a1f7 | 160 | bool M2MLWClient::create_device_object(M2MDevice::DeviceResource resource, |
ram54288 | 0:a2cb7295a1f7 | 161 | const char *value) |
ram54288 | 0:a2cb7295a1f7 | 162 | { |
ram54288 | 0:a2cb7295a1f7 | 163 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 164 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 165 | if(value) { |
ram54288 | 0:a2cb7295a1f7 | 166 | value_string += value; |
ram54288 | 0:a2cb7295a1f7 | 167 | } |
ram54288 | 0:a2cb7295a1f7 | 168 | if(!_device) { |
ram54288 | 0:a2cb7295a1f7 | 169 | _device = M2MInterfaceFactory::create_device(); |
ram54288 | 0:a2cb7295a1f7 | 170 | } |
ram54288 | 0:a2cb7295a1f7 | 171 | if(_device) { |
ram54288 | 0:a2cb7295a1f7 | 172 | |
ram54288 | 0:a2cb7295a1f7 | 173 | if(_device->create_resource(resource,value_string)){ |
ram54288 | 0:a2cb7295a1f7 | 174 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 175 | } else { |
ram54288 | 0:a2cb7295a1f7 | 176 | success = _device->set_resource_value(resource,value); |
ram54288 | 0:a2cb7295a1f7 | 177 | } |
ram54288 | 0:a2cb7295a1f7 | 178 | } |
ram54288 | 0:a2cb7295a1f7 | 179 | return success; |
ram54288 | 0:a2cb7295a1f7 | 180 | } |
ram54288 | 0:a2cb7295a1f7 | 181 | |
ram54288 | 0:a2cb7295a1f7 | 182 | bool M2MLWClient::create_device_object() |
ram54288 | 0:a2cb7295a1f7 | 183 | { |
ram54288 | 0:a2cb7295a1f7 | 184 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 185 | if(!_device) { |
ram54288 | 0:a2cb7295a1f7 | 186 | _device = M2MInterfaceFactory::create_device(); |
ram54288 | 0:a2cb7295a1f7 | 187 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 188 | } |
ram54288 | 0:a2cb7295a1f7 | 189 | return success; |
ram54288 | 0:a2cb7295a1f7 | 190 | } |
ram54288 | 0:a2cb7295a1f7 | 191 | |
ram54288 | 0:a2cb7295a1f7 | 192 | bool M2MLWClient::create_device_object(M2MDevice::DeviceResource resource, |
ram54288 | 0:a2cb7295a1f7 | 193 | int64_t value) |
ram54288 | 0:a2cb7295a1f7 | 194 | { |
ram54288 | 0:a2cb7295a1f7 | 195 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 196 | if(!_device) { |
ram54288 | 0:a2cb7295a1f7 | 197 | _device = M2MInterfaceFactory::create_device(); |
ram54288 | 0:a2cb7295a1f7 | 198 | } |
ram54288 | 0:a2cb7295a1f7 | 199 | if(_device) { |
ram54288 | 0:a2cb7295a1f7 | 200 | if(_device->create_resource(resource,value)) { |
ram54288 | 0:a2cb7295a1f7 | 201 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 202 | } else { |
ram54288 | 0:a2cb7295a1f7 | 203 | success = _device->set_resource_value(resource, value); |
ram54288 | 0:a2cb7295a1f7 | 204 | } |
ram54288 | 0:a2cb7295a1f7 | 205 | } |
ram54288 | 0:a2cb7295a1f7 | 206 | return success; |
ram54288 | 0:a2cb7295a1f7 | 207 | } |
ram54288 | 0:a2cb7295a1f7 | 208 | |
ram54288 | 0:a2cb7295a1f7 | 209 | bool M2MLWClient::create_device_object(M2MDevice::DeviceResource resource, |
ram54288 | 0:a2cb7295a1f7 | 210 | int64_t value, |
ram54288 | 0:a2cb7295a1f7 | 211 | uint16_t instance_id) |
ram54288 | 0:a2cb7295a1f7 | 212 | { |
ram54288 | 0:a2cb7295a1f7 | 213 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 214 | if(!_device) { |
ram54288 | 0:a2cb7295a1f7 | 215 | _device = M2MInterfaceFactory::create_device(); |
ram54288 | 0:a2cb7295a1f7 | 216 | } |
ram54288 | 0:a2cb7295a1f7 | 217 | if(_device) { |
ram54288 | 0:a2cb7295a1f7 | 218 | if(_device->create_resource_instance(resource,value,instance_id)) { |
ram54288 | 0:a2cb7295a1f7 | 219 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 220 | } else { |
ram54288 | 0:a2cb7295a1f7 | 221 | success = _device->set_resource_value(resource, |
ram54288 | 0:a2cb7295a1f7 | 222 | value, |
ram54288 | 0:a2cb7295a1f7 | 223 | instance_id); |
ram54288 | 0:a2cb7295a1f7 | 224 | } |
ram54288 | 0:a2cb7295a1f7 | 225 | } |
ram54288 | 0:a2cb7295a1f7 | 226 | return success; |
ram54288 | 0:a2cb7295a1f7 | 227 | } |
ram54288 | 0:a2cb7295a1f7 | 228 | |
ram54288 | 0:a2cb7295a1f7 | 229 | bool M2MLWClient::create_firmware_object(M2MFirmware::FirmwareResource resource, |
ram54288 | 0:a2cb7295a1f7 | 230 | const char *value) |
ram54288 | 0:a2cb7295a1f7 | 231 | { |
ram54288 | 0:a2cb7295a1f7 | 232 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 233 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 234 | if(value) { |
ram54288 | 0:a2cb7295a1f7 | 235 | value_string += value; |
ram54288 | 0:a2cb7295a1f7 | 236 | } |
ram54288 | 0:a2cb7295a1f7 | 237 | if(!_firmware) { |
ram54288 | 0:a2cb7295a1f7 | 238 | _firmware = M2MInterfaceFactory::create_firmware(); |
ram54288 | 0:a2cb7295a1f7 | 239 | } |
ram54288 | 0:a2cb7295a1f7 | 240 | if(_firmware) { |
ram54288 | 0:a2cb7295a1f7 | 241 | if(_firmware->create_resource(resource,value_string)){ |
ram54288 | 0:a2cb7295a1f7 | 242 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 243 | } else { |
ram54288 | 0:a2cb7295a1f7 | 244 | success = _firmware->set_resource_value(resource,value); |
ram54288 | 0:a2cb7295a1f7 | 245 | } |
ram54288 | 0:a2cb7295a1f7 | 246 | } |
ram54288 | 0:a2cb7295a1f7 | 247 | return success; |
ram54288 | 0:a2cb7295a1f7 | 248 | } |
ram54288 | 0:a2cb7295a1f7 | 249 | |
ram54288 | 0:a2cb7295a1f7 | 250 | bool M2MLWClient::create_firmware_object() |
ram54288 | 0:a2cb7295a1f7 | 251 | { |
ram54288 | 0:a2cb7295a1f7 | 252 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 253 | if(!_firmware) { |
ram54288 | 0:a2cb7295a1f7 | 254 | _firmware = M2MInterfaceFactory::create_firmware(); |
ram54288 | 0:a2cb7295a1f7 | 255 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 256 | } |
ram54288 | 0:a2cb7295a1f7 | 257 | return success; |
ram54288 | 0:a2cb7295a1f7 | 258 | } |
ram54288 | 0:a2cb7295a1f7 | 259 | |
ram54288 | 0:a2cb7295a1f7 | 260 | bool M2MLWClient::create_firmware_object(M2MFirmware::FirmwareResource resource, |
ram54288 | 0:a2cb7295a1f7 | 261 | int64_t value) |
ram54288 | 0:a2cb7295a1f7 | 262 | { |
ram54288 | 0:a2cb7295a1f7 | 263 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 264 | if(!_firmware) { |
ram54288 | 0:a2cb7295a1f7 | 265 | _firmware = M2MInterfaceFactory::create_firmware(); |
ram54288 | 0:a2cb7295a1f7 | 266 | } |
ram54288 | 0:a2cb7295a1f7 | 267 | if(_firmware) { |
ram54288 | 0:a2cb7295a1f7 | 268 | if(_firmware->create_resource(resource,value)) { |
ram54288 | 0:a2cb7295a1f7 | 269 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 270 | } else { |
ram54288 | 0:a2cb7295a1f7 | 271 | success = _firmware->set_resource_value(resource, value); |
ram54288 | 0:a2cb7295a1f7 | 272 | } |
ram54288 | 0:a2cb7295a1f7 | 273 | } |
ram54288 | 0:a2cb7295a1f7 | 274 | return success; |
ram54288 | 0:a2cb7295a1f7 | 275 | } |
ram54288 | 0:a2cb7295a1f7 | 276 | |
ram54288 | 0:a2cb7295a1f7 | 277 | bool M2MLWClient::create_firmware_object(M2MFirmware::FirmwareResource resource, |
ram54288 | 0:a2cb7295a1f7 | 278 | const uint8_t *value, |
ram54288 | 0:a2cb7295a1f7 | 279 | const uint32_t length) |
ram54288 | 0:a2cb7295a1f7 | 280 | { |
ram54288 | 0:a2cb7295a1f7 | 281 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 282 | if(!_firmware) { |
ram54288 | 0:a2cb7295a1f7 | 283 | _firmware = M2MInterfaceFactory::create_firmware(); |
ram54288 | 0:a2cb7295a1f7 | 284 | } |
ram54288 | 0:a2cb7295a1f7 | 285 | if(_firmware) { |
ram54288 | 0:a2cb7295a1f7 | 286 | success = _firmware->set_resource_value(resource, value, length); |
ram54288 | 0:a2cb7295a1f7 | 287 | } |
ram54288 | 0:a2cb7295a1f7 | 288 | return success; |
ram54288 | 0:a2cb7295a1f7 | 289 | } |
ram54288 | 0:a2cb7295a1f7 | 290 | |
ram54288 | 0:a2cb7295a1f7 | 291 | void M2MLWClient::set_fw_execute_function() |
ram54288 | 0:a2cb7295a1f7 | 292 | { |
ram54288 | 0:a2cb7295a1f7 | 293 | if(_firmware) { |
ram54288 | 0:a2cb7295a1f7 | 294 | M2MObjectInstance *inst = _firmware->object_instance(0); |
ram54288 | 0:a2cb7295a1f7 | 295 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 296 | M2MResource *res = inst->resource("2"); |
ram54288 | 0:a2cb7295a1f7 | 297 | if (res) { |
ram54288 | 0:a2cb7295a1f7 | 298 | res->set_execute_function(execute_callback( |
ram54288 | 0:a2cb7295a1f7 | 299 | this, |
ram54288 | 0:a2cb7295a1f7 | 300 | &M2MLWClient::fw_execute_function)); |
ram54288 | 0:a2cb7295a1f7 | 301 | } |
ram54288 | 0:a2cb7295a1f7 | 302 | } |
ram54288 | 0:a2cb7295a1f7 | 303 | } |
ram54288 | 0:a2cb7295a1f7 | 304 | } |
ram54288 | 0:a2cb7295a1f7 | 305 | |
ram54288 | 0:a2cb7295a1f7 | 306 | bool M2MLWClient::create_object(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 307 | bool new_instance, |
ram54288 | 0:a2cb7295a1f7 | 308 | uint8_t object_operation, |
ram54288 | 0:a2cb7295a1f7 | 309 | uint8_t object_instance_operation, |
ram54288 | 0:a2cb7295a1f7 | 310 | uint16_t object_instance_id, |
ram54288 | 0:a2cb7295a1f7 | 311 | bool object_observable, |
ram54288 | 0:a2cb7295a1f7 | 312 | bool object_instance_observable) |
ram54288 | 0:a2cb7295a1f7 | 313 | { |
ram54288 | 0:a2cb7295a1f7 | 314 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 315 | M2MObjectInstance *inst = NULL; |
ram54288 | 0:a2cb7295a1f7 | 316 | if(!_object) { |
ram54288 | 0:a2cb7295a1f7 | 317 | _object = M2MInterfaceFactory::create_object(name); |
ram54288 | 0:a2cb7295a1f7 | 318 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 319 | _object->set_operation(int_to_operation(object_operation)); |
ram54288 | 0:a2cb7295a1f7 | 320 | _object->set_observable(object_observable); |
ram54288 | 0:a2cb7295a1f7 | 321 | inst = _object->create_object_instance(object_instance_id); |
ram54288 | 0:a2cb7295a1f7 | 322 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 323 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 324 | inst->set_operation(int_to_operation(object_instance_operation)); |
ram54288 | 0:a2cb7295a1f7 | 325 | inst->set_observable(object_instance_observable); |
ram54288 | 0:a2cb7295a1f7 | 326 | } |
ram54288 | 0:a2cb7295a1f7 | 327 | } |
ram54288 | 0:a2cb7295a1f7 | 328 | } else { |
ram54288 | 0:a2cb7295a1f7 | 329 | if(new_instance) { |
ram54288 | 0:a2cb7295a1f7 | 330 | inst = _object->create_object_instance(object_instance_id); |
ram54288 | 0:a2cb7295a1f7 | 331 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 332 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 333 | inst->set_operation(int_to_operation(object_instance_operation)); |
ram54288 | 0:a2cb7295a1f7 | 334 | inst->set_observable(object_instance_observable); |
ram54288 | 0:a2cb7295a1f7 | 335 | } |
ram54288 | 0:a2cb7295a1f7 | 336 | } |
ram54288 | 0:a2cb7295a1f7 | 337 | } |
ram54288 | 0:a2cb7295a1f7 | 338 | return success; |
ram54288 | 0:a2cb7295a1f7 | 339 | } |
ram54288 | 0:a2cb7295a1f7 | 340 | |
ram54288 | 0:a2cb7295a1f7 | 341 | bool M2MLWClient::create_static_resource_string(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 342 | const char *value, |
ram54288 | 0:a2cb7295a1f7 | 343 | bool multiple_instance, |
ram54288 | 0:a2cb7295a1f7 | 344 | uint16_t object_instance) |
ram54288 | 0:a2cb7295a1f7 | 345 | { |
ram54288 | 0:a2cb7295a1f7 | 346 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 347 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 348 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 349 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 350 | } |
ram54288 | 0:a2cb7295a1f7 | 351 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 352 | if(value) { |
ram54288 | 0:a2cb7295a1f7 | 353 | value_string += value; |
ram54288 | 0:a2cb7295a1f7 | 354 | } |
ram54288 | 0:a2cb7295a1f7 | 355 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 356 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 357 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 358 | if(inst->create_static_resource(name,"resource", |
ram54288 | 0:a2cb7295a1f7 | 359 | M2MResourceInstance::STRING, |
ram54288 | 0:a2cb7295a1f7 | 360 | (const uint8_t*)value_string.c_str(), |
ram54288 | 0:a2cb7295a1f7 | 361 | value_string.size()) != NULL) { |
ram54288 | 0:a2cb7295a1f7 | 362 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 363 | } |
ram54288 | 0:a2cb7295a1f7 | 364 | } |
ram54288 | 0:a2cb7295a1f7 | 365 | } |
ram54288 | 0:a2cb7295a1f7 | 366 | return success; |
ram54288 | 0:a2cb7295a1f7 | 367 | } |
ram54288 | 0:a2cb7295a1f7 | 368 | |
ram54288 | 0:a2cb7295a1f7 | 369 | bool M2MLWClient::create_static_resource_int(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 370 | int64_t value, |
ram54288 | 0:a2cb7295a1f7 | 371 | bool multiple_instance, |
ram54288 | 0:a2cb7295a1f7 | 372 | uint16_t object_instance) |
ram54288 | 0:a2cb7295a1f7 | 373 | { |
ram54288 | 0:a2cb7295a1f7 | 374 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 375 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 376 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 377 | |
ram54288 | 0:a2cb7295a1f7 | 378 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 379 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 380 | } |
ram54288 | 0:a2cb7295a1f7 | 381 | |
ram54288 | 0:a2cb7295a1f7 | 382 | char value_buffer[20]; |
ram54288 | 0:a2cb7295a1f7 | 383 | sprintf(value_buffer,"%ld",value); |
ram54288 | 0:a2cb7295a1f7 | 384 | value_string += value_buffer; |
ram54288 | 0:a2cb7295a1f7 | 385 | |
ram54288 | 0:a2cb7295a1f7 | 386 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 387 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 388 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 389 | if(inst->create_static_resource(name,"resource", |
ram54288 | 0:a2cb7295a1f7 | 390 | M2MResourceInstance::INTEGER, |
ram54288 | 0:a2cb7295a1f7 | 391 | (const uint8_t*)value_string.c_str(), |
ram54288 | 0:a2cb7295a1f7 | 392 | value_string.size()) != NULL) { |
ram54288 | 0:a2cb7295a1f7 | 393 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 394 | } |
ram54288 | 0:a2cb7295a1f7 | 395 | } |
ram54288 | 0:a2cb7295a1f7 | 396 | } |
ram54288 | 0:a2cb7295a1f7 | 397 | return success; |
ram54288 | 0:a2cb7295a1f7 | 398 | } |
ram54288 | 0:a2cb7295a1f7 | 399 | |
ram54288 | 0:a2cb7295a1f7 | 400 | bool M2MLWClient::create_dynamic_resource_string(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 401 | bool observable, |
ram54288 | 0:a2cb7295a1f7 | 402 | bool multiple_instance, |
ram54288 | 0:a2cb7295a1f7 | 403 | uint16_t object_instance, |
ram54288 | 0:a2cb7295a1f7 | 404 | uint8_t resource_operation) |
ram54288 | 0:a2cb7295a1f7 | 405 | { |
ram54288 | 0:a2cb7295a1f7 | 406 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 407 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 408 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 409 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 410 | } |
ram54288 | 0:a2cb7295a1f7 | 411 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 412 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 413 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 414 | M2MResource *res = inst->create_dynamic_resource(name,"resource", |
ram54288 | 0:a2cb7295a1f7 | 415 | M2MResourceInstance::STRING, |
ram54288 | 0:a2cb7295a1f7 | 416 | observable, multiple_instance); |
ram54288 | 0:a2cb7295a1f7 | 417 | if(res) { |
ram54288 | 0:a2cb7295a1f7 | 418 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 419 | res->set_operation(int_to_operation(resource_operation)); |
ram54288 | 0:a2cb7295a1f7 | 420 | } |
ram54288 | 0:a2cb7295a1f7 | 421 | } |
ram54288 | 0:a2cb7295a1f7 | 422 | } |
ram54288 | 0:a2cb7295a1f7 | 423 | return success; |
ram54288 | 0:a2cb7295a1f7 | 424 | } |
ram54288 | 0:a2cb7295a1f7 | 425 | |
ram54288 | 0:a2cb7295a1f7 | 426 | bool M2MLWClient::create_dynamic_resource_int(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 427 | bool observable, |
ram54288 | 0:a2cb7295a1f7 | 428 | bool multiple_instance, |
ram54288 | 0:a2cb7295a1f7 | 429 | uint16_t object_instance, |
ram54288 | 0:a2cb7295a1f7 | 430 | uint8_t resource_operation) |
ram54288 | 0:a2cb7295a1f7 | 431 | { |
ram54288 | 0:a2cb7295a1f7 | 432 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 433 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 434 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 435 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 436 | } |
ram54288 | 0:a2cb7295a1f7 | 437 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 438 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 439 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 440 | M2MResource *res = inst->create_dynamic_resource(name,"resource", |
ram54288 | 0:a2cb7295a1f7 | 441 | M2MResourceInstance::INTEGER, |
ram54288 | 0:a2cb7295a1f7 | 442 | observable, multiple_instance); |
ram54288 | 0:a2cb7295a1f7 | 443 | if(res) { |
ram54288 | 0:a2cb7295a1f7 | 444 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 445 | res->set_operation(int_to_operation(resource_operation)); |
ram54288 | 0:a2cb7295a1f7 | 446 | } |
ram54288 | 0:a2cb7295a1f7 | 447 | } |
ram54288 | 0:a2cb7295a1f7 | 448 | } |
ram54288 | 0:a2cb7295a1f7 | 449 | return success; |
ram54288 | 0:a2cb7295a1f7 | 450 | } |
ram54288 | 0:a2cb7295a1f7 | 451 | |
ram54288 | 0:a2cb7295a1f7 | 452 | bool M2MLWClient::set_resource_value(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 453 | int32_t value, |
ram54288 | 0:a2cb7295a1f7 | 454 | uint16_t object_instance) |
ram54288 | 0:a2cb7295a1f7 | 455 | { |
ram54288 | 0:a2cb7295a1f7 | 456 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 457 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 458 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 459 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 460 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 461 | } |
ram54288 | 0:a2cb7295a1f7 | 462 | |
ram54288 | 0:a2cb7295a1f7 | 463 | char value_buffer[20]; |
ram54288 | 0:a2cb7295a1f7 | 464 | sprintf(value_buffer,"%d",value); |
ram54288 | 0:a2cb7295a1f7 | 465 | value_string += value_buffer; |
ram54288 | 0:a2cb7295a1f7 | 466 | |
ram54288 | 0:a2cb7295a1f7 | 467 | if(_object && name_string.length() > 0) { |
ram54288 | 0:a2cb7295a1f7 | 468 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 469 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 470 | M2MResource *res = inst->resource(name_string); |
ram54288 | 0:a2cb7295a1f7 | 471 | if (res) { |
ram54288 | 0:a2cb7295a1f7 | 472 | if (res->set_value((const uint8_t*)value_string.c_str(), value_string.size())) { |
ram54288 | 0:a2cb7295a1f7 | 473 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 474 | } |
ram54288 | 0:a2cb7295a1f7 | 475 | } |
ram54288 | 0:a2cb7295a1f7 | 476 | } |
ram54288 | 0:a2cb7295a1f7 | 477 | } |
ram54288 | 0:a2cb7295a1f7 | 478 | return success; |
ram54288 | 0:a2cb7295a1f7 | 479 | } |
ram54288 | 0:a2cb7295a1f7 | 480 | |
ram54288 | 0:a2cb7295a1f7 | 481 | bool M2MLWClient::set_resource_value(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 482 | const char *value, |
ram54288 | 0:a2cb7295a1f7 | 483 | uint16_t object_instance) |
ram54288 | 0:a2cb7295a1f7 | 484 | { |
ram54288 | 0:a2cb7295a1f7 | 485 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 486 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 487 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 488 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 489 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 490 | } |
ram54288 | 0:a2cb7295a1f7 | 491 | if(value) { |
ram54288 | 0:a2cb7295a1f7 | 492 | value_string += value; |
ram54288 | 0:a2cb7295a1f7 | 493 | } |
ram54288 | 0:a2cb7295a1f7 | 494 | |
ram54288 | 0:a2cb7295a1f7 | 495 | if(_object && name_string.length() > 0) { |
ram54288 | 0:a2cb7295a1f7 | 496 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 497 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 498 | M2MResource *res = inst->resource(name_string); |
ram54288 | 0:a2cb7295a1f7 | 499 | if (res) { |
ram54288 | 0:a2cb7295a1f7 | 500 | if (res->set_value((const uint8_t*)value_string.c_str(), value_string.size())) { |
ram54288 | 0:a2cb7295a1f7 | 501 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 502 | } |
ram54288 | 0:a2cb7295a1f7 | 503 | } |
ram54288 | 0:a2cb7295a1f7 | 504 | } |
ram54288 | 0:a2cb7295a1f7 | 505 | } |
ram54288 | 0:a2cb7295a1f7 | 506 | return success; |
ram54288 | 0:a2cb7295a1f7 | 507 | } |
ram54288 | 0:a2cb7295a1f7 | 508 | |
ram54288 | 0:a2cb7295a1f7 | 509 | bool M2MLWClient::create_static_resource_instance_string(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 510 | const char *value, |
ram54288 | 0:a2cb7295a1f7 | 511 | bool multiple_instance, |
ram54288 | 0:a2cb7295a1f7 | 512 | uint16_t object_instance, |
ram54288 | 0:a2cb7295a1f7 | 513 | uint16_t resource_instance) |
ram54288 | 0:a2cb7295a1f7 | 514 | { |
ram54288 | 0:a2cb7295a1f7 | 515 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 516 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 517 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 518 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 519 | } |
ram54288 | 0:a2cb7295a1f7 | 520 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 521 | if(value) { |
ram54288 | 0:a2cb7295a1f7 | 522 | value_string += value; |
ram54288 | 0:a2cb7295a1f7 | 523 | } |
ram54288 | 0:a2cb7295a1f7 | 524 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 525 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 526 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 527 | if(inst->create_static_resource_instance(name,"resource", |
ram54288 | 0:a2cb7295a1f7 | 528 | M2MResourceInstance::STRING, |
ram54288 | 0:a2cb7295a1f7 | 529 | (const uint8_t*)value_string.c_str(), |
ram54288 | 0:a2cb7295a1f7 | 530 | value_string.size(), |
ram54288 | 0:a2cb7295a1f7 | 531 | resource_instance) != NULL) { |
ram54288 | 0:a2cb7295a1f7 | 532 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 533 | } |
ram54288 | 0:a2cb7295a1f7 | 534 | } |
ram54288 | 0:a2cb7295a1f7 | 535 | } |
ram54288 | 0:a2cb7295a1f7 | 536 | return success; |
ram54288 | 0:a2cb7295a1f7 | 537 | } |
ram54288 | 0:a2cb7295a1f7 | 538 | |
ram54288 | 0:a2cb7295a1f7 | 539 | bool M2MLWClient::create_static_resource_instance_int(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 540 | int32_t value, |
ram54288 | 0:a2cb7295a1f7 | 541 | bool multiple_instance, |
ram54288 | 0:a2cb7295a1f7 | 542 | uint16_t object_instance, |
ram54288 | 0:a2cb7295a1f7 | 543 | uint16_t resource_instance) |
ram54288 | 0:a2cb7295a1f7 | 544 | { |
ram54288 | 0:a2cb7295a1f7 | 545 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 546 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 547 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 548 | |
ram54288 | 0:a2cb7295a1f7 | 549 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 550 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 551 | } |
ram54288 | 0:a2cb7295a1f7 | 552 | |
ram54288 | 0:a2cb7295a1f7 | 553 | char value_buffer[20]; |
ram54288 | 0:a2cb7295a1f7 | 554 | sprintf(value_buffer,"%ld",value); |
ram54288 | 0:a2cb7295a1f7 | 555 | value_string += value_buffer; |
ram54288 | 0:a2cb7295a1f7 | 556 | |
ram54288 | 0:a2cb7295a1f7 | 557 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 558 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 559 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 560 | if(inst->create_static_resource_instance(name,"resource", |
ram54288 | 0:a2cb7295a1f7 | 561 | M2MResourceInstance::INTEGER, |
ram54288 | 0:a2cb7295a1f7 | 562 | (const uint8_t*)value_string.c_str(), |
ram54288 | 0:a2cb7295a1f7 | 563 | value_string.size(), |
ram54288 | 0:a2cb7295a1f7 | 564 | resource_instance) != NULL) { |
ram54288 | 0:a2cb7295a1f7 | 565 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 566 | } |
ram54288 | 0:a2cb7295a1f7 | 567 | } |
ram54288 | 0:a2cb7295a1f7 | 568 | } |
ram54288 | 0:a2cb7295a1f7 | 569 | return success; |
ram54288 | 0:a2cb7295a1f7 | 570 | } |
ram54288 | 0:a2cb7295a1f7 | 571 | |
ram54288 | 0:a2cb7295a1f7 | 572 | bool M2MLWClient::create_dynamic_resource_instance_int(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 573 | bool observable, |
ram54288 | 0:a2cb7295a1f7 | 574 | bool multiple_instance, |
ram54288 | 0:a2cb7295a1f7 | 575 | uint16_t object_instance, |
ram54288 | 0:a2cb7295a1f7 | 576 | uint16_t resource_instance, |
ram54288 | 0:a2cb7295a1f7 | 577 | uint8_t resource_instance_operation) |
ram54288 | 0:a2cb7295a1f7 | 578 | { |
ram54288 | 0:a2cb7295a1f7 | 579 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 580 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 581 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 582 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 583 | } |
ram54288 | 0:a2cb7295a1f7 | 584 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 585 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 586 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 587 | M2MResourceInstance *res = inst->create_dynamic_resource_instance(name,"resource", |
ram54288 | 0:a2cb7295a1f7 | 588 | M2MResourceInstance::INTEGER, |
ram54288 | 0:a2cb7295a1f7 | 589 | observable, |
ram54288 | 0:a2cb7295a1f7 | 590 | resource_instance); |
ram54288 | 0:a2cb7295a1f7 | 591 | if( res) { |
ram54288 | 0:a2cb7295a1f7 | 592 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 593 | res->set_operation(int_to_operation(resource_instance_operation)); |
ram54288 | 0:a2cb7295a1f7 | 594 | } |
ram54288 | 0:a2cb7295a1f7 | 595 | } |
ram54288 | 0:a2cb7295a1f7 | 596 | } |
ram54288 | 0:a2cb7295a1f7 | 597 | return success; |
ram54288 | 0:a2cb7295a1f7 | 598 | } |
ram54288 | 0:a2cb7295a1f7 | 599 | |
ram54288 | 0:a2cb7295a1f7 | 600 | bool M2MLWClient::create_dynamic_resource_instance_string(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 601 | bool observable, |
ram54288 | 0:a2cb7295a1f7 | 602 | bool multiple_instance, |
ram54288 | 0:a2cb7295a1f7 | 603 | uint16_t object_instance, |
ram54288 | 0:a2cb7295a1f7 | 604 | uint16_t resource_instance, |
ram54288 | 0:a2cb7295a1f7 | 605 | uint8_t resource_instance_operation) |
ram54288 | 0:a2cb7295a1f7 | 606 | { |
ram54288 | 0:a2cb7295a1f7 | 607 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 608 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 609 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 610 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 611 | } |
ram54288 | 0:a2cb7295a1f7 | 612 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 613 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 614 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 615 | M2MResourceInstance *res = inst->create_dynamic_resource_instance(name,"resource", |
ram54288 | 0:a2cb7295a1f7 | 616 | M2MResourceInstance::STRING, |
ram54288 | 0:a2cb7295a1f7 | 617 | observable, |
ram54288 | 0:a2cb7295a1f7 | 618 | resource_instance); |
ram54288 | 0:a2cb7295a1f7 | 619 | if( res) { |
ram54288 | 0:a2cb7295a1f7 | 620 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 621 | res->set_operation(int_to_operation(resource_instance_operation)); |
ram54288 | 0:a2cb7295a1f7 | 622 | } |
ram54288 | 0:a2cb7295a1f7 | 623 | } |
ram54288 | 0:a2cb7295a1f7 | 624 | } |
ram54288 | 0:a2cb7295a1f7 | 625 | return success; |
ram54288 | 0:a2cb7295a1f7 | 626 | } |
ram54288 | 0:a2cb7295a1f7 | 627 | |
ram54288 | 0:a2cb7295a1f7 | 628 | bool M2MLWClient::set_resource_instance_value(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 629 | int32_t value, |
ram54288 | 0:a2cb7295a1f7 | 630 | uint16_t object_instance, |
ram54288 | 0:a2cb7295a1f7 | 631 | uint16_t resource_instance) |
ram54288 | 0:a2cb7295a1f7 | 632 | { |
ram54288 | 0:a2cb7295a1f7 | 633 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 634 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 635 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 636 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 637 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 638 | } |
ram54288 | 0:a2cb7295a1f7 | 639 | |
ram54288 | 0:a2cb7295a1f7 | 640 | char value_buffer[20]; |
ram54288 | 0:a2cb7295a1f7 | 641 | sprintf(value_buffer,"%d",value); |
ram54288 | 0:a2cb7295a1f7 | 642 | value_string += value_buffer; |
ram54288 | 0:a2cb7295a1f7 | 643 | |
ram54288 | 0:a2cb7295a1f7 | 644 | if(_object && name_string.length() > 0) { |
ram54288 | 0:a2cb7295a1f7 | 645 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 646 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 647 | M2MResource *res = inst->resource(name_string); |
ram54288 | 0:a2cb7295a1f7 | 648 | if (res) { |
ram54288 | 0:a2cb7295a1f7 | 649 | M2MResourceInstance *res_inst = res->resource_instance(resource_instance); |
ram54288 | 0:a2cb7295a1f7 | 650 | if(res_inst) { |
ram54288 | 0:a2cb7295a1f7 | 651 | if (res_inst->set_value((const uint8_t*)value_string.c_str(), value_string.size())) { |
ram54288 | 0:a2cb7295a1f7 | 652 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 653 | } |
ram54288 | 0:a2cb7295a1f7 | 654 | } |
ram54288 | 0:a2cb7295a1f7 | 655 | } |
ram54288 | 0:a2cb7295a1f7 | 656 | } |
ram54288 | 0:a2cb7295a1f7 | 657 | } |
ram54288 | 0:a2cb7295a1f7 | 658 | return success; |
ram54288 | 0:a2cb7295a1f7 | 659 | } |
ram54288 | 0:a2cb7295a1f7 | 660 | |
ram54288 | 0:a2cb7295a1f7 | 661 | bool M2MLWClient::set_resource_instance_value(const char *name, |
ram54288 | 0:a2cb7295a1f7 | 662 | const char *value, |
ram54288 | 0:a2cb7295a1f7 | 663 | uint16_t object_instance, |
ram54288 | 0:a2cb7295a1f7 | 664 | uint16_t resource_instance) |
ram54288 | 0:a2cb7295a1f7 | 665 | { |
ram54288 | 0:a2cb7295a1f7 | 666 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 667 | String name_string; |
ram54288 | 0:a2cb7295a1f7 | 668 | String value_string; |
ram54288 | 0:a2cb7295a1f7 | 669 | if(name) { |
ram54288 | 0:a2cb7295a1f7 | 670 | name_string += name; |
ram54288 | 0:a2cb7295a1f7 | 671 | } |
ram54288 | 0:a2cb7295a1f7 | 672 | if(value) { |
ram54288 | 0:a2cb7295a1f7 | 673 | value_string += value; |
ram54288 | 0:a2cb7295a1f7 | 674 | } |
ram54288 | 0:a2cb7295a1f7 | 675 | |
ram54288 | 0:a2cb7295a1f7 | 676 | if(_object && name_string.length() > 0) { |
ram54288 | 0:a2cb7295a1f7 | 677 | M2MObjectInstance *inst = _object->object_instance(object_instance); |
ram54288 | 0:a2cb7295a1f7 | 678 | if(inst) { |
ram54288 | 0:a2cb7295a1f7 | 679 | M2MResource *res = inst->resource(name_string); |
ram54288 | 0:a2cb7295a1f7 | 680 | if (res) { |
ram54288 | 0:a2cb7295a1f7 | 681 | M2MResourceInstance *res_inst = res->resource_instance(resource_instance); |
ram54288 | 0:a2cb7295a1f7 | 682 | if(res_inst) { |
ram54288 | 0:a2cb7295a1f7 | 683 | if (res_inst->set_value((const uint8_t*)value_string.c_str(), value_string.size())) { |
ram54288 | 0:a2cb7295a1f7 | 684 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 685 | } |
ram54288 | 0:a2cb7295a1f7 | 686 | } |
ram54288 | 0:a2cb7295a1f7 | 687 | } |
ram54288 | 0:a2cb7295a1f7 | 688 | } |
ram54288 | 0:a2cb7295a1f7 | 689 | } |
ram54288 | 0:a2cb7295a1f7 | 690 | return success; |
ram54288 | 0:a2cb7295a1f7 | 691 | } |
ram54288 | 0:a2cb7295a1f7 | 692 | |
ram54288 | 0:a2cb7295a1f7 | 693 | bool M2MLWClient::test_register() |
ram54288 | 0:a2cb7295a1f7 | 694 | { |
ram54288 | 0:a2cb7295a1f7 | 695 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 696 | M2MObjectList object_list; |
ram54288 | 0:a2cb7295a1f7 | 697 | if(_device) { |
ram54288 | 0:a2cb7295a1f7 | 698 | object_list.push_back(_device); |
ram54288 | 0:a2cb7295a1f7 | 699 | } |
ram54288 | 0:a2cb7295a1f7 | 700 | if(_firmware) { |
ram54288 | 0:a2cb7295a1f7 | 701 | object_list.push_back(_firmware); |
ram54288 | 0:a2cb7295a1f7 | 702 | } |
ram54288 | 0:a2cb7295a1f7 | 703 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 704 | object_list.push_back(_object); |
ram54288 | 0:a2cb7295a1f7 | 705 | } |
ram54288 | 0:a2cb7295a1f7 | 706 | if(_interface) { |
ram54288 | 0:a2cb7295a1f7 | 707 | _interface->register_object(_register_security,object_list); |
ram54288 | 0:a2cb7295a1f7 | 708 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 709 | } |
ram54288 | 0:a2cb7295a1f7 | 710 | return success; |
ram54288 | 0:a2cb7295a1f7 | 711 | } |
ram54288 | 0:a2cb7295a1f7 | 712 | |
ram54288 | 0:a2cb7295a1f7 | 713 | bool M2MLWClient::test_update_register(const uint32_t lifetime) |
ram54288 | 0:a2cb7295a1f7 | 714 | { |
ram54288 | 0:a2cb7295a1f7 | 715 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 716 | if(_interface && _register_security) { |
ram54288 | 0:a2cb7295a1f7 | 717 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 718 | _interface->update_registration(_register_security,lifetime); |
ram54288 | 0:a2cb7295a1f7 | 719 | } |
ram54288 | 0:a2cb7295a1f7 | 720 | return success; |
ram54288 | 0:a2cb7295a1f7 | 721 | } |
ram54288 | 0:a2cb7295a1f7 | 722 | |
ram54288 | 0:a2cb7295a1f7 | 723 | bool M2MLWClient::test_unregister() |
ram54288 | 0:a2cb7295a1f7 | 724 | { |
ram54288 | 0:a2cb7295a1f7 | 725 | bool success = false; |
ram54288 | 0:a2cb7295a1f7 | 726 | if(_interface) { |
ram54288 | 0:a2cb7295a1f7 | 727 | success = true; |
ram54288 | 0:a2cb7295a1f7 | 728 | _interface->unregister_object(_register_security); |
ram54288 | 0:a2cb7295a1f7 | 729 | } |
ram54288 | 0:a2cb7295a1f7 | 730 | return success; |
ram54288 | 0:a2cb7295a1f7 | 731 | } |
ram54288 | 0:a2cb7295a1f7 | 732 | |
ram54288 | 0:a2cb7295a1f7 | 733 | void M2MLWClient::bootstrap_done(M2MSecurity *server_object) |
ram54288 | 0:a2cb7295a1f7 | 734 | { |
ram54288 | 0:a2cb7295a1f7 | 735 | if(server_object) { |
ram54288 | 0:a2cb7295a1f7 | 736 | _register_security = server_object; |
ram54288 | 0:a2cb7295a1f7 | 737 | _bootstrapped = true; |
ram54288 | 0:a2cb7295a1f7 | 738 | cmd_printf("\nBootstrapped\n"); |
ram54288 | 0:a2cb7295a1f7 | 739 | cmd_ready( CMDLINE_RETCODE_SUCCESS ); |
ram54288 | 0:a2cb7295a1f7 | 740 | } |
ram54288 | 0:a2cb7295a1f7 | 741 | } |
ram54288 | 0:a2cb7295a1f7 | 742 | |
ram54288 | 0:a2cb7295a1f7 | 743 | void M2MLWClient::object_registered(M2MSecurity *security_object, const M2MServer &server_object) |
ram54288 | 0:a2cb7295a1f7 | 744 | { |
ram54288 | 0:a2cb7295a1f7 | 745 | _registered = true; |
ram54288 | 0:a2cb7295a1f7 | 746 | cmd_printf("\nRegistered\n"); |
ram54288 | 0:a2cb7295a1f7 | 747 | cmd_ready( CMDLINE_RETCODE_SUCCESS ); |
ram54288 | 0:a2cb7295a1f7 | 748 | } |
ram54288 | 0:a2cb7295a1f7 | 749 | |
ram54288 | 0:a2cb7295a1f7 | 750 | void M2MLWClient::object_unregistered(M2MSecurity *server_object) |
ram54288 | 0:a2cb7295a1f7 | 751 | { |
ram54288 | 0:a2cb7295a1f7 | 752 | _unregistered = true; |
ram54288 | 0:a2cb7295a1f7 | 753 | if(_device) { |
ram54288 | 0:a2cb7295a1f7 | 754 | M2MDevice::delete_instance(); |
ram54288 | 0:a2cb7295a1f7 | 755 | _device = NULL; |
ram54288 | 0:a2cb7295a1f7 | 756 | } |
ram54288 | 0:a2cb7295a1f7 | 757 | if(_object) { |
ram54288 | 0:a2cb7295a1f7 | 758 | delete _object; |
ram54288 | 0:a2cb7295a1f7 | 759 | _object = NULL; |
ram54288 | 0:a2cb7295a1f7 | 760 | } |
ram54288 | 0:a2cb7295a1f7 | 761 | if(_security) { |
ram54288 | 0:a2cb7295a1f7 | 762 | delete _security; |
ram54288 | 0:a2cb7295a1f7 | 763 | _security = NULL; |
ram54288 | 0:a2cb7295a1f7 | 764 | } |
ram54288 | 0:a2cb7295a1f7 | 765 | if(_register_security) { |
ram54288 | 0:a2cb7295a1f7 | 766 | delete _register_security; |
ram54288 | 0:a2cb7295a1f7 | 767 | _register_security = NULL; |
ram54288 | 0:a2cb7295a1f7 | 768 | } |
ram54288 | 0:a2cb7295a1f7 | 769 | cmd_printf("\nUnregistered\n"); |
ram54288 | 0:a2cb7295a1f7 | 770 | cmd_ready( CMDLINE_RETCODE_SUCCESS ); |
ram54288 | 0:a2cb7295a1f7 | 771 | } |
ram54288 | 0:a2cb7295a1f7 | 772 | |
ram54288 | 0:a2cb7295a1f7 | 773 | void M2MLWClient::registration_updated(M2MSecurity *security_object, |
ram54288 | 0:a2cb7295a1f7 | 774 | const M2MServer &server_object) |
ram54288 | 0:a2cb7295a1f7 | 775 | { |
ram54288 | 0:a2cb7295a1f7 | 776 | _registration_updated = true; |
ram54288 | 0:a2cb7295a1f7 | 777 | cmd_printf("\nregistration updated\n"); |
ram54288 | 0:a2cb7295a1f7 | 778 | cmd_ready( CMDLINE_RETCODE_SUCCESS ); |
ram54288 | 0:a2cb7295a1f7 | 779 | } |
ram54288 | 0:a2cb7295a1f7 | 780 | |
ram54288 | 0:a2cb7295a1f7 | 781 | void M2MLWClient::error(M2MInterface::Error error) |
ram54288 | 0:a2cb7295a1f7 | 782 | { |
ram54288 | 0:a2cb7295a1f7 | 783 | _error = true; |
ram54288 | 0:a2cb7295a1f7 | 784 | cmd_printf("\nError occured Error Code : %d\n", (int8_t)error); |
ram54288 | 0:a2cb7295a1f7 | 785 | cmd_ready( CMDLINE_RETCODE_SUCCESS ); |
ram54288 | 0:a2cb7295a1f7 | 786 | } |
ram54288 | 0:a2cb7295a1f7 | 787 | |
ram54288 | 0:a2cb7295a1f7 | 788 | void M2MLWClient::value_updated(M2MBase *base, M2MBase::BaseType type) |
ram54288 | 0:a2cb7295a1f7 | 789 | { |
ram54288 | 0:a2cb7295a1f7 | 790 | cmd_printf("\nValue updated of Object name %s and Type \n", |
ram54288 | 0:a2cb7295a1f7 | 791 | base->name().c_str(), type); |
ram54288 | 0:a2cb7295a1f7 | 792 | } |
ram54288 | 0:a2cb7295a1f7 | 793 | |
ram54288 | 0:a2cb7295a1f7 | 794 | M2MBase::Operation M2MLWClient::int_to_operation(uint8_t operation) |
ram54288 | 0:a2cb7295a1f7 | 795 | { |
ram54288 | 0:a2cb7295a1f7 | 796 | M2MBase::Operation op = M2MBase::NOT_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 797 | switch(operation) { |
ram54288 | 0:a2cb7295a1f7 | 798 | case 0: |
ram54288 | 0:a2cb7295a1f7 | 799 | op = M2MBase::NOT_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 800 | break; |
ram54288 | 0:a2cb7295a1f7 | 801 | case 1: |
ram54288 | 0:a2cb7295a1f7 | 802 | op = M2MBase::GET_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 803 | break; |
ram54288 | 0:a2cb7295a1f7 | 804 | case 2: |
ram54288 | 0:a2cb7295a1f7 | 805 | op = M2MBase::PUT_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 806 | break; |
ram54288 | 0:a2cb7295a1f7 | 807 | case 3: |
ram54288 | 0:a2cb7295a1f7 | 808 | op = M2MBase::GET_PUT_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 809 | break; |
ram54288 | 0:a2cb7295a1f7 | 810 | case 4: |
ram54288 | 0:a2cb7295a1f7 | 811 | op = M2MBase::POST_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 812 | break; |
ram54288 | 0:a2cb7295a1f7 | 813 | case 5: |
ram54288 | 0:a2cb7295a1f7 | 814 | op = M2MBase::GET_POST_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 815 | break; |
ram54288 | 0:a2cb7295a1f7 | 816 | case 6: |
ram54288 | 0:a2cb7295a1f7 | 817 | op = M2MBase::PUT_POST_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 818 | break; |
ram54288 | 0:a2cb7295a1f7 | 819 | case 7: |
ram54288 | 0:a2cb7295a1f7 | 820 | op = M2MBase::GET_PUT_POST_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 821 | break; |
ram54288 | 0:a2cb7295a1f7 | 822 | case 8: |
ram54288 | 0:a2cb7295a1f7 | 823 | op = M2MBase::DELETE_ALLOWED; |
ram54288 | 0:a2cb7295a1f7 | 824 | break; |
ram54288 | 0:a2cb7295a1f7 | 825 | default: |
ram54288 | 0:a2cb7295a1f7 | 826 | break; |
ram54288 | 0:a2cb7295a1f7 | 827 | } |
ram54288 | 0:a2cb7295a1f7 | 828 | return op; |
ram54288 | 0:a2cb7295a1f7 | 829 | } |
ram54288 | 0:a2cb7295a1f7 | 830 | |
ram54288 | 0:a2cb7295a1f7 | 831 | void M2MLWClient::fw_execute_function(void *argument) |
ram54288 | 0:a2cb7295a1f7 | 832 | { |
ram54288 | 0:a2cb7295a1f7 | 833 | if(argument) { |
ram54288 | 0:a2cb7295a1f7 | 834 | char* arguments = (char*)argument; |
ram54288 | 0:a2cb7295a1f7 | 835 | cmd_printf("Received %s!!\n", arguments); |
ram54288 | 0:a2cb7295a1f7 | 836 | } |
ram54288 | 0:a2cb7295a1f7 | 837 | cmd_printf("Firmware update executed\n"); |
ram54288 | 0:a2cb7295a1f7 | 838 | } |
ram54288 | 0:a2cb7295a1f7 | 839 | |
ram54288 | 0:a2cb7295a1f7 | 840 | void M2MLWClient::firmware_resource_int(int resource) |
ram54288 | 0:a2cb7295a1f7 | 841 | { |
ram54288 | 0:a2cb7295a1f7 | 842 | cmd_printf("Firmware resource value int\n"); |
ram54288 | 0:a2cb7295a1f7 | 843 | cmd_printf("%ld\n", _firmware->resource_value_int(static_cast<M2MFirmware::FirmwareResource>(resource))); |
ram54288 | 0:a2cb7295a1f7 | 844 | } |
ram54288 | 0:a2cb7295a1f7 | 845 | |
ram54288 | 0:a2cb7295a1f7 | 846 | void M2MLWClient::firmware_resource_string(int resource) |
ram54288 | 0:a2cb7295a1f7 | 847 | { |
ram54288 | 0:a2cb7295a1f7 | 848 | cmd_printf("Firmware resource value string\n"); |
ram54288 | 0:a2cb7295a1f7 | 849 | cmd_printf("%s\n", _firmware->resource_value_string(static_cast<M2MFirmware::FirmwareResource>(resource)).c_str()); |
ram54288 | 0:a2cb7295a1f7 | 850 | } |
ram54288 | 0:a2cb7295a1f7 | 851 | |
ram54288 | 0:a2cb7295a1f7 | 852 | void M2MLWClient::firmware_resource_buffer() |
ram54288 | 0:a2cb7295a1f7 | 853 | { |
ram54288 | 0:a2cb7295a1f7 | 854 | cmd_printf("Firmware resource value buffer\n"); |
ram54288 | 0:a2cb7295a1f7 | 855 | uint8_t *value = 0; |
ram54288 | 0:a2cb7295a1f7 | 856 | uint32_t valueSize = _firmware->resource_value_buffer(M2MFirmware::Package, value); |
ram54288 | 0:a2cb7295a1f7 | 857 | cmd_printf("%s\n", value); |
ram54288 | 0:a2cb7295a1f7 | 858 | free(value); |
ram54288 | 0:a2cb7295a1f7 | 859 | } |