Example

Dependencies:   FXAS21002 FXOS8700Q

Committer:
maygup01
Date:
Tue Nov 19 09:49:38 2019 +0000
Revision:
0:11cc2b7889af
Example

Who changed what in which revision?

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