leo hendrickson
/
S
simple-mbed-cloud-client/mbed-cloud-client/update-client-hub/modules/lwm2m-mbed/source/lwm2m-control.cpp@0:25fa8795676b, 2021-04-18 (annotated)
- Committer:
- leothedragon
- Date:
- Sun Apr 18 15:20:23 2021 +0000
- Revision:
- 0:25fa8795676b
DS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leothedragon | 0:25fa8795676b | 1 | // ---------------------------------------------------------------------------- |
leothedragon | 0:25fa8795676b | 2 | // Copyright 2016-2017 ARM Ltd. |
leothedragon | 0:25fa8795676b | 3 | // |
leothedragon | 0:25fa8795676b | 4 | // SPDX-License-Identifier: Apache-2.0 |
leothedragon | 0:25fa8795676b | 5 | // |
leothedragon | 0:25fa8795676b | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); |
leothedragon | 0:25fa8795676b | 7 | // you may not use this file except in compliance with the License. |
leothedragon | 0:25fa8795676b | 8 | // You may obtain a copy of the License at |
leothedragon | 0:25fa8795676b | 9 | // |
leothedragon | 0:25fa8795676b | 10 | // http://www.apache.org/licenses/LICENSE-2.0 |
leothedragon | 0:25fa8795676b | 11 | // |
leothedragon | 0:25fa8795676b | 12 | // Unless required by applicable law or agreed to in writing, software |
leothedragon | 0:25fa8795676b | 13 | // distributed under the License is distributed on an "AS IS" BASIS, |
leothedragon | 0:25fa8795676b | 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
leothedragon | 0:25fa8795676b | 15 | // See the License for the specific language governing permissions and |
leothedragon | 0:25fa8795676b | 16 | // limitations under the License. |
leothedragon | 0:25fa8795676b | 17 | // ---------------------------------------------------------------------------- |
leothedragon | 0:25fa8795676b | 18 | |
leothedragon | 0:25fa8795676b | 19 | #include "update-client-lwm2m/lwm2m-control.h" |
leothedragon | 0:25fa8795676b | 20 | #include "update-client-lwm2m/FirmwareUpdateResource.h" |
leothedragon | 0:25fa8795676b | 21 | #include "update-client-common/arm_uc_config.h" |
leothedragon | 0:25fa8795676b | 22 | |
leothedragon | 0:25fa8795676b | 23 | /** |
leothedragon | 0:25fa8795676b | 24 | * @brief Set callback function for externally triggering an update. |
leothedragon | 0:25fa8795676b | 25 | * @details The callback function is called when an external trigger |
leothedragon | 0:25fa8795676b | 26 | * is fired. The callback function should force an update. |
leothedragon | 0:25fa8795676b | 27 | * |
leothedragon | 0:25fa8795676b | 28 | * @param callback Function pointer. |
leothedragon | 0:25fa8795676b | 29 | */ |
leothedragon | 0:25fa8795676b | 30 | arm_uc_error_t ARM_UC_CONTROL_SetOverrideCallback(void (*callback)(void)) |
leothedragon | 0:25fa8795676b | 31 | { |
leothedragon | 0:25fa8795676b | 32 | ARM_UC_INIT_ERROR(retval, ERR_INVALID_PARAMETER); |
leothedragon | 0:25fa8795676b | 33 | |
leothedragon | 0:25fa8795676b | 34 | #if !defined(ARM_UC_PROFILE_MBED_CLIENT_LITE) || (ARM_UC_PROFILE_MBED_CLIENT_LITE == 0) |
leothedragon | 0:25fa8795676b | 35 | int32_t result = FirmwareUpdateResource::addUpdateCallback(callback); |
leothedragon | 0:25fa8795676b | 36 | |
leothedragon | 0:25fa8795676b | 37 | if (result == 0) { |
leothedragon | 0:25fa8795676b | 38 | retval.code = ERR_NONE; |
leothedragon | 0:25fa8795676b | 39 | } |
leothedragon | 0:25fa8795676b | 40 | #else |
leothedragon | 0:25fa8795676b | 41 | retval.code = ERR_NONE; |
leothedragon | 0:25fa8795676b | 42 | #endif |
leothedragon | 0:25fa8795676b | 43 | return retval; |
leothedragon | 0:25fa8795676b | 44 | } |
leothedragon | 0:25fa8795676b | 45 | |
leothedragon | 0:25fa8795676b | 46 | #if defined(ARM_UC_FEATURE_FW_SOURCE_COAP) && (ARM_UC_FEATURE_FW_SOURCE_COAP == 1) |
leothedragon | 0:25fa8795676b | 47 | /** |
leothedragon | 0:25fa8795676b | 48 | * @brief Setter for having reference to M2MInterface in Update client. |
leothedragon | 0:25fa8795676b | 49 | * @details M2MInterface::get_data_request is used in LWM2M source for |
leothedragon | 0:25fa8795676b | 50 | * requesting FW data over COAP * |
leothedragon | 0:25fa8795676b | 51 | * @param interface pointer to the M2MInterface instance. |
leothedragon | 0:25fa8795676b | 52 | */ |
leothedragon | 0:25fa8795676b | 53 | arm_uc_error_t ARM_UC_CONTROL_SetM2MInterface(M2MInterface *interface) |
leothedragon | 0:25fa8795676b | 54 | { |
leothedragon | 0:25fa8795676b | 55 | arm_uc_error_t retval = { .code = ERR_INVALID_PARAMETER }; |
leothedragon | 0:25fa8795676b | 56 | |
leothedragon | 0:25fa8795676b | 57 | int32_t result = FirmwareUpdateResource::setM2MInterface(interface); |
leothedragon | 0:25fa8795676b | 58 | |
leothedragon | 0:25fa8795676b | 59 | if (result == 0) { |
leothedragon | 0:25fa8795676b | 60 | retval.code = ERR_NONE; |
leothedragon | 0:25fa8795676b | 61 | } |
leothedragon | 0:25fa8795676b | 62 | |
leothedragon | 0:25fa8795676b | 63 | return retval; |
leothedragon | 0:25fa8795676b | 64 | } |
leothedragon | 0:25fa8795676b | 65 | #endif //ARM_UC_FEATURE_FW_SOURCE_COAP |