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 54:6963bb4d0399, committed 2015-04-14
- Comitter:
- ansond
- Date:
- Tue Apr 14 13:54:41 2015 +0000
- Parent:
- 53:458c2730e086
- Child:
- 55:3915ac238c5d
- Commit message:
- minor cleanups and additions of comments for max_age and content_type in the code
Changed in this revision
| api/DynamicResource.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/api/DynamicResource.cpp Tue Apr 14 13:44:41 2015 +0000
+++ b/api/DynamicResource.cpp Tue Apr 14 13:54:41 2015 +0000
@@ -31,10 +31,14 @@
// Options enablement
#include "Options.h"
-// GET verb can Start/Stop Observations...
+// GET option that can be used to Start/Stop Observations...
#define START_OBS 0
#define STOP_OBS 1
+
+// MaxAge support for each DynamicResource
#define DEFAULT_MAXAGE 60
+
+// ContentFormat defaults for each DynamicResource
#define DEFAULT_CONTENT_FORMAT 0
// default constructor
@@ -165,18 +169,18 @@
}
// CoAP Content-Format
- coap_res_ptr->content_type_ptr = &this->m_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){
- this->logger()->log("Cant alloc option list\r\n");
+ this->logger()->log("Cant alloc options list");
coap_res_ptr->options_list_ptr = NULL;
}
else{
memset(coap_res_ptr->options_list_ptr, 0, sizeof(sn_coap_options_list_s));
- coap_res_ptr->options_list_ptr->max_age_ptr = &this->m_maxage;
+ coap_res_ptr->options_list_ptr->max_age_ptr = &this->m_maxage;
coap_res_ptr->options_list_ptr->max_age_len = sizeof(this->m_maxage);
}
@@ -228,6 +232,8 @@
// build out the response and send...
sn_nsdl_send_coap_message(address,coap_res_ptr);
+
+ // freeing up the options_list_ptr and clearing the content_type pointer
nsdl_free(coap_res_ptr->options_list_ptr);
coap_res_ptr->options_list_ptr = NULL;
coap_res_ptr->content_type_ptr = NULL;
@@ -238,7 +244,7 @@
// because our obs_number (assigned to observe_ptr) is part of this object instance, we dont
// want to have the underlying free() try to free it... to just nullify here
//
- if (coap_res_ptr->options_list_ptr) coap_res_ptr->options_list_ptr->observe_ptr = 0;
+ if (coap_res_ptr->options_list_ptr) coap_res_ptr->options_list_ptr->observe_ptr = 0;
}
else {
this->logger()->log("ERROR: resource(GET) mask is munged (mask: 0x%x)",this->m_res_mask);
