use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Revision:
27:b8aaf7dc7023
Parent:
13:9edad7677211
Child:
29:be035befb437
--- a/mbed-connector-interface/DeviceManager.h	Sun Jun 12 03:18:25 2016 +0000
+++ b/mbed-connector-interface/DeviceManager.h	Tue Jun 14 04:01:34 2016 +0000
@@ -25,39 +25,53 @@
 
 // mbed-client support
 #include "mbed-client/m2mconstants.h"
- 
-// Support for Device Resources
-#include "mbed-connector-interface/DeviceResource.h"
+#include "mbed-client/m2mdevice.h"
+#include "mbed-client/m2mfirmware.h"
 
 // Action Resource: Device DeRegistration
 #include "mbed-connector-interface/DeviceDeRegisterResource.h"
 
-// Action Resource: Device Reboot
-#include "mbed-connector-interface/DeviceRebootResource.h"
+// LWM2M Device Info # of Device Resources we support
+#define NUM_DEVICE_RESOURCES                9
 
-// Action Resource: Device Reset
-#include "mbed-connector-interface/DeviceResetResource.h"
-
-// Action Resource: Device Firmware
-#include "mbed-connector-interface/DeviceFirmwareCompositeResource.h"
+// LWM2M Firmware Resources supported
+#define NUM_FIRMWARE_RESOURCES              5
 
-// LWM2M Device Info: Mfg, DevType, Model, Serial, Firmware version, Hardware version, Software version
-#define NUM_DEVICE_RESOURCES                7
-
-// LWM2M Device Object ID
-#define LWM2M_DEVICE_OBJ_ID                 "3"
+// LWM2M DeRegistration Object ID
+#define LWM2M_DREGISTER_OBJ_ID              "86"
 
-// LWM2M Firmware Object ID
-#define LWM2M_FIRMWARE_OBJ_ID               "5"
-
-// TEMP: Device DeRegistration Resource ID
-#define LWM2M_DEV_DEREGISTER_ID             "86"
+// LWM2M Device DeRegistration Resource ID
+#define LWM2M_DEV_DEREGISTER_ID             "1"
 
 /** DeviceManager is the endpoint management class
  */
 class DeviceManager
 {    
     public:
+        // Optional Firmware Resource (indices)
+        typedef enum {
+            PackageUri = 0,
+            PackageName = 1,
+            PackageVersion = 2, 
+            State = 3,
+            UpdateResult = 4,
+            Update = 5
+        } FirmwareResources;
+        
+        // Optional Device Resource (indices)
+        typedef enum {
+            Manufacturer = 0,
+            DeviceType = 1,
+            ModelNumber = 2, 
+            SerialNumber = 3,
+            FirmwareVersion = 4,
+            HardwareVersion = 5,
+            SoftwareVersion = 6,
+            Reboot = 7,
+            FactoryReset = 8,
+            DeRegistration = 9
+        } DeviceResources;
+        
         /**
         Default constructor
         @param logger input logger instance
@@ -96,24 +110,62 @@
         */
         void *getResponder();
         
+        // LWM2M Device: Reboot Action Handler
+        void process_reboot_action(void *args);
+        
+        // LWM2M Device: Reset Action Handler 
+        void process_reset_action(void *args);
+        
+        // LWM2M Firmware: Update
+        void process_firmware_update_action(void *args);
+        
+        // bind our device resources   
+        void bind();
+        
+        // Get a specific Firmware Resource
+        M2MResource *getFirmwareResource(FirmwareResources res); 
+        
+        // Get a specific Device Resource
+        M2MResource *getDeviceResource(DeviceResources res);
+        
+        // Get the Device Object
+        M2MDevice *getDeviceObject();
+        
+        // Get the Firmware Object
+        M2MFirmware *getFirmwareObject();
+        
     private:
         Logger                              *m_logger;
         void                                *m_endpoint;
         void                                *m_config;
         char                                *m_dev_type;
         void                                *m_dm_responder;
+        char                                *m_mfg;
+        char                                *m_model;
+        char                                *m_serial;
+        char                                *m_fw_vers;
+        char                                *m_hw_vers;
+        char                                *m_sw_vers;
         
-        // Static LWM2M Device Info Resources
-        DeviceResource                      *m_dev[NUM_DEVICE_RESOURCES];
+        // LWM2M Device Info Resources
+        M2MDevice                           *m_device;
+        M2MResource                         *m_dev_res[NUM_DEVICE_RESOURCES];
         
-        // DM Action-able Resources
+        // LWM2M Firmware Resources
+        M2MFirmware                         *m_firmware;
+        M2MResource                         *m_fw_res[NUM_FIRMWARE_RESOURCES];
+        
+        // DeRegistation Resource
         DeviceDeRegisterResource            *m_deregister_resource; 
-        DeviceRebootResource                *m_reboot_resource; 
-        DeviceResetResource                 *m_reset_resource; 
-        DeviceFirmwareCompositeResource     *m_firmware_composite_resource; 
+        
+        // Bind our Device Resources to our Device Object
+        void bindDeviceResources();
         
-        // convenience method to convert enum (int) type to string 
-        string                               createResName(M2MDevice::DeviceResource res);
+        // Bind our Firmware Resources to our Firmware Object
+        void bindFirmwareResources();   
+        
+        // Bind our mbed Cloud Resource
+        void bindMBEDCloudResources();
 };
 
 #endif // __DEVICE_MANAGER_H__
\ No newline at end of file