custom for >5 resources

Fork of mbedConnectorInterface by Doug Anson

Revision:
51:b308658817e5
Parent:
50:1a9e2184945e
Child:
52:822611156e35
--- a/api/DynamicResource.cpp	Tue Apr 14 02:51:23 2015 +0000
+++ b/api/DynamicResource.cpp	Tue Apr 14 03:02:35 2015 +0000
@@ -35,6 +35,7 @@
 #define START_OBS 0
 #define STOP_OBS  1
 #define DEFAULT_MAXAGE 60
+#define DEFAULT_CONTENT_FORMAT 0
 
 // default constructor
 DynamicResource::DynamicResource(const Logger *logger,const char *name,const char *res_type,uint8_t res_mask,const bool observable) : Resource<string>(logger,string(name),string(""))
@@ -47,7 +48,8 @@
     this->m_obs_token_len = 0;
     this->m_data_wrapper = NULL;
     this->m_observer = NULL;
-    this->m_maxage = (uint16_t)DEFAULT_MAXAGE;
+    this->m_maxage = DEFAULT_MAXAGE;
+    this->m_content_format = DEFAULT_CONTENT_FORMAT;
 }
 
 // constructor (input initial value)
@@ -62,6 +64,7 @@
     this->m_data_wrapper = NULL;
     this->m_observer = NULL;
     this->m_maxage = DEFAULT_MAXAGE;
+    this->m_content_format = DEFAULT_CONTENT_FORMAT;
 }
 
 // constructor (strings)
@@ -76,6 +79,7 @@
     this->m_data_wrapper = NULL;
     this->m_observer = NULL;
     this->m_maxage = DEFAULT_MAXAGE;
+    this->m_content_format = DEFAULT_CONTENT_FORMAT;
 }
 
 // copy constructor
@@ -90,6 +94,7 @@
     this->m_data_wrapper = resource.m_data_wrapper;
     this->m_observer = resource.m_observer;
     this->m_maxage = resource.m_maxage;
+    this->m_content_format = resource.m_content_format;
 }
 
 // destructor
@@ -159,6 +164,10 @@
                 coap_res_ptr->payload_ptr = (uint8_t *)value.c_str();
             }
             
+            // CoAP Content-Format
+            coap_res_ptr->content_type_ptr = &this->m_content_format;
+            coap_res_ptr->content_type_len = sizeof(this->m_content_format);
+            
             // max-age cache control
             coap_res_ptr->options_list_ptr = (sn_coap_options_list_s*)nsdl_alloc(sizeof(sn_coap_options_list_s));
             if(!coap_res_ptr->options_list_ptr){
@@ -221,6 +230,7 @@
             sn_nsdl_send_coap_message(address,coap_res_ptr);
             nsdl_free(coap_res_ptr->options_list_ptr);
             coap_res_ptr->options_list_ptr = NULL;
+            coap_res_ptr->content_type_ptr = NULL;
             
             //
             // nullify note: