leo hendrickson / Mbed OS example-Ethernet-mbed-Cloud-connect
Committer:
leothedragon
Date:
Tue May 04 08:55:12 2021 +0000
Revision:
0:8f0bb79ddd48
nmn

Who changed what in which revision?

UserRevisionLine numberNew 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
leothedragon 0:8f0bb79ddd48 19 #ifndef MBED_CLOUD_CLIENT_UPDATE_CLIENT_H
leothedragon 0:8f0bb79ddd48 20 #define MBED_CLOUD_CLIENT_UPDATE_CLIENT_H
leothedragon 0:8f0bb79ddd48 21
leothedragon 0:8f0bb79ddd48 22 #include "mbed-client/m2minterface.h"
leothedragon 0:8f0bb79ddd48 23 #include "update-client-hub/update_client_public.h"
leothedragon 0:8f0bb79ddd48 24
leothedragon 0:8f0bb79ddd48 25 #include <stdint.h>
leothedragon 0:8f0bb79ddd48 26 #include <stddef.h>
leothedragon 0:8f0bb79ddd48 27
leothedragon 0:8f0bb79ddd48 28 class ServiceClient;
leothedragon 0:8f0bb79ddd48 29
leothedragon 0:8f0bb79ddd48 30 namespace UpdateClient
leothedragon 0:8f0bb79ddd48 31 {
leothedragon 0:8f0bb79ddd48 32 /**
leothedragon 0:8f0bb79ddd48 33 * Error codes used by the Update Client.
leothedragon 0:8f0bb79ddd48 34 *
leothedragon 0:8f0bb79ddd48 35 * Warning: a recoverable error occured, no user action required.
leothedragon 0:8f0bb79ddd48 36 * Error : a recoverable error occured, action required. E.g. the
leothedragon 0:8f0bb79ddd48 37 * application has to free some space and let the Update
leothedragon 0:8f0bb79ddd48 38 * Service try again.
leothedragon 0:8f0bb79ddd48 39 * Fatal : a non-recoverable error occured, application should safe
leothedragon 0:8f0bb79ddd48 40 * ongoing work and reboot the device.
leothedragon 0:8f0bb79ddd48 41 */
leothedragon 0:8f0bb79ddd48 42 enum {
leothedragon 0:8f0bb79ddd48 43 WarningBase = 0x0400, // Range reserved for Update Error from 0x0400 - 0x04FF
leothedragon 0:8f0bb79ddd48 44 WarningCertificateNotFound = WarningBase + ARM_UC_WARNING_CERTIFICATE_NOT_FOUND,
leothedragon 0:8f0bb79ddd48 45 WarningIdentityNotFound = WarningBase + ARM_UC_WARNING_IDENTITY_NOT_FOUND,
leothedragon 0:8f0bb79ddd48 46 WarningVendorMismatch = WarningBase + ARM_UC_WARNING_VENDOR_MISMATCH,
leothedragon 0:8f0bb79ddd48 47 WarningClassMismatch = WarningBase + ARM_UC_WARNING_CLASS_MISMATCH,
leothedragon 0:8f0bb79ddd48 48 WarningDeviceMismatch = WarningBase + ARM_UC_WARNING_DEVICE_MISMATCH,
leothedragon 0:8f0bb79ddd48 49 WarningCertificateInvalid = WarningBase + ARM_UC_WARNING_CERTIFICATE_INVALID,
leothedragon 0:8f0bb79ddd48 50 WarningSignatureInvalid = WarningBase + ARM_UC_WARNING_SIGNATURE_INVALID,
leothedragon 0:8f0bb79ddd48 51 WarningBadKeytable = WarningBase + ARM_UC_WARNING_BAD_KEYTABLE,
leothedragon 0:8f0bb79ddd48 52 WarningURINotFound = WarningBase + ARM_UC_WARNING_URI_NOT_FOUND,
leothedragon 0:8f0bb79ddd48 53 WarningRollbackProtection = WarningBase + ARM_UC_WARNING_ROLLBACK_PROTECTION,
leothedragon 0:8f0bb79ddd48 54 WarningUnknown = WarningBase + ARM_UC_WARNING_UNKNOWN,
leothedragon 0:8f0bb79ddd48 55 WarningCertificateInsertion,
leothedragon 0:8f0bb79ddd48 56 ErrorBase,
leothedragon 0:8f0bb79ddd48 57 ErrorWriteToStorage = ErrorBase + ARM_UC_ERROR_WRITE_TO_STORAGE,
leothedragon 0:8f0bb79ddd48 58 ErrorInvalidHash = ErrorBase + ARM_UC_ERROR_INVALID_HASH,
leothedragon 0:8f0bb79ddd48 59 ErrorConnection = ErrorBase + ARM_UC_ERROR_CONNECTION,
leothedragon 0:8f0bb79ddd48 60 FatalBase
leothedragon 0:8f0bb79ddd48 61 };
leothedragon 0:8f0bb79ddd48 62
leothedragon 0:8f0bb79ddd48 63 enum {
leothedragon 0:8f0bb79ddd48 64 RequestInvalid = ARM_UCCC_REQUEST_INVALID,
leothedragon 0:8f0bb79ddd48 65 RequestDownload = ARM_UCCC_REQUEST_DOWNLOAD,
leothedragon 0:8f0bb79ddd48 66 RequestInstall = ARM_UCCC_REQUEST_INSTALL
leothedragon 0:8f0bb79ddd48 67 };
leothedragon 0:8f0bb79ddd48 68
leothedragon 0:8f0bb79ddd48 69 /**
leothedragon 0:8f0bb79ddd48 70 * \brief Initialization function for the Update Client.
leothedragon 0:8f0bb79ddd48 71 * \param Callback to error handler.
leothedragon 0:8f0bb79ddd48 72 */
leothedragon 0:8f0bb79ddd48 73 void UpdateClient(FP1<void, int32_t> callback, M2MInterface *m2mInterface, ServiceClient *service);
leothedragon 0:8f0bb79ddd48 74 /**
leothedragon 0:8f0bb79ddd48 75 * \brief Populate M2MObjectList with Update Client objects.
leothedragon 0:8f0bb79ddd48 76 * \details The function takes an existing object list and adds LWM2M
leothedragon 0:8f0bb79ddd48 77 * objects needed by the Update Client.
leothedragon 0:8f0bb79ddd48 78 *
leothedragon 0:8f0bb79ddd48 79 * \param list M2MObjectList reference.
leothedragon 0:8f0bb79ddd48 80 */
leothedragon 0:8f0bb79ddd48 81 void populate_object_list(M2MBaseList& list);
leothedragon 0:8f0bb79ddd48 82
leothedragon 0:8f0bb79ddd48 83 /**
leothedragon 0:8f0bb79ddd48 84 * \brief Registers a callback function for authorizing firmware downloads and reboots.
leothedragon 0:8f0bb79ddd48 85 * \param handler Callback function.
leothedragon 0:8f0bb79ddd48 86 */
leothedragon 0:8f0bb79ddd48 87 void set_update_authorize_handler(void (*handler)(int32_t request));
leothedragon 0:8f0bb79ddd48 88
leothedragon 0:8f0bb79ddd48 89 /**
leothedragon 0:8f0bb79ddd48 90 * \brief Authorize request passed to authorization handler.
leothedragon 0:8f0bb79ddd48 91 * \param request Request being authorized.
leothedragon 0:8f0bb79ddd48 92 */
leothedragon 0:8f0bb79ddd48 93 void update_authorize(int32_t request);
leothedragon 0:8f0bb79ddd48 94
leothedragon 0:8f0bb79ddd48 95 /**
leothedragon 0:8f0bb79ddd48 96 * \brief Registers a callback function for monitoring download progress.
leothedragon 0:8f0bb79ddd48 97 * \param handler Callback function.
leothedragon 0:8f0bb79ddd48 98 */
leothedragon 0:8f0bb79ddd48 99 void set_update_progress_handler(void (*handler)(uint32_t progress, uint32_t total));
leothedragon 0:8f0bb79ddd48 100
leothedragon 0:8f0bb79ddd48 101 /**
leothedragon 0:8f0bb79ddd48 102 * \brief Fills the buffer with the 16-byte vendor UUID
leothedragon 0:8f0bb79ddd48 103 * \param buffer The buffer to fill with the UUID
leothedragon 0:8f0bb79ddd48 104 * \param buffer_size_max The maximum avaliable space in the buffer
leothedragon 0:8f0bb79ddd48 105 * \param value_size A pointer to a length variable to populate with the length of the UUID (always 16)
leothedragon 0:8f0bb79ddd48 106 * \retval CCS_STATUS_MEMORY_ERROR when the buffer is less than 16 bytes
leothedragon 0:8f0bb79ddd48 107 * \retval CCS_STATUS_KEY_DOESNT_EXIST when no vendor ID is present
leothedragon 0:8f0bb79ddd48 108 * \retval CCS_STATUS_SUCCESS on success
leothedragon 0:8f0bb79ddd48 109 */
leothedragon 0:8f0bb79ddd48 110 int getVendorId(uint8_t* buffer, size_t buffer_size_max, size_t* value_size);
leothedragon 0:8f0bb79ddd48 111 /**
leothedragon 0:8f0bb79ddd48 112 * \brief Fills the buffer with the 16-byte device class UUID
leothedragon 0:8f0bb79ddd48 113 * \param buffer The buffer to fill with the UUID
leothedragon 0:8f0bb79ddd48 114 * \param buffer_size_max The maximum avaliable space in the buffer
leothedragon 0:8f0bb79ddd48 115 * \param value_size A pointer to a length variable to populate with the length of the UUID (always 16)
leothedragon 0:8f0bb79ddd48 116 * \retval CCS_STATUS_MEMORY_ERROR when the buffer is less than 16 bytes
leothedragon 0:8f0bb79ddd48 117 * \retval CCS_STATUS_KEY_DOESNT_EXIST when no device class ID is present
leothedragon 0:8f0bb79ddd48 118 * \retval CCS_STATUS_SUCCESS on success
leothedragon 0:8f0bb79ddd48 119 */
leothedragon 0:8f0bb79ddd48 120 int getClassId(uint8_t* buffer, size_t buffer_size_max, size_t* value_size);
leothedragon 0:8f0bb79ddd48 121 /**
leothedragon 0:8f0bb79ddd48 122 * \brief Fills the buffer with the 16-byte device UUID
leothedragon 0:8f0bb79ddd48 123 * \param buffer The buffer to fill with the UUID
leothedragon 0:8f0bb79ddd48 124 * \param buffer_size_max The maximum avaliable space in the buffer
leothedragon 0:8f0bb79ddd48 125 * \param value_size A pointer to a length variable to populate with the length of the UUID (always 16)
leothedragon 0:8f0bb79ddd48 126 * \retval CCS_STATUS_MEMORY_ERROR when the buffer is less than 16 bytes
leothedragon 0:8f0bb79ddd48 127 * \retval CCS_STATUS_KEY_DOESNT_EXIST when no device ID is present
leothedragon 0:8f0bb79ddd48 128 * \retval CCS_STATUS_SUCCESS on success
leothedragon 0:8f0bb79ddd48 129 */
leothedragon 0:8f0bb79ddd48 130 int getDeviceId(uint8_t* buffer, size_t buffer_size_max, size_t* value_size);
leothedragon 0:8f0bb79ddd48 131 }
leothedragon 0:8f0bb79ddd48 132
leothedragon 0:8f0bb79ddd48 133 #endif // MBED_CLOUD_CLIENT_UPDATE_CLIENT_H