use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Wed Jun 08 22:32:08 2016 +0000
Revision:
13:9edad7677211
Child:
27:b8aaf7dc7023
updated to latest revision with new DM functions

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 13:9edad7677211 28
ansond 13:9edad7677211 29 // Support for Device Resources
ansond 13:9edad7677211 30 #include "mbed-connector-interface/DeviceResource.h"
ansond 13:9edad7677211 31
ansond 13:9edad7677211 32 // Action Resource: Device DeRegistration
ansond 13:9edad7677211 33 #include "mbed-connector-interface/DeviceDeRegisterResource.h"
ansond 13:9edad7677211 34
ansond 13:9edad7677211 35 // Action Resource: Device Reboot
ansond 13:9edad7677211 36 #include "mbed-connector-interface/DeviceRebootResource.h"
ansond 13:9edad7677211 37
ansond 13:9edad7677211 38 // Action Resource: Device Reset
ansond 13:9edad7677211 39 #include "mbed-connector-interface/DeviceResetResource.h"
ansond 13:9edad7677211 40
ansond 13:9edad7677211 41 // Action Resource: Device Firmware
ansond 13:9edad7677211 42 #include "mbed-connector-interface/DeviceFirmwareCompositeResource.h"
ansond 13:9edad7677211 43
ansond 13:9edad7677211 44 // LWM2M Device Info: Mfg, DevType, Model, Serial, Firmware version, Hardware version, Software version
ansond 13:9edad7677211 45 #define NUM_DEVICE_RESOURCES 7
ansond 13:9edad7677211 46
ansond 13:9edad7677211 47 // LWM2M Device Object ID
ansond 13:9edad7677211 48 #define LWM2M_DEVICE_OBJ_ID "3"
ansond 13:9edad7677211 49
ansond 13:9edad7677211 50 // LWM2M Firmware Object ID
ansond 13:9edad7677211 51 #define LWM2M_FIRMWARE_OBJ_ID "5"
ansond 13:9edad7677211 52
ansond 13:9edad7677211 53 // TEMP: Device DeRegistration Resource ID
ansond 13:9edad7677211 54 #define LWM2M_DEV_DEREGISTER_ID "86"
ansond 13:9edad7677211 55
ansond 13:9edad7677211 56 /** DeviceManager is the endpoint management class
ansond 13:9edad7677211 57 */
ansond 13:9edad7677211 58 class DeviceManager
ansond 13:9edad7677211 59 {
ansond 13:9edad7677211 60 public:
ansond 13:9edad7677211 61 /**
ansond 13:9edad7677211 62 Default constructor
ansond 13:9edad7677211 63 @param logger input logger instance
ansond 13:9edad7677211 64 @param dm_responder input data management responder/processor
ansond 13:9edad7677211 65 @param mfg input endpoint manufacturer
ansond 13:9edad7677211 66 @param dev_type input the endpoint type
ansond 13:9edad7677211 67 @param model input the model of the endpoint
ansond 13:9edad7677211 68 @param serial input the serial of the endpoint
ansond 13:9edad7677211 69 @param fw_vers input the current firmware version
ansond 13:9edad7677211 70 @param hw_vers input the current hardware version
ansond 13:9edad7677211 71 @param sw_vers input the current software version
ansond 13:9edad7677211 72 */
ansond 13:9edad7677211 73 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 74
ansond 13:9edad7677211 75 /**
ansond 13:9edad7677211 76 Copy constructor
ansond 13:9edad7677211 77 @param resource input the DeviceManager that is to be deep copied
ansond 13:9edad7677211 78 */
ansond 13:9edad7677211 79 DeviceManager(const DeviceManager &manager);
ansond 13:9edad7677211 80
ansond 13:9edad7677211 81 /**
ansond 13:9edad7677211 82 Destructor
ansond 13:9edad7677211 83 */
ansond 13:9edad7677211 84 virtual ~DeviceManager();
ansond 13:9edad7677211 85
ansond 13:9edad7677211 86 /**
ansond 13:9edad7677211 87 install the device manager into the endpoint
ansond 13:9edad7677211 88 @param endpoint input the endpoint instance
ansond 13:9edad7677211 89 @param config input the endpoint configuration instance
ansond 13:9edad7677211 90 */
ansond 13:9edad7677211 91 void install(const void *endpoint,const void *config);
ansond 13:9edad7677211 92
ansond 13:9edad7677211 93 /**
ansond 13:9edad7677211 94 get the DeviceManagementResponder
ansond 13:9edad7677211 95 @return the DeviceManagementResponder or NULL
ansond 13:9edad7677211 96 */
ansond 13:9edad7677211 97 void *getResponder();
ansond 13:9edad7677211 98
ansond 13:9edad7677211 99 private:
ansond 13:9edad7677211 100 Logger *m_logger;
ansond 13:9edad7677211 101 void *m_endpoint;
ansond 13:9edad7677211 102 void *m_config;
ansond 13:9edad7677211 103 char *m_dev_type;
ansond 13:9edad7677211 104 void *m_dm_responder;
ansond 13:9edad7677211 105
ansond 13:9edad7677211 106 // Static LWM2M Device Info Resources
ansond 13:9edad7677211 107 DeviceResource *m_dev[NUM_DEVICE_RESOURCES];
ansond 13:9edad7677211 108
ansond 13:9edad7677211 109 // DM Action-able Resources
ansond 13:9edad7677211 110 DeviceDeRegisterResource *m_deregister_resource;
ansond 13:9edad7677211 111 DeviceRebootResource *m_reboot_resource;
ansond 13:9edad7677211 112 DeviceResetResource *m_reset_resource;
ansond 13:9edad7677211 113 DeviceFirmwareCompositeResource *m_firmware_composite_resource;
ansond 13:9edad7677211 114
ansond 13:9edad7677211 115 // convenience method to convert enum (int) type to string
ansond 13:9edad7677211 116 string createResName(M2MDevice::DeviceResource res);
ansond 13:9edad7677211 117 };
ansond 13:9edad7677211 118
ansond 13:9edad7677211 119 #endif // __DEVICE_MANAGER_H__