Pfp Cybersecurity (Aka Power Fingerprinting, Inc.) / Mbed OS pfp-emon-nxp

Dependencies:   FXAS21002 FXOS8700Q

Committer:
vithyat
Date:
Wed Aug 28 19:24:56 2019 +0000
Revision:
0:977e87915078
init

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vithyat 0:977e87915078 1 // ----------------------------------------------------------------------------
vithyat 0:977e87915078 2 // Copyright 2016-2017 ARM Ltd.
vithyat 0:977e87915078 3 //
vithyat 0:977e87915078 4 // SPDX-License-Identifier: Apache-2.0
vithyat 0:977e87915078 5 //
vithyat 0:977e87915078 6 // Licensed under the Apache License, Version 2.0 (the "License");
vithyat 0:977e87915078 7 // you may not use this file except in compliance with the License.
vithyat 0:977e87915078 8 // You may obtain a copy of the License at
vithyat 0:977e87915078 9 //
vithyat 0:977e87915078 10 // http://www.apache.org/licenses/LICENSE-2.0
vithyat 0:977e87915078 11 //
vithyat 0:977e87915078 12 // Unless required by applicable law or agreed to in writing, software
vithyat 0:977e87915078 13 // distributed under the License is distributed on an "AS IS" BASIS,
vithyat 0:977e87915078 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
vithyat 0:977e87915078 15 // See the License for the specific language governing permissions and
vithyat 0:977e87915078 16 // limitations under the License.
vithyat 0:977e87915078 17 // ----------------------------------------------------------------------------
vithyat 0:977e87915078 18
vithyat 0:977e87915078 19 #ifndef MBED_CLOUD_CLIENT_UPDATE_CLIENT_H
vithyat 0:977e87915078 20 #define MBED_CLOUD_CLIENT_UPDATE_CLIENT_H
vithyat 0:977e87915078 21
vithyat 0:977e87915078 22 #include "mbed-client/m2minterface.h"
vithyat 0:977e87915078 23 #include "update-client-hub/update_client_public.h"
vithyat 0:977e87915078 24
vithyat 0:977e87915078 25 #include <stdint.h>
vithyat 0:977e87915078 26 #include <stddef.h>
vithyat 0:977e87915078 27
vithyat 0:977e87915078 28 class ServiceClient;
vithyat 0:977e87915078 29
vithyat 0:977e87915078 30 namespace UpdateClient
vithyat 0:977e87915078 31 {
vithyat 0:977e87915078 32 /**
vithyat 0:977e87915078 33 * Error codes used by the Update Client.
vithyat 0:977e87915078 34 *
vithyat 0:977e87915078 35 * Warning: a recoverable error occured, no user action required.
vithyat 0:977e87915078 36 * Error : a recoverable error occured, action required. E.g. the
vithyat 0:977e87915078 37 * application has to free some space and let the Update
vithyat 0:977e87915078 38 * Service try again.
vithyat 0:977e87915078 39 * Fatal : a non-recoverable error occured, application should safe
vithyat 0:977e87915078 40 * ongoing work and reboot the device.
vithyat 0:977e87915078 41 */
vithyat 0:977e87915078 42 enum {
vithyat 0:977e87915078 43 WarningBase = 0x0400, // Range reserved for Update Error from 0x0400 - 0x04FF
vithyat 0:977e87915078 44 WarningCertificateNotFound = WarningBase + ARM_UC_WARNING_CERTIFICATE_NOT_FOUND,
vithyat 0:977e87915078 45 WarningIdentityNotFound = WarningBase + ARM_UC_WARNING_IDENTITY_NOT_FOUND,
vithyat 0:977e87915078 46 WarningVendorMismatch = WarningBase + ARM_UC_WARNING_VENDOR_MISMATCH,
vithyat 0:977e87915078 47 WarningClassMismatch = WarningBase + ARM_UC_WARNING_CLASS_MISMATCH,
vithyat 0:977e87915078 48 WarningDeviceMismatch = WarningBase + ARM_UC_WARNING_DEVICE_MISMATCH,
vithyat 0:977e87915078 49 WarningCertificateInvalid = WarningBase + ARM_UC_WARNING_CERTIFICATE_INVALID,
vithyat 0:977e87915078 50 WarningSignatureInvalid = WarningBase + ARM_UC_WARNING_SIGNATURE_INVALID,
vithyat 0:977e87915078 51 WarningBadKeytable = WarningBase + ARM_UC_WARNING_BAD_KEYTABLE,
vithyat 0:977e87915078 52 WarningURINotFound = WarningBase + ARM_UC_WARNING_URI_NOT_FOUND,
vithyat 0:977e87915078 53 WarningRollbackProtection = WarningBase + ARM_UC_WARNING_ROLLBACK_PROTECTION,
vithyat 0:977e87915078 54 WarningUnknown = WarningBase + ARM_UC_WARNING_UNKNOWN,
vithyat 0:977e87915078 55 WarningCertificateInsertion,
vithyat 0:977e87915078 56 ErrorBase,
vithyat 0:977e87915078 57 ErrorWriteToStorage = ErrorBase + ARM_UC_ERROR_WRITE_TO_STORAGE,
vithyat 0:977e87915078 58 ErrorInvalidHash = ErrorBase + ARM_UC_ERROR_INVALID_HASH,
vithyat 0:977e87915078 59 ErrorConnection = ErrorBase + ARM_UC_ERROR_CONNECTION,
vithyat 0:977e87915078 60 FatalBase
vithyat 0:977e87915078 61 };
vithyat 0:977e87915078 62
vithyat 0:977e87915078 63 enum {
vithyat 0:977e87915078 64 RequestInvalid = ARM_UCCC_REQUEST_INVALID,
vithyat 0:977e87915078 65 RequestDownload = ARM_UCCC_REQUEST_DOWNLOAD,
vithyat 0:977e87915078 66 RequestInstall = ARM_UCCC_REQUEST_INSTALL
vithyat 0:977e87915078 67 };
vithyat 0:977e87915078 68
vithyat 0:977e87915078 69 /**
vithyat 0:977e87915078 70 * \brief Initialization function for the Update Client.
vithyat 0:977e87915078 71 * \param Callback to error handler.
vithyat 0:977e87915078 72 */
vithyat 0:977e87915078 73 void UpdateClient(FP1<void, int32_t> callback, M2MInterface *m2mInterface, ServiceClient *service);
vithyat 0:977e87915078 74 /**
vithyat 0:977e87915078 75 * \brief Populate M2MObjectList with Update Client objects.
vithyat 0:977e87915078 76 * \details The function takes an existing object list and adds LWM2M
vithyat 0:977e87915078 77 * objects needed by the Update Client.
vithyat 0:977e87915078 78 *
vithyat 0:977e87915078 79 * \param list M2MObjectList reference.
vithyat 0:977e87915078 80 */
vithyat 0:977e87915078 81 void populate_object_list(M2MBaseList& list);
vithyat 0:977e87915078 82
vithyat 0:977e87915078 83 /**
vithyat 0:977e87915078 84 * \brief Registers a callback function for authorizing firmware downloads and reboots.
vithyat 0:977e87915078 85 * \param handler Callback function.
vithyat 0:977e87915078 86 */
vithyat 0:977e87915078 87 void set_update_authorize_handler(void (*handler)(int32_t request));
vithyat 0:977e87915078 88
vithyat 0:977e87915078 89 /**
vithyat 0:977e87915078 90 * \brief Authorize request passed to authorization handler.
vithyat 0:977e87915078 91 * \param request Request being authorized.
vithyat 0:977e87915078 92 */
vithyat 0:977e87915078 93 void update_authorize(int32_t request);
vithyat 0:977e87915078 94
vithyat 0:977e87915078 95 /**
vithyat 0:977e87915078 96 * \brief Registers a callback function for monitoring download progress.
vithyat 0:977e87915078 97 * \param handler Callback function.
vithyat 0:977e87915078 98 */
vithyat 0:977e87915078 99 void set_update_progress_handler(void (*handler)(uint32_t progress, uint32_t total));
vithyat 0:977e87915078 100
vithyat 0:977e87915078 101 /**
vithyat 0:977e87915078 102 * \brief Fills the buffer with the 16-byte vendor UUID
vithyat 0:977e87915078 103 * \param buffer The buffer to fill with the UUID
vithyat 0:977e87915078 104 * \param buffer_size_max The maximum avaliable space in the buffer
vithyat 0:977e87915078 105 * \param value_size A pointer to a length variable to populate with the length of the UUID (always 16)
vithyat 0:977e87915078 106 * \retval CCS_STATUS_MEMORY_ERROR when the buffer is less than 16 bytes
vithyat 0:977e87915078 107 * \retval CCS_STATUS_KEY_DOESNT_EXIST when no vendor ID is present
vithyat 0:977e87915078 108 * \retval CCS_STATUS_SUCCESS on success
vithyat 0:977e87915078 109 */
vithyat 0:977e87915078 110 int getVendorId(uint8_t* buffer, size_t buffer_size_max, size_t* value_size);
vithyat 0:977e87915078 111 /**
vithyat 0:977e87915078 112 * \brief Fills the buffer with the 16-byte device class UUID
vithyat 0:977e87915078 113 * \param buffer The buffer to fill with the UUID
vithyat 0:977e87915078 114 * \param buffer_size_max The maximum avaliable space in the buffer
vithyat 0:977e87915078 115 * \param value_size A pointer to a length variable to populate with the length of the UUID (always 16)
vithyat 0:977e87915078 116 * \retval CCS_STATUS_MEMORY_ERROR when the buffer is less than 16 bytes
vithyat 0:977e87915078 117 * \retval CCS_STATUS_KEY_DOESNT_EXIST when no device class ID is present
vithyat 0:977e87915078 118 * \retval CCS_STATUS_SUCCESS on success
vithyat 0:977e87915078 119 */
vithyat 0:977e87915078 120 int getClassId(uint8_t* buffer, size_t buffer_size_max, size_t* value_size);
vithyat 0:977e87915078 121 /**
vithyat 0:977e87915078 122 * \brief Fills the buffer with the 16-byte device UUID
vithyat 0:977e87915078 123 * \param buffer The buffer to fill with the UUID
vithyat 0:977e87915078 124 * \param buffer_size_max The maximum avaliable space in the buffer
vithyat 0:977e87915078 125 * \param value_size A pointer to a length variable to populate with the length of the UUID (always 16)
vithyat 0:977e87915078 126 * \retval CCS_STATUS_MEMORY_ERROR when the buffer is less than 16 bytes
vithyat 0:977e87915078 127 * \retval CCS_STATUS_KEY_DOESNT_EXIST when no device ID is present
vithyat 0:977e87915078 128 * \retval CCS_STATUS_SUCCESS on success
vithyat 0:977e87915078 129 */
vithyat 0:977e87915078 130 int getDeviceId(uint8_t* buffer, size_t buffer_size_max, size_t* value_size);
vithyat 0:977e87915078 131 }
vithyat 0:977e87915078 132
vithyat 0:977e87915078 133 #endif // MBED_CLOUD_CLIENT_UPDATE_CLIENT_H