use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Tue Jun 14 05:54:20 2016 +0000
Revision:
29:be035befb437
Parent:
27:b8aaf7dc7023
Child:
30:db367366b1f5
updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 13:9edad7677211 1 /**
ansond 13:9edad7677211 2 * @file DeviceManager.h
ansond 13:9edad7677211 3 * @brief mbed CoAP Endpoint Device Management class
ansond 13:9edad7677211 4 * @author Doug Anson
ansond 13:9edad7677211 5 * @version 1.0
ansond 13:9edad7677211 6 * @see
ansond 13:9edad7677211 7 *
ansond 13:9edad7677211 8 * Copyright (c) 2016
ansond 13:9edad7677211 9 *
ansond 13:9edad7677211 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 13:9edad7677211 11 * you may not use this file except in compliance with the License.
ansond 13:9edad7677211 12 * You may obtain a copy of the License at
ansond 13:9edad7677211 13 *
ansond 13:9edad7677211 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 13:9edad7677211 15 *
ansond 13:9edad7677211 16 * Unless required by applicable law or agreed to in writing, software
ansond 13:9edad7677211 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 13:9edad7677211 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 13:9edad7677211 19 * See the License for the specific language governing permissions and
ansond 13:9edad7677211 20 * limitations under the License.
ansond 13:9edad7677211 21 */
ansond 13:9edad7677211 22
ansond 13:9edad7677211 23 #ifndef __DEVICE_MANAGER_H__
ansond 13:9edad7677211 24 #define __DEVICE_MANAGER_H__
ansond 13:9edad7677211 25
ansond 13:9edad7677211 26 // mbed-client support
ansond 13:9edad7677211 27 #include "mbed-client/m2mconstants.h"
ansond 27:b8aaf7dc7023 28 #include "mbed-client/m2mdevice.h"
ansond 27:b8aaf7dc7023 29 #include "mbed-client/m2mfirmware.h"
ansond 13:9edad7677211 30
ansond 13:9edad7677211 31 // Action Resource: Device DeRegistration
ansond 13:9edad7677211 32 #include "mbed-connector-interface/DeviceDeRegisterResource.h"
ansond 13:9edad7677211 33
ansond 27:b8aaf7dc7023 34 // LWM2M Device Info # of Device Resources we support
ansond 27:b8aaf7dc7023 35 #define NUM_DEVICE_RESOURCES 9
ansond 13:9edad7677211 36
ansond 27:b8aaf7dc7023 37 // LWM2M Firmware Resources supported
ansond 29:be035befb437 38 #define NUM_FIRMWARE_RESOURCES 7
ansond 13:9edad7677211 39
ansond 27:b8aaf7dc7023 40 // LWM2M DeRegistration Object ID
ansond 27:b8aaf7dc7023 41 #define LWM2M_DREGISTER_OBJ_ID "86"
ansond 13:9edad7677211 42
ansond 27:b8aaf7dc7023 43 // LWM2M Device DeRegistration Resource ID
ansond 27:b8aaf7dc7023 44 #define LWM2M_DEV_DEREGISTER_ID "1"
ansond 13:9edad7677211 45
ansond 13:9edad7677211 46 /** DeviceManager is the endpoint management class
ansond 13:9edad7677211 47 */
ansond 13:9edad7677211 48 class DeviceManager
ansond 13:9edad7677211 49 {
ansond 13:9edad7677211 50 public:
ansond 27:b8aaf7dc7023 51 // Optional Firmware Resource (indices)
ansond 27:b8aaf7dc7023 52 typedef enum {
ansond 29:be035befb437 53 PackageName = 0,
ansond 29:be035befb437 54 PackageVersion = 1,
ansond 29:be035befb437 55 Update = 2,
ansond 29:be035befb437 56 Package = 3,
ansond 29:be035befb437 57 PackageURI = 4,
ansond 29:be035befb437 58 State = 5,
ansond 29:be035befb437 59 UpdateResult = 6
ansond 27:b8aaf7dc7023 60 } FirmwareResources;
ansond 27:b8aaf7dc7023 61
ansond 27:b8aaf7dc7023 62 // Optional Device Resource (indices)
ansond 27:b8aaf7dc7023 63 typedef enum {
ansond 27:b8aaf7dc7023 64 Manufacturer = 0,
ansond 27:b8aaf7dc7023 65 DeviceType = 1,
ansond 27:b8aaf7dc7023 66 ModelNumber = 2,
ansond 27:b8aaf7dc7023 67 SerialNumber = 3,
ansond 27:b8aaf7dc7023 68 FirmwareVersion = 4,
ansond 27:b8aaf7dc7023 69 HardwareVersion = 5,
ansond 27:b8aaf7dc7023 70 SoftwareVersion = 6,
ansond 27:b8aaf7dc7023 71 Reboot = 7,
ansond 27:b8aaf7dc7023 72 FactoryReset = 8,
ansond 27:b8aaf7dc7023 73 DeRegistration = 9
ansond 27:b8aaf7dc7023 74 } DeviceResources;
ansond 27:b8aaf7dc7023 75
ansond 13:9edad7677211 76 /**
ansond 13:9edad7677211 77 Default constructor
ansond 13:9edad7677211 78 @param logger input logger instance
ansond 13:9edad7677211 79 @param dm_responder input data management responder/processor
ansond 13:9edad7677211 80 @param mfg input endpoint manufacturer
ansond 13:9edad7677211 81 @param dev_type input the endpoint type
ansond 13:9edad7677211 82 @param model input the model of the endpoint
ansond 13:9edad7677211 83 @param serial input the serial of the endpoint
ansond 13:9edad7677211 84 @param fw_vers input the current firmware version
ansond 13:9edad7677211 85 @param hw_vers input the current hardware version
ansond 13:9edad7677211 86 @param sw_vers input the current software version
ansond 13:9edad7677211 87 */
ansond 13:9edad7677211 88 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");
ansond 13:9edad7677211 89
ansond 13:9edad7677211 90 /**
ansond 13:9edad7677211 91 Copy constructor
ansond 13:9edad7677211 92 @param resource input the DeviceManager that is to be deep copied
ansond 13:9edad7677211 93 */
ansond 13:9edad7677211 94 DeviceManager(const DeviceManager &manager);
ansond 13:9edad7677211 95
ansond 13:9edad7677211 96 /**
ansond 13:9edad7677211 97 Destructor
ansond 13:9edad7677211 98 */
ansond 13:9edad7677211 99 virtual ~DeviceManager();
ansond 13:9edad7677211 100
ansond 13:9edad7677211 101 /**
ansond 13:9edad7677211 102 install the device manager into the endpoint
ansond 13:9edad7677211 103 @param endpoint input the endpoint instance
ansond 13:9edad7677211 104 @param config input the endpoint configuration instance
ansond 13:9edad7677211 105 */
ansond 13:9edad7677211 106 void install(const void *endpoint,const void *config);
ansond 13:9edad7677211 107
ansond 13:9edad7677211 108 /**
ansond 13:9edad7677211 109 get the DeviceManagementResponder
ansond 13:9edad7677211 110 @return the DeviceManagementResponder or NULL
ansond 13:9edad7677211 111 */
ansond 13:9edad7677211 112 void *getResponder();
ansond 13:9edad7677211 113
ansond 27:b8aaf7dc7023 114 // LWM2M Device: Reboot Action Handler
ansond 27:b8aaf7dc7023 115 void process_reboot_action(void *args);
ansond 27:b8aaf7dc7023 116
ansond 27:b8aaf7dc7023 117 // LWM2M Device: Reset Action Handler
ansond 27:b8aaf7dc7023 118 void process_reset_action(void *args);
ansond 27:b8aaf7dc7023 119
ansond 27:b8aaf7dc7023 120 // LWM2M Firmware: Update
ansond 27:b8aaf7dc7023 121 void process_firmware_update_action(void *args);
ansond 27:b8aaf7dc7023 122
ansond 27:b8aaf7dc7023 123 // bind our device resources
ansond 27:b8aaf7dc7023 124 void bind();
ansond 27:b8aaf7dc7023 125
ansond 27:b8aaf7dc7023 126 // Get a specific Firmware Resource
ansond 27:b8aaf7dc7023 127 M2MResource *getFirmwareResource(FirmwareResources res);
ansond 27:b8aaf7dc7023 128
ansond 27:b8aaf7dc7023 129 // Get a specific Device Resource
ansond 27:b8aaf7dc7023 130 M2MResource *getDeviceResource(DeviceResources res);
ansond 27:b8aaf7dc7023 131
ansond 27:b8aaf7dc7023 132 // Get the Device Object
ansond 27:b8aaf7dc7023 133 M2MDevice *getDeviceObject();
ansond 27:b8aaf7dc7023 134
ansond 27:b8aaf7dc7023 135 // Get the Firmware Object
ansond 27:b8aaf7dc7023 136 M2MFirmware *getFirmwareObject();
ansond 27:b8aaf7dc7023 137
ansond 29:be035befb437 138 // Process updated values
ansond 29:be035befb437 139 void process(M2MBase *base, M2MBase::BaseType type);
ansond 29:be035befb437 140
ansond 13:9edad7677211 141 private:
ansond 13:9edad7677211 142 Logger *m_logger;
ansond 13:9edad7677211 143 void *m_endpoint;
ansond 13:9edad7677211 144 void *m_config;
ansond 13:9edad7677211 145 char *m_dev_type;
ansond 13:9edad7677211 146 void *m_dm_responder;
ansond 27:b8aaf7dc7023 147 char *m_mfg;
ansond 27:b8aaf7dc7023 148 char *m_model;
ansond 27:b8aaf7dc7023 149 char *m_serial;
ansond 27:b8aaf7dc7023 150 char *m_fw_vers;
ansond 27:b8aaf7dc7023 151 char *m_hw_vers;
ansond 27:b8aaf7dc7023 152 char *m_sw_vers;
ansond 13:9edad7677211 153
ansond 27:b8aaf7dc7023 154 // LWM2M Device Info Resources
ansond 27:b8aaf7dc7023 155 M2MDevice *m_device;
ansond 27:b8aaf7dc7023 156 M2MResource *m_dev_res[NUM_DEVICE_RESOURCES];
ansond 13:9edad7677211 157
ansond 27:b8aaf7dc7023 158 // LWM2M Firmware Resources
ansond 27:b8aaf7dc7023 159 M2MFirmware *m_firmware;
ansond 27:b8aaf7dc7023 160 M2MResource *m_fw_res[NUM_FIRMWARE_RESOURCES];
ansond 27:b8aaf7dc7023 161
ansond 27:b8aaf7dc7023 162 // DeRegistation Resource
ansond 13:9edad7677211 163 DeviceDeRegisterResource *m_deregister_resource;
ansond 27:b8aaf7dc7023 164
ansond 27:b8aaf7dc7023 165 // Bind our Device Resources to our Device Object
ansond 27:b8aaf7dc7023 166 void bindDeviceResources();
ansond 13:9edad7677211 167
ansond 27:b8aaf7dc7023 168 // Bind our Firmware Resources to our Firmware Object
ansond 27:b8aaf7dc7023 169 void bindFirmwareResources();
ansond 27:b8aaf7dc7023 170
ansond 27:b8aaf7dc7023 171 // Bind our mbed Cloud Resource
ansond 27:b8aaf7dc7023 172 void bindMBEDCloudResources();
ansond 29:be035befb437 173
ansond 29:be035befb437 174 // Get the Device Reboot Resource from the Device Object
ansond 29:be035befb437 175 M2MResource *getDeviceRebootResource();
ansond 29:be035befb437 176
ansond 29:be035befb437 177 // Get the Firmware Update Resource from the Firmware Object
ansond 29:be035befb437 178 M2MResource *getFirmwareUpdateResource();
ansond 29:be035befb437 179
ansond 29:be035befb437 180 // Get the Firmware Package Resource from the Firmware Object
ansond 29:be035befb437 181 M2MResource *getFirmwarePackageResource();
ansond 29:be035befb437 182
ansond 29:be035befb437 183 // Get the Firmware Package URI Resource from the Firmware Object
ansond 29:be035befb437 184 M2MResource *getFirmwarePackageURIResource();
ansond 29:be035befb437 185
ansond 29:be035befb437 186 // Get the Firmware State Resource from the Firmware Object
ansond 29:be035befb437 187 M2MResource *getFirmwareStateResource();
ansond 29:be035befb437 188
ansond 29:be035befb437 189 // Get the Firmware UpdateResult Resource from the Firmware Object
ansond 29:be035befb437 190 M2MResource *getFirmwareUpdateResultResource();
ansond 29:be035befb437 191
ansond 29:be035befb437 192 // Get a specific resource from a given resource object
ansond 29:be035befb437 193 M2MResource *getResourceFromObject(M2MObject *obj,int instanceID,int resID);
ansond 13:9edad7677211 194 };
ansond 13:9edad7677211 195
ansond 13:9edad7677211 196 #endif // __DEVICE_MANAGER_H__