use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Tue Jun 14 04:01:34 2016 +0000
Revision:
27:b8aaf7dc7023
Parent:
13:9edad7677211
Child:
29:be035befb437
Initial merge and update of device and firmware objects

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 27:b8aaf7dc7023 38 #define NUM_FIRMWARE_RESOURCES 5
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 27:b8aaf7dc7023 53 PackageUri = 0,
ansond 27:b8aaf7dc7023 54 PackageName = 1,
ansond 27:b8aaf7dc7023 55 PackageVersion = 2,
ansond 27:b8aaf7dc7023 56 State = 3,
ansond 27:b8aaf7dc7023 57 UpdateResult = 4,
ansond 27:b8aaf7dc7023 58 Update = 5
ansond 27:b8aaf7dc7023 59 } FirmwareResources;
ansond 27:b8aaf7dc7023 60
ansond 27:b8aaf7dc7023 61 // Optional Device Resource (indices)
ansond 27:b8aaf7dc7023 62 typedef enum {
ansond 27:b8aaf7dc7023 63 Manufacturer = 0,
ansond 27:b8aaf7dc7023 64 DeviceType = 1,
ansond 27:b8aaf7dc7023 65 ModelNumber = 2,
ansond 27:b8aaf7dc7023 66 SerialNumber = 3,
ansond 27:b8aaf7dc7023 67 FirmwareVersion = 4,
ansond 27:b8aaf7dc7023 68 HardwareVersion = 5,
ansond 27:b8aaf7dc7023 69 SoftwareVersion = 6,
ansond 27:b8aaf7dc7023 70 Reboot = 7,
ansond 27:b8aaf7dc7023 71 FactoryReset = 8,
ansond 27:b8aaf7dc7023 72 DeRegistration = 9
ansond 27:b8aaf7dc7023 73 } DeviceResources;
ansond 27:b8aaf7dc7023 74
ansond 13:9edad7677211 75 /**
ansond 13:9edad7677211 76 Default constructor
ansond 13:9edad7677211 77 @param logger input logger instance
ansond 13:9edad7677211 78 @param dm_responder input data management responder/processor
ansond 13:9edad7677211 79 @param mfg input endpoint manufacturer
ansond 13:9edad7677211 80 @param dev_type input the endpoint type
ansond 13:9edad7677211 81 @param model input the model of the endpoint
ansond 13:9edad7677211 82 @param serial input the serial of the endpoint
ansond 13:9edad7677211 83 @param fw_vers input the current firmware version
ansond 13:9edad7677211 84 @param hw_vers input the current hardware version
ansond 13:9edad7677211 85 @param sw_vers input the current software version
ansond 13:9edad7677211 86 */
ansond 13:9edad7677211 87 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 88
ansond 13:9edad7677211 89 /**
ansond 13:9edad7677211 90 Copy constructor
ansond 13:9edad7677211 91 @param resource input the DeviceManager that is to be deep copied
ansond 13:9edad7677211 92 */
ansond 13:9edad7677211 93 DeviceManager(const DeviceManager &manager);
ansond 13:9edad7677211 94
ansond 13:9edad7677211 95 /**
ansond 13:9edad7677211 96 Destructor
ansond 13:9edad7677211 97 */
ansond 13:9edad7677211 98 virtual ~DeviceManager();
ansond 13:9edad7677211 99
ansond 13:9edad7677211 100 /**
ansond 13:9edad7677211 101 install the device manager into the endpoint
ansond 13:9edad7677211 102 @param endpoint input the endpoint instance
ansond 13:9edad7677211 103 @param config input the endpoint configuration instance
ansond 13:9edad7677211 104 */
ansond 13:9edad7677211 105 void install(const void *endpoint,const void *config);
ansond 13:9edad7677211 106
ansond 13:9edad7677211 107 /**
ansond 13:9edad7677211 108 get the DeviceManagementResponder
ansond 13:9edad7677211 109 @return the DeviceManagementResponder or NULL
ansond 13:9edad7677211 110 */
ansond 13:9edad7677211 111 void *getResponder();
ansond 13:9edad7677211 112
ansond 27:b8aaf7dc7023 113 // LWM2M Device: Reboot Action Handler
ansond 27:b8aaf7dc7023 114 void process_reboot_action(void *args);
ansond 27:b8aaf7dc7023 115
ansond 27:b8aaf7dc7023 116 // LWM2M Device: Reset Action Handler
ansond 27:b8aaf7dc7023 117 void process_reset_action(void *args);
ansond 27:b8aaf7dc7023 118
ansond 27:b8aaf7dc7023 119 // LWM2M Firmware: Update
ansond 27:b8aaf7dc7023 120 void process_firmware_update_action(void *args);
ansond 27:b8aaf7dc7023 121
ansond 27:b8aaf7dc7023 122 // bind our device resources
ansond 27:b8aaf7dc7023 123 void bind();
ansond 27:b8aaf7dc7023 124
ansond 27:b8aaf7dc7023 125 // Get a specific Firmware Resource
ansond 27:b8aaf7dc7023 126 M2MResource *getFirmwareResource(FirmwareResources res);
ansond 27:b8aaf7dc7023 127
ansond 27:b8aaf7dc7023 128 // Get a specific Device Resource
ansond 27:b8aaf7dc7023 129 M2MResource *getDeviceResource(DeviceResources res);
ansond 27:b8aaf7dc7023 130
ansond 27:b8aaf7dc7023 131 // Get the Device Object
ansond 27:b8aaf7dc7023 132 M2MDevice *getDeviceObject();
ansond 27:b8aaf7dc7023 133
ansond 27:b8aaf7dc7023 134 // Get the Firmware Object
ansond 27:b8aaf7dc7023 135 M2MFirmware *getFirmwareObject();
ansond 27:b8aaf7dc7023 136
ansond 13:9edad7677211 137 private:
ansond 13:9edad7677211 138 Logger *m_logger;
ansond 13:9edad7677211 139 void *m_endpoint;
ansond 13:9edad7677211 140 void *m_config;
ansond 13:9edad7677211 141 char *m_dev_type;
ansond 13:9edad7677211 142 void *m_dm_responder;
ansond 27:b8aaf7dc7023 143 char *m_mfg;
ansond 27:b8aaf7dc7023 144 char *m_model;
ansond 27:b8aaf7dc7023 145 char *m_serial;
ansond 27:b8aaf7dc7023 146 char *m_fw_vers;
ansond 27:b8aaf7dc7023 147 char *m_hw_vers;
ansond 27:b8aaf7dc7023 148 char *m_sw_vers;
ansond 13:9edad7677211 149
ansond 27:b8aaf7dc7023 150 // LWM2M Device Info Resources
ansond 27:b8aaf7dc7023 151 M2MDevice *m_device;
ansond 27:b8aaf7dc7023 152 M2MResource *m_dev_res[NUM_DEVICE_RESOURCES];
ansond 13:9edad7677211 153
ansond 27:b8aaf7dc7023 154 // LWM2M Firmware Resources
ansond 27:b8aaf7dc7023 155 M2MFirmware *m_firmware;
ansond 27:b8aaf7dc7023 156 M2MResource *m_fw_res[NUM_FIRMWARE_RESOURCES];
ansond 27:b8aaf7dc7023 157
ansond 27:b8aaf7dc7023 158 // DeRegistation Resource
ansond 13:9edad7677211 159 DeviceDeRegisterResource *m_deregister_resource;
ansond 27:b8aaf7dc7023 160
ansond 27:b8aaf7dc7023 161 // Bind our Device Resources to our Device Object
ansond 27:b8aaf7dc7023 162 void bindDeviceResources();
ansond 13:9edad7677211 163
ansond 27:b8aaf7dc7023 164 // Bind our Firmware Resources to our Firmware Object
ansond 27:b8aaf7dc7023 165 void bindFirmwareResources();
ansond 27:b8aaf7dc7023 166
ansond 27:b8aaf7dc7023 167 // Bind our mbed Cloud Resource
ansond 27:b8aaf7dc7023 168 void bindMBEDCloudResources();
ansond 13:9edad7677211 169 };
ansond 13:9edad7677211 170
ansond 13:9edad7677211 171 #endif // __DEVICE_MANAGER_H__