Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IoT_LED_demo ServoTest uWater_Project hackathon ... more
Revision 51:b308658817e5, committed 2015-04-14
- Comitter:
- michaeljkoster
- Date:
- Tue Apr 14 03:02:35 2015 +0000
- Parent:
- 50:1a9e2184945e
- Child:
- 52:822611156e35
- Commit message:
- add support for content-format
Changed in this revision
| api/DynamicResource.cpp | Show annotated file Show diff for this revision Revisions of this file |
| api/DynamicResource.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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:
--- a/api/DynamicResource.h Tue Apr 14 02:51:23 2015 +0000
+++ b/api/DynamicResource.h Tue Apr 14 03:02:35 2015 +0000
@@ -164,6 +164,7 @@
DataWrapper *m_data_wrapper;
void *m_observer;
uint8_t m_maxage;
+ uint8_t m_content_format;
// convenience method to create a string from the NSDL CoAP data buffers...
string coapDataToString(uint8_t *coap_data_ptr,int coap_data_ptr_length);
