Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbedConnectorInterfaceWithDM by
DeviceManager.h
00001 /** 00002 * @file DeviceManager.h 00003 * @brief mbed CoAP Endpoint Device Management class 00004 * @author Doug Anson 00005 * @version 1.0 00006 * @see 00007 * 00008 * Copyright (c) 2016 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); 00011 * you may not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, 00018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 */ 00022 00023 #ifndef __DEVICE_MANAGER_H__ 00024 #define __DEVICE_MANAGER_H__ 00025 00026 // mbed-client support 00027 #include "mbed-client/m2mconstants.h" 00028 #include "mbed-client/m2mdevice.h" 00029 #include "mbed-client/m2mfirmware.h" 00030 00031 // Action Resource: Device DeRegistration 00032 #include "mbed-connector-interface/DeviceDeRegisterResource.h" 00033 00034 // LWM2M Device Info # of Device Resources we support 00035 #define NUM_DEVICE_RESOURCES 9 00036 00037 // LWM2M Firmware Resources supported 00038 #define NUM_FIRMWARE_RESOURCES 7 00039 00040 // LWM2M DeRegistration Object ID 00041 #define LWM2M_DREGISTER_OBJ_ID "86" 00042 00043 // LWM2M Device DeRegistration Resource ID 00044 #define LWM2M_DEV_DEREGISTER_ID "1" 00045 00046 /** DeviceManager is the endpoint management class 00047 */ 00048 class DeviceManager 00049 { 00050 public: 00051 // Optional Firmware Resource (indices) 00052 typedef enum { 00053 PackageName = 0, 00054 PackageVersion = 1, 00055 Update = 2, 00056 Package = 3, 00057 PackageURI = 4, 00058 State = 5, 00059 UpdateResult = 6 00060 } FirmwareResources; 00061 00062 // Optional Device Resource (indices) 00063 typedef enum { 00064 Manufacturer = 0, 00065 DeviceType = 1, 00066 ModelNumber = 2, 00067 SerialNumber = 3, 00068 FirmwareVersion = 4, 00069 HardwareVersion = 5, 00070 SoftwareVersion = 6, 00071 Reboot = 7, 00072 FactoryReset = 8, 00073 DeRegistration = 9 00074 } DeviceResources; 00075 00076 /** 00077 Default constructor 00078 @param logger input logger instance 00079 @param dm_responder input data management responder/processor 00080 @param mfg input endpoint manufacturer 00081 @param dev_type input the endpoint type 00082 @param model input the model of the endpoint 00083 @param serial input the serial of the endpoint 00084 @param fw_vers input the current firmware version 00085 @param hw_vers input the current hardware version 00086 @param sw_vers input the current software version 00087 */ 00088 DeviceManager(const Logger *logger,const void *dm_responder=NULL,const char *mfg="ARM",const char *dev_type="mbed",const char *model="ARM" ,const char *serial="000000",const char *fw_ver="0.0.0",const char *hw_ver="0.0.0",const char *sw_ver="0.0.0"); 00089 00090 /** 00091 Copy constructor 00092 @param resource input the DeviceManager that is to be deep copied 00093 */ 00094 DeviceManager(const DeviceManager &manager); 00095 00096 /** 00097 Destructor 00098 */ 00099 virtual ~DeviceManager(); 00100 00101 /** 00102 install the device manager into the endpoint 00103 @param endpoint input the endpoint instance 00104 @param config input the endpoint configuration instance 00105 */ 00106 void install(const void *endpoint,const void *config); 00107 00108 /** 00109 get the DeviceManagementResponder 00110 @return the DeviceManagementResponder or NULL 00111 */ 00112 void *getResponder(); 00113 00114 // LWM2M Device: Reboot Action Handler 00115 void process_reboot_action(void *args); 00116 00117 // LWM2M Device: Reset Action Handler 00118 void process_reset_action(void *args); 00119 00120 // LWM2M Firmware: Update 00121 void process_firmware_update_action(void *args); 00122 00123 // bind our device resources 00124 void bind(); 00125 00126 // Get a specific Firmware Resource 00127 M2MResource *getFirmwareResource(FirmwareResources res); 00128 00129 // Get a specific Device Resource 00130 M2MResource *getDeviceResource(DeviceResources res); 00131 00132 // Get the Device Object 00133 M2MDevice *getDeviceObject(); 00134 00135 // Get the Firmware Object 00136 M2MFirmware *getFirmwareObject(); 00137 00138 // Process updated values 00139 void process(M2MBase *base, M2MBase::BaseType type); 00140 00141 private: 00142 Logger *m_logger; 00143 void *m_endpoint; 00144 void *m_config; 00145 char *m_dev_type; 00146 void *m_dm_responder; 00147 char *m_mfg; 00148 char *m_model; 00149 char *m_serial; 00150 char *m_fw_vers; 00151 char *m_hw_vers; 00152 char *m_sw_vers; 00153 00154 // LWM2M Firmware Data 00155 char *m_fw_manifest; 00156 uint32_t m_fw_manifest_length; 00157 void *m_fw_image; 00158 uint32_t m_fw_image_length; 00159 00160 // LWM2M Device Info Resources 00161 M2MDevice *m_device; 00162 M2MResource *m_dev_res[NUM_DEVICE_RESOURCES]; 00163 00164 // LWM2M Firmware Resources 00165 M2MFirmware *m_firmware; 00166 M2MResource *m_fw_res[NUM_FIRMWARE_RESOURCES]; 00167 00168 // DeRegistation Resource 00169 DeviceDeRegisterResource *m_deregister_resource; 00170 00171 // Memory utilities 00172 char *saveManifest(uint8_t *value,uint32_t length); 00173 void *saveImage(void *image,uint32_t image_length); 00174 00175 // Bind our Device Resources to our Device Object 00176 void bindDeviceResources(); 00177 00178 // Bind our Firmware Resources to our Firmware Object 00179 void bindFirmwareResources(); 00180 00181 // Bind our mbed Cloud Resource 00182 void bindMBEDCloudResources(); 00183 00184 // Get the Device Reboot Resource from the Device Object 00185 M2MResource *getDeviceRebootResource(); 00186 00187 // Get the Firmware Update Resource from the Firmware Object 00188 M2MResource *getFirmwareUpdateResource(); 00189 00190 // Get the Firmware Package Resource from the Firmware Object 00191 M2MResource *getFirmwarePackageResource(); 00192 00193 // Get the Firmware Package URI Resource from the Firmware Object 00194 M2MResource *getFirmwarePackageURIResource(); 00195 00196 // Get the Firmware State Resource from the Firmware Object 00197 M2MResource *getFirmwareStateResource(); 00198 00199 // Get the Firmware UpdateResult Resource from the Firmware Object 00200 M2MResource *getFirmwareUpdateResultResource(); 00201 00202 // Get a specific resource from a given resource object 00203 M2MResource *getResourceFromObject(M2MObject *obj,int instanceID,int resID); 00204 }; 00205 00206 #endif // __DEVICE_MANAGER_H__
Generated on Wed Jul 13 2022 01:24:02 by
