Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
simple-mbed-cloud-client/mbed-cloud-client/update-client-hub/modules/lwm2m-mbed/source/DeviceMetadataResource.cpp@0:8f0bb79ddd48, 2021-05-04 (annotated)
- Committer:
- leothedragon
- Date:
- Tue May 04 08:55:12 2021 +0000
- Revision:
- 0:8f0bb79ddd48
nmn
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leothedragon | 0:8f0bb79ddd48 | 1 | // ---------------------------------------------------------------------------- |
leothedragon | 0:8f0bb79ddd48 | 2 | // Copyright 2016-2017 ARM Ltd. |
leothedragon | 0:8f0bb79ddd48 | 3 | // |
leothedragon | 0:8f0bb79ddd48 | 4 | // SPDX-License-Identifier: Apache-2.0 |
leothedragon | 0:8f0bb79ddd48 | 5 | // |
leothedragon | 0:8f0bb79ddd48 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); |
leothedragon | 0:8f0bb79ddd48 | 7 | // you may not use this file except in compliance with the License. |
leothedragon | 0:8f0bb79ddd48 | 8 | // You may obtain a copy of the License at |
leothedragon | 0:8f0bb79ddd48 | 9 | // |
leothedragon | 0:8f0bb79ddd48 | 10 | // http://www.apache.org/licenses/LICENSE-2.0 |
leothedragon | 0:8f0bb79ddd48 | 11 | // |
leothedragon | 0:8f0bb79ddd48 | 12 | // Unless required by applicable law or agreed to in writing, software |
leothedragon | 0:8f0bb79ddd48 | 13 | // distributed under the License is distributed on an "AS IS" BASIS, |
leothedragon | 0:8f0bb79ddd48 | 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
leothedragon | 0:8f0bb79ddd48 | 15 | // See the License for the specific language governing permissions and |
leothedragon | 0:8f0bb79ddd48 | 16 | // limitations under the License. |
leothedragon | 0:8f0bb79ddd48 | 17 | // ---------------------------------------------------------------------------- |
leothedragon | 0:8f0bb79ddd48 | 18 | // Note: this macro is needed on armcc to get the the PRI*32 macros |
leothedragon | 0:8f0bb79ddd48 | 19 | // from inttypes.h in a C++ code. |
leothedragon | 0:8f0bb79ddd48 | 20 | #ifndef __STDC_FORMAT_MACROS |
leothedragon | 0:8f0bb79ddd48 | 21 | #define __STDC_FORMAT_MACROS |
leothedragon | 0:8f0bb79ddd48 | 22 | #endif |
leothedragon | 0:8f0bb79ddd48 | 23 | |
leothedragon | 0:8f0bb79ddd48 | 24 | #include "update-client-lwm2m/DeviceMetadataResource.h" |
leothedragon | 0:8f0bb79ddd48 | 25 | #include "update-client-lwm2m/FirmwareUpdateResource.h" |
leothedragon | 0:8f0bb79ddd48 | 26 | #include "update-client-common/arm_uc_types.h" |
leothedragon | 0:8f0bb79ddd48 | 27 | #include "pal4life-device-identity/pal_device_identity.h" |
leothedragon | 0:8f0bb79ddd48 | 28 | #include <inttypes.h> |
leothedragon | 0:8f0bb79ddd48 | 29 | |
leothedragon | 0:8f0bb79ddd48 | 30 | |
leothedragon | 0:8f0bb79ddd48 | 31 | #include <stdio.h> |
leothedragon | 0:8f0bb79ddd48 | 32 | |
leothedragon | 0:8f0bb79ddd48 | 33 | #define ARM_UCS_LWM2M_INTERNAL_ERROR (-1) |
leothedragon | 0:8f0bb79ddd48 | 34 | #define ARM_UCS_LWM2M_INTERNAL_SUCCESS (0) |
leothedragon | 0:8f0bb79ddd48 | 35 | |
leothedragon | 0:8f0bb79ddd48 | 36 | #if defined(ARM_UC_PROFILE_MBED_CLIENT_LITE) && (ARM_UC_PROFILE_MBED_CLIENT_LITE == 1) |
leothedragon | 0:8f0bb79ddd48 | 37 | #define RESOURCE_VALUE(arg) arg |
leothedragon | 0:8f0bb79ddd48 | 38 | #define PROTOCOL_VERSION 2 |
leothedragon | 0:8f0bb79ddd48 | 39 | #else |
leothedragon | 0:8f0bb79ddd48 | 40 | #define RESOURCE_VALUE(arg) #arg |
leothedragon | 0:8f0bb79ddd48 | 41 | #define PROTOCOL_VERSION 3 |
leothedragon | 0:8f0bb79ddd48 | 42 | #endif |
leothedragon | 0:8f0bb79ddd48 | 43 | |
leothedragon | 0:8f0bb79ddd48 | 44 | namespace DeviceMetadataResource { |
leothedragon | 0:8f0bb79ddd48 | 45 | /* LWM2M Firmware Update Object */ |
leothedragon | 0:8f0bb79ddd48 | 46 | static M2MObject *deviceMetadataObject; |
leothedragon | 0:8f0bb79ddd48 | 47 | |
leothedragon | 0:8f0bb79ddd48 | 48 | /* LWM2M Firmware Update Object resources */ |
leothedragon | 0:8f0bb79ddd48 | 49 | static M2MResource *protocolSupportedResource = NULL; // /10255/0/0 |
leothedragon | 0:8f0bb79ddd48 | 50 | static M2MResource *bootloaderHashResource = NULL; // /10255/0/1 |
leothedragon | 0:8f0bb79ddd48 | 51 | static M2MResource *OEMBootloaderHashResource = NULL; // /10255/0/2 |
leothedragon | 0:8f0bb79ddd48 | 52 | static M2MResource *vendorIdResource = NULL; // /10255/0/3 |
leothedragon | 0:8f0bb79ddd48 | 53 | static M2MResource *classIdResource = NULL; // /10255/0/4 |
leothedragon | 0:8f0bb79ddd48 | 54 | static M2MResource *deviceIdResource = NULL; // /10255/0/5 |
leothedragon | 0:8f0bb79ddd48 | 55 | } |
leothedragon | 0:8f0bb79ddd48 | 56 | |
leothedragon | 0:8f0bb79ddd48 | 57 | |
leothedragon | 0:8f0bb79ddd48 | 58 | /** |
leothedragon | 0:8f0bb79ddd48 | 59 | * @brief Initialize LWM2M Device Metadata Object |
leothedragon | 0:8f0bb79ddd48 | 60 | * @details Sets up LWM2M object with accompanying resources. |
leothedragon | 0:8f0bb79ddd48 | 61 | */ |
leothedragon | 0:8f0bb79ddd48 | 62 | void DeviceMetadataResource::Initialize(void) |
leothedragon | 0:8f0bb79ddd48 | 63 | { |
leothedragon | 0:8f0bb79ddd48 | 64 | static bool initialized = false; |
leothedragon | 0:8f0bb79ddd48 | 65 | |
leothedragon | 0:8f0bb79ddd48 | 66 | if (!initialized) { |
leothedragon | 0:8f0bb79ddd48 | 67 | |
leothedragon | 0:8f0bb79ddd48 | 68 | /* The LWM2M Firmware Update Object is at /10255 */ |
leothedragon | 0:8f0bb79ddd48 | 69 | #if defined(ARM_UC_PROFILE_MBED_CLIENT_LITE) && (ARM_UC_PROFILE_MBED_CLIENT_LITE == 1) |
leothedragon | 0:8f0bb79ddd48 | 70 | deviceMetadataObject = M2MInterfaceFactory::create_object(10255, FirmwareUpdateResource::getM2MInterface()); |
leothedragon | 0:8f0bb79ddd48 | 71 | #else |
leothedragon | 0:8f0bb79ddd48 | 72 | deviceMetadataObject = M2MInterfaceFactory::create_object("10255"); |
leothedragon | 0:8f0bb79ddd48 | 73 | #endif |
leothedragon | 0:8f0bb79ddd48 | 74 | |
leothedragon | 0:8f0bb79ddd48 | 75 | if (deviceMetadataObject) { |
leothedragon | 0:8f0bb79ddd48 | 76 | initialized = true; |
leothedragon | 0:8f0bb79ddd48 | 77 | |
leothedragon | 0:8f0bb79ddd48 | 78 | #if defined(ARM_UC_PROFILE_MBED_CLOUD_CLIENT) && (ARM_UC_PROFILE_MBED_CLOUD_CLIENT == 1) |
leothedragon | 0:8f0bb79ddd48 | 79 | deviceMetadataObject->set_register_uri(false); |
leothedragon | 0:8f0bb79ddd48 | 80 | #endif |
leothedragon | 0:8f0bb79ddd48 | 81 | /* Set object operating mode to GET_ALLOWED */ |
leothedragon | 0:8f0bb79ddd48 | 82 | deviceMetadataObject->set_operation(M2MBase::GET_ALLOWED); |
leothedragon | 0:8f0bb79ddd48 | 83 | /* Create first (and only) instance /10255/0 */ |
leothedragon | 0:8f0bb79ddd48 | 84 | M2MObjectInstance *deviceMetadataInstance = deviceMetadataObject->create_object_instance(); |
leothedragon | 0:8f0bb79ddd48 | 85 | |
leothedragon | 0:8f0bb79ddd48 | 86 | if (deviceMetadataInstance) { |
leothedragon | 0:8f0bb79ddd48 | 87 | #if defined(ARM_UC_PROFILE_MBED_CLOUD_CLIENT) && (ARM_UC_PROFILE_MBED_CLOUD_CLIENT == 1) |
leothedragon | 0:8f0bb79ddd48 | 88 | deviceMetadataInstance->set_register_uri(false); |
leothedragon | 0:8f0bb79ddd48 | 89 | #endif |
leothedragon | 0:8f0bb79ddd48 | 90 | |
leothedragon | 0:8f0bb79ddd48 | 91 | /* Default values are non-standard, but the standard has no |
leothedragon | 0:8f0bb79ddd48 | 92 | values for indicating that the device is initializing. |
leothedragon | 0:8f0bb79ddd48 | 93 | */ |
leothedragon | 0:8f0bb79ddd48 | 94 | const int64_t version = PROTOCOL_VERSION; |
leothedragon | 0:8f0bb79ddd48 | 95 | const uint8_t invalid_value[] = "INVALID"; |
leothedragon | 0:8f0bb79ddd48 | 96 | const uint8_t invalid_value_size = sizeof(invalid_value) - 1; |
leothedragon | 0:8f0bb79ddd48 | 97 | |
leothedragon | 0:8f0bb79ddd48 | 98 | ARM_UC_INIT_ERROR(err, ERR_INVALID_PARAMETER); |
leothedragon | 0:8f0bb79ddd48 | 99 | arm_uc_guid_t guid = { 0 }; |
leothedragon | 0:8f0bb79ddd48 | 100 | uint8_t *value = NULL; |
leothedragon | 0:8f0bb79ddd48 | 101 | uint32_t value_length = 0; |
leothedragon | 0:8f0bb79ddd48 | 102 | |
leothedragon | 0:8f0bb79ddd48 | 103 | /* Set instance operating mode to GET_ALLOWED */ |
leothedragon | 0:8f0bb79ddd48 | 104 | deviceMetadataInstance->set_operation(M2MBase::GET_ALLOWED); |
leothedragon | 0:8f0bb79ddd48 | 105 | |
leothedragon | 0:8f0bb79ddd48 | 106 | /* Create Update resource /10255/0/0 */ |
leothedragon | 0:8f0bb79ddd48 | 107 | protocolSupportedResource = deviceMetadataInstance->create_dynamic_resource( |
leothedragon | 0:8f0bb79ddd48 | 108 | RESOURCE_VALUE(0), |
leothedragon | 0:8f0bb79ddd48 | 109 | "ProtocolSupported", |
leothedragon | 0:8f0bb79ddd48 | 110 | M2MResourceInstance::INTEGER, |
leothedragon | 0:8f0bb79ddd48 | 111 | true); |
leothedragon | 0:8f0bb79ddd48 | 112 | if (protocolSupportedResource) { |
leothedragon | 0:8f0bb79ddd48 | 113 | protocolSupportedResource->set_operation(M2MBase::GET_ALLOWED); |
leothedragon | 0:8f0bb79ddd48 | 114 | protocolSupportedResource->set_value(version); |
leothedragon | 0:8f0bb79ddd48 | 115 | protocolSupportedResource->publish_value_in_registration_msg(true); |
leothedragon | 0:8f0bb79ddd48 | 116 | protocolSupportedResource->set_auto_observable(true); |
leothedragon | 0:8f0bb79ddd48 | 117 | } |
leothedragon | 0:8f0bb79ddd48 | 118 | |
leothedragon | 0:8f0bb79ddd48 | 119 | /* Create Update resource /10255/0/1 */ |
leothedragon | 0:8f0bb79ddd48 | 120 | #if defined(ARM_UC_PROFILE_MBED_CLIENT_LITE) && (ARM_UC_PROFILE_MBED_CLIENT_LITE == 1) |
leothedragon | 0:8f0bb79ddd48 | 121 | bootloaderHashResource = deviceMetadataInstance->create_dynamic_resource( |
leothedragon | 0:8f0bb79ddd48 | 122 | RESOURCE_VALUE(1), |
leothedragon | 0:8f0bb79ddd48 | 123 | "BootloaderHash", |
leothedragon | 0:8f0bb79ddd48 | 124 | M2MResourceInstance::OPAQUE, |
leothedragon | 0:8f0bb79ddd48 | 125 | true); |
leothedragon | 0:8f0bb79ddd48 | 126 | #else |
leothedragon | 0:8f0bb79ddd48 | 127 | bootloaderHashResource = deviceMetadataInstance->create_static_resource( |
leothedragon | 0:8f0bb79ddd48 | 128 | RESOURCE_VALUE(1), |
leothedragon | 0:8f0bb79ddd48 | 129 | "BootloaderHash", |
leothedragon | 0:8f0bb79ddd48 | 130 | M2MResourceInstance::OPAQUE, |
leothedragon | 0:8f0bb79ddd48 | 131 | (uint8_t *) invalid_value, |
leothedragon | 0:8f0bb79ddd48 | 132 | invalid_value_size); |
leothedragon | 0:8f0bb79ddd48 | 133 | #endif |
leothedragon | 0:8f0bb79ddd48 | 134 | if (bootloaderHashResource) { |
leothedragon | 0:8f0bb79ddd48 | 135 | bootloaderHashResource->set_operation(M2MBase::GET_ALLOWED); |
leothedragon | 0:8f0bb79ddd48 | 136 | bootloaderHashResource->publish_value_in_registration_msg(true); |
leothedragon | 0:8f0bb79ddd48 | 137 | bootloaderHashResource->set_auto_observable(true); |
leothedragon | 0:8f0bb79ddd48 | 138 | } |
leothedragon | 0:8f0bb79ddd48 | 139 | |
leothedragon | 0:8f0bb79ddd48 | 140 | /* Create Update resource /10255/0/2 */ |
leothedragon | 0:8f0bb79ddd48 | 141 | #if defined(ARM_UC_PROFILE_MBED_CLIENT_LITE) && (ARM_UC_PROFILE_MBED_CLIENT_LITE == 1) |
leothedragon | 0:8f0bb79ddd48 | 142 | OEMBootloaderHashResource = deviceMetadataInstance->create_dynamic_resource( |
leothedragon | 0:8f0bb79ddd48 | 143 | RESOURCE_VALUE(2), |
leothedragon | 0:8f0bb79ddd48 | 144 | "OEMBootloaderHash", |
leothedragon | 0:8f0bb79ddd48 | 145 | M2MResourceInstance::OPAQUE, |
leothedragon | 0:8f0bb79ddd48 | 146 | true); |
leothedragon | 0:8f0bb79ddd48 | 147 | #else |
leothedragon | 0:8f0bb79ddd48 | 148 | OEMBootloaderHashResource = deviceMetadataInstance->create_static_resource( |
leothedragon | 0:8f0bb79ddd48 | 149 | RESOURCE_VALUE(2), |
leothedragon | 0:8f0bb79ddd48 | 150 | "OEMBootloaderHash", |
leothedragon | 0:8f0bb79ddd48 | 151 | M2MResourceInstance::OPAQUE, |
leothedragon | 0:8f0bb79ddd48 | 152 | (uint8_t *) invalid_value, |
leothedragon | 0:8f0bb79ddd48 | 153 | invalid_value_size); |
leothedragon | 0:8f0bb79ddd48 | 154 | #endif |
leothedragon | 0:8f0bb79ddd48 | 155 | if (OEMBootloaderHashResource) { |
leothedragon | 0:8f0bb79ddd48 | 156 | OEMBootloaderHashResource->set_operation(M2MBase::GET_ALLOWED); |
leothedragon | 0:8f0bb79ddd48 | 157 | OEMBootloaderHashResource->publish_value_in_registration_msg(true); |
leothedragon | 0:8f0bb79ddd48 | 158 | OEMBootloaderHashResource->set_auto_observable(true); |
leothedragon | 0:8f0bb79ddd48 | 159 | } |
leothedragon | 0:8f0bb79ddd48 | 160 | |
leothedragon | 0:8f0bb79ddd48 | 161 | /* get vendor ID */ |
leothedragon | 0:8f0bb79ddd48 | 162 | err = pal_getVendorGuid(&guid); |
leothedragon | 0:8f0bb79ddd48 | 163 | if (err.error == ERR_NONE) { |
leothedragon | 0:8f0bb79ddd48 | 164 | value = (uint8_t *) &guid; |
leothedragon | 0:8f0bb79ddd48 | 165 | value_length = sizeof(arm_uc_guid_t); |
leothedragon | 0:8f0bb79ddd48 | 166 | } else { |
leothedragon | 0:8f0bb79ddd48 | 167 | value = (uint8_t *) invalid_value; |
leothedragon | 0:8f0bb79ddd48 | 168 | value_length = invalid_value_size; |
leothedragon | 0:8f0bb79ddd48 | 169 | } |
leothedragon | 0:8f0bb79ddd48 | 170 | |
leothedragon | 0:8f0bb79ddd48 | 171 | /* Create Update resource /10255/0/3 */ |
leothedragon | 0:8f0bb79ddd48 | 172 | vendorIdResource = deviceMetadataInstance->create_dynamic_resource( |
leothedragon | 0:8f0bb79ddd48 | 173 | RESOURCE_VALUE(3), |
leothedragon | 0:8f0bb79ddd48 | 174 | "Vendor", |
leothedragon | 0:8f0bb79ddd48 | 175 | M2MResourceInstance::OPAQUE, |
leothedragon | 0:8f0bb79ddd48 | 176 | true); |
leothedragon | 0:8f0bb79ddd48 | 177 | |
leothedragon | 0:8f0bb79ddd48 | 178 | if (vendorIdResource) { |
leothedragon | 0:8f0bb79ddd48 | 179 | vendorIdResource->set_operation(M2MBase::GET_ALLOWED); |
leothedragon | 0:8f0bb79ddd48 | 180 | vendorIdResource->set_value(value, value_length); |
leothedragon | 0:8f0bb79ddd48 | 181 | vendorIdResource->publish_value_in_registration_msg(true); |
leothedragon | 0:8f0bb79ddd48 | 182 | vendorIdResource->set_auto_observable(true); |
leothedragon | 0:8f0bb79ddd48 | 183 | } |
leothedragon | 0:8f0bb79ddd48 | 184 | |
leothedragon | 0:8f0bb79ddd48 | 185 | /* get class ID */ |
leothedragon | 0:8f0bb79ddd48 | 186 | err = pal_getClassGuid(&guid); |
leothedragon | 0:8f0bb79ddd48 | 187 | if (err.error == ERR_NONE) { |
leothedragon | 0:8f0bb79ddd48 | 188 | value = (uint8_t *) &guid; |
leothedragon | 0:8f0bb79ddd48 | 189 | value_length = sizeof(arm_uc_guid_t); |
leothedragon | 0:8f0bb79ddd48 | 190 | } else { |
leothedragon | 0:8f0bb79ddd48 | 191 | value = (uint8_t *) invalid_value; |
leothedragon | 0:8f0bb79ddd48 | 192 | value_length = invalid_value_size; |
leothedragon | 0:8f0bb79ddd48 | 193 | } |
leothedragon | 0:8f0bb79ddd48 | 194 | |
leothedragon | 0:8f0bb79ddd48 | 195 | /* Create Update resource /10255/0/4 */ |
leothedragon | 0:8f0bb79ddd48 | 196 | classIdResource = deviceMetadataInstance->create_dynamic_resource( |
leothedragon | 0:8f0bb79ddd48 | 197 | RESOURCE_VALUE(4), |
leothedragon | 0:8f0bb79ddd48 | 198 | "Class", |
leothedragon | 0:8f0bb79ddd48 | 199 | M2MResourceInstance::OPAQUE, |
leothedragon | 0:8f0bb79ddd48 | 200 | true); |
leothedragon | 0:8f0bb79ddd48 | 201 | |
leothedragon | 0:8f0bb79ddd48 | 202 | if (classIdResource) { |
leothedragon | 0:8f0bb79ddd48 | 203 | classIdResource->set_operation(M2MBase::GET_ALLOWED); |
leothedragon | 0:8f0bb79ddd48 | 204 | classIdResource->set_value(value, value_length); |
leothedragon | 0:8f0bb79ddd48 | 205 | classIdResource->publish_value_in_registration_msg(true); |
leothedragon | 0:8f0bb79ddd48 | 206 | classIdResource->set_auto_observable(true); |
leothedragon | 0:8f0bb79ddd48 | 207 | } |
leothedragon | 0:8f0bb79ddd48 | 208 | |
leothedragon | 0:8f0bb79ddd48 | 209 | /* get device ID */ |
leothedragon | 0:8f0bb79ddd48 | 210 | err = pal_getDeviceGuid(&guid); |
leothedragon | 0:8f0bb79ddd48 | 211 | if (err.error == ERR_NONE) { |
leothedragon | 0:8f0bb79ddd48 | 212 | value = (uint8_t *) &guid; |
leothedragon | 0:8f0bb79ddd48 | 213 | value_length = sizeof(arm_uc_guid_t); |
leothedragon | 0:8f0bb79ddd48 | 214 | } else { |
leothedragon | 0:8f0bb79ddd48 | 215 | value = (uint8_t *) invalid_value; |
leothedragon | 0:8f0bb79ddd48 | 216 | value_length = invalid_value_size; |
leothedragon | 0:8f0bb79ddd48 | 217 | } |
leothedragon | 0:8f0bb79ddd48 | 218 | |
leothedragon | 0:8f0bb79ddd48 | 219 | /* Create Update resource /10255/0/5 */ |
leothedragon | 0:8f0bb79ddd48 | 220 | #if defined(ARM_UC_PROFILE_MBED_CLIENT_LITE) && (ARM_UC_PROFILE_MBED_CLIENT_LITE == 1) |
leothedragon | 0:8f0bb79ddd48 | 221 | deviceIdResource = deviceMetadataInstance->create_dynamic_resource( |
leothedragon | 0:8f0bb79ddd48 | 222 | RESOURCE_VALUE(5), |
leothedragon | 0:8f0bb79ddd48 | 223 | "DeviceId", |
leothedragon | 0:8f0bb79ddd48 | 224 | M2MResourceInstance::OPAQUE, |
leothedragon | 0:8f0bb79ddd48 | 225 | true); |
leothedragon | 0:8f0bb79ddd48 | 226 | #else |
leothedragon | 0:8f0bb79ddd48 | 227 | deviceIdResource = deviceMetadataInstance->create_static_resource( |
leothedragon | 0:8f0bb79ddd48 | 228 | RESOURCE_VALUE(5), |
leothedragon | 0:8f0bb79ddd48 | 229 | "DeviceId", |
leothedragon | 0:8f0bb79ddd48 | 230 | M2MResourceInstance::OPAQUE, |
leothedragon | 0:8f0bb79ddd48 | 231 | value, |
leothedragon | 0:8f0bb79ddd48 | 232 | value_length); |
leothedragon | 0:8f0bb79ddd48 | 233 | #endif |
leothedragon | 0:8f0bb79ddd48 | 234 | if (deviceIdResource) { |
leothedragon | 0:8f0bb79ddd48 | 235 | deviceIdResource->set_operation(M2MBase::GET_ALLOWED); |
leothedragon | 0:8f0bb79ddd48 | 236 | #if defined(ARM_UC_PROFILE_MBED_CLIENT_LITE) && (ARM_UC_PROFILE_MBED_CLIENT_LITE == 1) |
leothedragon | 0:8f0bb79ddd48 | 237 | deviceIdResource->set_value(value, value_length); |
leothedragon | 0:8f0bb79ddd48 | 238 | #endif |
leothedragon | 0:8f0bb79ddd48 | 239 | deviceIdResource->publish_value_in_registration_msg(true); |
leothedragon | 0:8f0bb79ddd48 | 240 | deviceIdResource->set_auto_observable(true); |
leothedragon | 0:8f0bb79ddd48 | 241 | } |
leothedragon | 0:8f0bb79ddd48 | 242 | } |
leothedragon | 0:8f0bb79ddd48 | 243 | } |
leothedragon | 0:8f0bb79ddd48 | 244 | } |
leothedragon | 0:8f0bb79ddd48 | 245 | } |
leothedragon | 0:8f0bb79ddd48 | 246 | |
leothedragon | 0:8f0bb79ddd48 | 247 | int32_t DeviceMetadataResource::setBootloaderHash(arm_uc_buffer_t *hash) |
leothedragon | 0:8f0bb79ddd48 | 248 | { |
leothedragon | 0:8f0bb79ddd48 | 249 | UC_SRCE_TRACE("DeviceMetadataResource::setBootloaderHash ptr %p size %" PRIu32, hash, hash->size); |
leothedragon | 0:8f0bb79ddd48 | 250 | |
leothedragon | 0:8f0bb79ddd48 | 251 | int32_t result = ARM_UCS_LWM2M_INTERNAL_ERROR; |
leothedragon | 0:8f0bb79ddd48 | 252 | |
leothedragon | 0:8f0bb79ddd48 | 253 | if (bootloaderHashResource && hash && hash->size > 0) { |
leothedragon | 0:8f0bb79ddd48 | 254 | bool rt = bootloaderHashResource->set_value(hash->ptr, hash->size); |
leothedragon | 0:8f0bb79ddd48 | 255 | if (rt == true) { |
leothedragon | 0:8f0bb79ddd48 | 256 | result = ARM_UCS_LWM2M_INTERNAL_SUCCESS; |
leothedragon | 0:8f0bb79ddd48 | 257 | } |
leothedragon | 0:8f0bb79ddd48 | 258 | } |
leothedragon | 0:8f0bb79ddd48 | 259 | |
leothedragon | 0:8f0bb79ddd48 | 260 | return result; |
leothedragon | 0:8f0bb79ddd48 | 261 | } |
leothedragon | 0:8f0bb79ddd48 | 262 | |
leothedragon | 0:8f0bb79ddd48 | 263 | int32_t DeviceMetadataResource::setOEMBootloaderHash(arm_uc_buffer_t *hash) |
leothedragon | 0:8f0bb79ddd48 | 264 | { |
leothedragon | 0:8f0bb79ddd48 | 265 | UC_SRCE_TRACE("DeviceMetadataResource::setOEMBootloaderHash ptr %p size %" PRIu32, hash, hash->size); |
leothedragon | 0:8f0bb79ddd48 | 266 | |
leothedragon | 0:8f0bb79ddd48 | 267 | int32_t result = ARM_UCS_LWM2M_INTERNAL_ERROR; |
leothedragon | 0:8f0bb79ddd48 | 268 | |
leothedragon | 0:8f0bb79ddd48 | 269 | if (OEMBootloaderHashResource && hash && hash->size > 0) { |
leothedragon | 0:8f0bb79ddd48 | 270 | bool rt = OEMBootloaderHashResource->set_value(hash->ptr, hash->size); |
leothedragon | 0:8f0bb79ddd48 | 271 | if (rt == true) { |
leothedragon | 0:8f0bb79ddd48 | 272 | result = ARM_UCS_LWM2M_INTERNAL_SUCCESS; |
leothedragon | 0:8f0bb79ddd48 | 273 | } |
leothedragon | 0:8f0bb79ddd48 | 274 | } |
leothedragon | 0:8f0bb79ddd48 | 275 | |
leothedragon | 0:8f0bb79ddd48 | 276 | return result; |
leothedragon | 0:8f0bb79ddd48 | 277 | } |
leothedragon | 0:8f0bb79ddd48 | 278 | |
leothedragon | 0:8f0bb79ddd48 | 279 | M2MObject *DeviceMetadataResource::getObject() |
leothedragon | 0:8f0bb79ddd48 | 280 | { |
leothedragon | 0:8f0bb79ddd48 | 281 | Initialize(); |
leothedragon | 0:8f0bb79ddd48 | 282 | |
leothedragon | 0:8f0bb79ddd48 | 283 | return deviceMetadataObject; |
leothedragon | 0:8f0bb79ddd48 | 284 | } |
leothedragon | 0:8f0bb79ddd48 | 285 | |
leothedragon | 0:8f0bb79ddd48 | 286 | void DeviceMetadataResource::Uninitialize() |
leothedragon | 0:8f0bb79ddd48 | 287 | { |
leothedragon | 0:8f0bb79ddd48 | 288 | UC_SRCE_TRACE("DeviceMetadataResource::Uninitialize"); |
leothedragon | 0:8f0bb79ddd48 | 289 | delete deviceMetadataObject; |
leothedragon | 0:8f0bb79ddd48 | 290 | deviceMetadataObject = NULL; |
leothedragon | 0:8f0bb79ddd48 | 291 | } |