adding resources firmware and 1/0/8

Dependencies:   Beep C12832_lcd EthernetInterface EthernetNetIf HTTPClient LM75B MMA7660 mbed-rtos mbed nsdl_lib

Fork of LWM2M_NanoService_Ethernet by Pascal Nysten

Files at this revision

API Documentation at this revision

Comitter:
pnysten
Date:
Wed Feb 17 08:54:58 2016 +0000
Parent:
22:2fab757f9c2a
Commit message:
New

Changed in this revision

resources/Lwm2m_Server_Object.cpp Show annotated file Show diff for this revision Revisions of this file
resources/Lwm2m_Server_Object.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/resources/Lwm2m_Server_Object.cpp	Wed Feb 17 08:54:58 2016 +0000
@@ -0,0 +1,59 @@
+#include "Lwm2m_Server_Object.h"
+#include "Lwm2m_RW_Resource.h"
+#include "Lwm2m_E_Resource.h"
+
+using namespace std;
+
+void update_trigger(Lwm2m_Node * node){
+    
+    node->get_Register_Interface()->Update();
+    
+}
+
+
+//Resource constructor : Lwm2m_RW_Resource<TYPE>(ID,NAME,MULTIPLE,MANDATORY,OBJECT,INITIAL_VALUE,READ?,READ_FUNC (NULL FOR DEFAULT),WRITE?,WRITE_FUNC(NULL FOR DEFAULT))
+//                       Lwm2m_E_Resource(int Id, std::string name, bool multiple_instance, bool mandatory,OBJECT, void (*exec_func)(), Lwm2m_Node *node);
+
+Lwm2m_Server_Object::Lwm2m_Server_Object(uint16_t object_Id, int object_Instance, bool multiple_instance, bool mandatory, std::string object_URN,Lwm2m_Node * node) : Lwm2m_Object( object_Id, object_Instance,multiple_instance,mandatory,object_URN,node){
+    
+    _resources->insert(make_pair(LWM2M_SERVER_SHORT_ID_ID, new Lwm2m_RW_Resource<int>(LWM2M_SERVER_SHORT_ID_ID,"Short Server Id",false,true,this,1,true,NULL,false,NULL)));
+    _resources->insert(pair<int, Lwm2m_RW_Resource<int>*>(LWM2M_SERVER_LIFETIME_ID, new Lwm2m_RW_Resource<int>(LWM2M_SERVER_LIFETIME_ID,"Lifetime",false,true,this,60*5,true,NULL,true,NULL)));
+    _resources->insert(pair<int, Lwm2m_RW_Resource<int>*>(LWM2M_SERVER_MIN_PERIOD_ID, new Lwm2m_RW_Resource<int>(LWM2M_SERVER_MIN_PERIOD_ID,"Default Minimum Period",false,false,this,1,true,NULL,true,NULL)));
+    _resources->insert(pair<int, Lwm2m_RW_Resource<int>*>(LWM2M_SERVER_MAX_PERIOD_ID, new Lwm2m_RW_Resource<int>(LWM2M_SERVER_MAX_PERIOD_ID,"Default Maximum Period",false,false,this,90,true,NULL,true,NULL)));
+    
+    _resources->insert(pair<int, Lwm2m_RW_Resource<bool>*>(LWM2M_SERVER_STORING_ID, new Lwm2m_RW_Resource<bool>(LWM2M_SERVER_STORING_ID,"Notification Storing when Disabled or Offline",false,true,this,true,true,NULL,true,NULL)));
+    
+    _resources->insert(pair<int, Lwm2m_RW_Resource<string>*>(LWM2M_SERVER_BINDING_ID, new Lwm2m_RW_Resource<string>(LWM2M_SERVER_BINDING_ID,"Binding",false,true,this,"U",true,NULL,true,NULL)));
+    
+    void (*ptr1)(Lwm2m_Node*);
+    ptr1=update_trigger;
+    
+    _resources->insert(pair<int, Lwm2m_E_Resource*>(LWM2M_SERVER_UPDATE_ID, new Lwm2m_E_Resource(LWM2M_SERVER_UPDATE_ID,"Update Trigger",false,true,this,ptr1,_node)));
+    
+    //_resources->insert(pair<int, Lwm2m_E_Resource*>(LWM2M_SERVER_UPDATE_ID, new Update_Trigger(LWM2M_SERVER_UPDATE_ID,"Update Trigger",false,true,this,ptr1,_node)));
+    
+}
+
+Lwm2m_Server_Object::~Lwm2m_Server_Object(){
+    
+    for (Resource_Map::iterator it=_resources->begin(); it!=_resources->end(); ++it) {
+        delete it->second;
+    }
+    
+    delete _resources;
+    
+}
+
+
+string Lwm2m_Server_Object::get_Lifetime(){
+    
+    return _resources->at(LWM2M_SERVER_LIFETIME_ID)->get_Value();
+}
+
+string Lwm2m_Server_Object::get_Binding(){
+    
+    return _resources->at(LWM2M_SERVER_BINDING_ID)->get_Value();
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/resources/Lwm2m_Server_Object.h	Wed Feb 17 08:54:58 2016 +0000
@@ -0,0 +1,32 @@
+#ifndef __lwm2m_client__Lwm2m_Server_Object__
+#define __lwm2m_client__Lwm2m_Server_Object__
+
+#include <stdio.h>
+#include "Lwm2m_Object.h"
+
+
+const int LWM2M_SERVER_SHORT_ID_ID   = 0;
+const int LWM2M_SERVER_LIFETIME_ID   = 1;
+const int LWM2M_SERVER_MIN_PERIOD_ID = 2;
+const int LWM2M_SERVER_MAX_PERIOD_ID = 3;
+const int LWM2M_SERVER_DISABLE_ID    = 4;
+const int LWM2M_SERVER_DISABLE_TIMEOUT_ID    = 5;
+const int LWM2M_SERVER_STORING_ID    = 6;
+const int LWM2M_SERVER_BINDING_ID    = 7;
+const int LWM2M_SERVER_UPDATE_ID     = 8;
+
+
+class Lwm2m_Server_Object : public Lwm2m_Object {
+   
+    private :
+    
+    public:
+    
+    Lwm2m_Server_Object(uint16_t object_Id, int object_Instance, bool multiple_instance, bool mandatory, std::string object_URN,Lwm2m_Node * node);
+    virtual std::string get_Lifetime();
+    virtual std::string get_Binding();
+    
+    ~Lwm2m_Server_Object();
+};
+
+#endif /* defined(__lwm2m_client__Lwm2m_Server_Object__) */