Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_uc_device_identity.c Source File

arm_uc_device_identity.c

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2017 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #include "pal4life-device-identity/pal_device_identity.h"
00020 #include "update-client-common/arm_uc_config.h"
00021 
00022 #if ARM_UC_USE_KCM
00023 extern const ARM_PAL_DEVICE_IDENTITY arm_uc_device_identity_kcm;
00024 static const ARM_PAL_DEVICE_IDENTITY* arm_uc_device_identity =
00025     &arm_uc_device_identity_kcm;
00026 #elif ARM_UC_USE_CFSTORE
00027 extern const ARM_PAL_DEVICE_IDENTITY arm_uc_device_identity_cfstore;
00028 static const ARM_PAL_DEVICE_IDENTITY* arm_uc_device_identity =
00029     &arm_uc_device_identity_cfstore;
00030 #else
00031 #error No configuration store set
00032 #endif
00033 
00034 /**
00035  * @brief Function for setting the vendor GUID.
00036  * @details The GUID is copied.
00037  * @param vendor_guid Pointer to a arm_uc_guid_t GUID.
00038  * @return Error code.
00039  */
00040 arm_uc_error_t pal_setVendorGuid(const arm_uc_guid_t* vendor_guid)
00041 {
00042     arm_uc_error_t result = { .code = ERR_INVALID_PARAMETER };
00043 
00044     if (arm_uc_device_identity)
00045     {
00046         result = arm_uc_device_identity->SetVendorGuid(vendor_guid);
00047     }
00048 
00049     return result;
00050 }
00051 
00052 /**
00053  * @brief Function for getting a pointer to the vendor GUID.
00054  * @param vendor_guid Pointer to a arm_uc_guid_t pointer.
00055  * @return Error code.
00056  */
00057 arm_uc_error_t pal_getVendorGuid(arm_uc_guid_t* vendor_guid)
00058 {
00059     arm_uc_error_t result = { .code = ERR_INVALID_PARAMETER };
00060 
00061     if (arm_uc_device_identity)
00062     {
00063         result = arm_uc_device_identity->GetVendorGuid(vendor_guid);
00064     }
00065 
00066     return result;
00067 }
00068 
00069 /**
00070  * @brief Function for setting the device class GUID.
00071  * @details The GUID is copied.
00072  * @param class_guid Pointer to a arm_uc_guid_t GUID.
00073  * @return Error code.
00074  */
00075 arm_uc_error_t pal_setClassGuid(const arm_uc_guid_t* class_guid)
00076 {
00077     arm_uc_error_t result = { .code = ERR_INVALID_PARAMETER };
00078 
00079     if (arm_uc_device_identity)
00080     {
00081         result = arm_uc_device_identity->SetClassGuid(class_guid);
00082     }
00083 
00084     return result;
00085 }
00086 
00087 /**
00088  * @brief Function for getting a pointer to the device class GUID.
00089  * @param class_guid Pointer to a arm_uc_guid_t pointer.
00090  * @return Error code.
00091  */
00092 arm_uc_error_t pal_getClassGuid(arm_uc_guid_t* class_guid)
00093 {
00094     arm_uc_error_t result = { .code = ERR_INVALID_PARAMETER };
00095 
00096     if (arm_uc_device_identity)
00097     {
00098         result = arm_uc_device_identity->GetClassGuid(class_guid);
00099     }
00100 
00101     return result;
00102 }
00103 
00104 /**
00105  * @brief Function for setting the device GUID.
00106  * @details The GUID is copied.
00107  * @param device_guid Pointer to a arm_uc_guid_t GUID.
00108  * @return Error code.
00109  */
00110 arm_uc_error_t pal_setDeviceGuid(const arm_uc_guid_t* device_guid)
00111 {
00112     arm_uc_error_t result = { .code = ERR_INVALID_PARAMETER };
00113 
00114     if (arm_uc_device_identity)
00115     {
00116         result = arm_uc_device_identity->SetDeviceGuid(device_guid);
00117     }
00118 
00119     return result;
00120 }
00121 
00122 /**
00123  * @brief Function for getting a pointer to the device GUID.
00124  * @param device_guid Pointer to a arm_uc_guid_t pointer.
00125  * @return Error code.
00126  */
00127 arm_uc_error_t pal_getDeviceGuid(arm_uc_guid_t* device_guid)
00128 {
00129     arm_uc_error_t result = { .code = ERR_INVALID_PARAMETER };
00130 
00131     if (arm_uc_device_identity)
00132     {
00133         result = arm_uc_device_identity->GetDeviceGuid(device_guid);
00134     }
00135 
00136     return result;
00137 }
00138 
00139 /**
00140  * @brief Check whether the three GUIDs provided are valid on the device.
00141  * @details
00142  * @param vendor_guid Buffer pointer to the Vendor GUID.
00143  * @param class_guid  Buffer pointer to the device class GUID.
00144  * @param device_guid Buffer pointer to the device GUID.
00145  * @return Error code.
00146  */
00147 arm_uc_error_t pal_deviceIdentityCheck(const arm_uc_buffer_t* vendor_guid,
00148                                        const arm_uc_buffer_t* class_guid,
00149                                        const arm_uc_buffer_t* device_guid)
00150 {
00151     arm_uc_error_t result = { .code = ERR_INVALID_PARAMETER };
00152 
00153     if (arm_uc_device_identity)
00154     {
00155         result = arm_uc_device_identity->DeviceIdentityCheck(vendor_guid,
00156                                                        class_guid,
00157                                                        device_guid);
00158     }
00159 
00160     return result;
00161 }