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.
Fork of mbedConnectorInterface by
Revision 2:853f9ecc12df, committed 2015-01-27
- Comitter:
- sam_grove
- Date:
- Tue Jan 27 23:41:34 2015 +0000
- Parent:
- 1:cabdd0350707
- Child:
- 3:11b2f4e58378
- Commit message:
- Use auto-format on code and add markup to render class documentation
Changed in this revision
--- a/api/DynamicResource.cpp Tue Jan 27 22:52:25 2015 +0000
+++ b/api/DynamicResource.cpp Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint Dynamic Resource class
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,46 +19,52 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #include "DynamicResource.h"
-
- // InstancePointerTable Helper
- #include "InstancePointerTableHelper.h"
-
- // 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("")) {
+
+#include "DynamicResource.h"
+
+// InstancePointerTable Helper
+#include "InstancePointerTableHelper.h"
+
+// 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(""))
+{
this->m_res_type = string(res_type);
this->m_observable = observable;
- this->m_res_mask = res_mask;
- }
-
- // constructor (input initial value)
- DynamicResource::DynamicResource(const Logger *logger,const char *name,const char *res_type,const string value,uint8_t res_mask,const bool observable) : Resource<string>(logger,string(name),value) {
+ this->m_res_mask = res_mask;
+}
+
+// constructor (input initial value)
+DynamicResource::DynamicResource(const Logger *logger,const char *name,const char *res_type,const string value,uint8_t res_mask,const bool observable) : Resource<string>(logger,string(name),value)
+{
this->m_res_type = string(res_type);
this->m_observable = observable;
- this->m_res_mask = res_mask;
- }
-
- // constructor (strings)
- DynamicResource::DynamicResource(const Logger *logger,const string name,const string res_type,const string value,uint8_t res_mask,const bool observable) : Resource<string>(logger,name,value) {
+ this->m_res_mask = res_mask;
+}
+
+// constructor (strings)
+DynamicResource::DynamicResource(const Logger *logger,const string name,const string res_type,const string value,uint8_t res_mask,const bool observable) : Resource<string>(logger,name,value)
+{
this->m_res_type = res_type;
this->m_observable = observable;
- this->m_res_mask = res_mask;
- }
-
- // copy constructor
- DynamicResource::DynamicResource(const DynamicResource &resource) : Resource<string>((const Resource<string> &)resource) {
+ this->m_res_mask = res_mask;
+}
+
+// copy constructor
+DynamicResource::DynamicResource(const DynamicResource &resource) : Resource<string>((const Resource<string> &)resource)
+{
this->m_res_type = resource.m_res_type;
this->m_observable = resource.m_observable;
this->m_res_mask = resource.m_res_mask;
- }
-
- // destructor
- DynamicResource::~DynamicResource() {
- }
-
- // bind resource to NSDL
- void DynamicResource::bind(void *p) {
+}
+
+// destructor
+DynamicResource::~DynamicResource()
+{
+}
+
+// bind resource to NSDL
+void DynamicResource::bind(void *p)
+{
if (p != NULL) {
sn_nsdl_resource_info_s *resource_ptr = (sn_nsdl_resource_info_s *)p;
std::printf("DynamicResource: name[%s] type:[%s] mask: 0x%.2x\r\n",this->getName().c_str(),this->m_res_type.c_str(),this->m_res_mask);
@@ -66,78 +72,72 @@
const uint8_t *res_type = (const uint8_t *)this->m_res_type.c_str();
int name_length = this->getName().size();
int res_type_length = this->m_res_type.size();
- int is_observable = 0; if (this->m_observable == true) is_observable = 1;
+ int is_observable = 0;
+ if (this->m_observable == true) is_observable = 1;
const string *key = new string(this->getName());
ipt_helper_add_instance_pointer(key,this);
nsdl_create_dynamic_resource(resource_ptr,name_length,(uint8_t *)name,res_type_length,(uint8_t *)res_type,is_observable,&ipt_helper_nsdl_callback_stub,this->m_res_mask);
std::printf("DynamicResource[%s(%d)] type: %s(%d) bound mask: 0x%.2x\r\n",name,name_length,res_type,res_type_length,this->m_res_mask);
- }
- else {
+ } else {
std::printf("DynamicResource: NULL parameter in bind()\r\n");
}
- }
+}
- // process NSDL message
- uint8_t DynamicResource::process(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s *proto) {
+// process NSDL message
+uint8_t DynamicResource::process(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s *proto)
+{
sn_coap_hdr_s *coap_res_ptr = 0;
-
+
// create our key for debugging output...
string key = this->coapDataToString(received_coap_ptr->uri_path_ptr,received_coap_ptr->uri_path_len);
-
- if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET)
- {
+
+ if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET) {
std::printf("GET requested for [%s]...\r\n",key.c_str());
coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
-
- // process the GET if we have registered a callback for it...
+
+ // process the GET if we have registered a callback for it...
if ((this->m_res_mask&SN_GRS_GET_ALLOWED) != 0) {
// call the resource get() to get the resource value
std::printf("Calling resource(GET) for [%s]...\r\n",key.c_str());
string value = this->get();
-
- // convert the string from the GET to something suitable for CoAP payloads
- std::printf("Building payload for [%s]=[%s]...\r\n",key.c_str(),value.c_str());
+
+ // convert the string from the GET to something suitable for CoAP payloads
+ std::printf("Building payload for [%s]=[%s]...\r\n",key.c_str(),value.c_str());
int length = value.size();
char value_buffer[MAX_VALUE_BUFFER_LENGTH+1];
if (length > MAX_VALUE_BUFFER_LENGTH) length = MAX_VALUE_BUFFER_LENGTH;
memset(value_buffer,0,MAX_VALUE_BUFFER_LENGTH+1);
- memcpy(value_buffer,value.c_str(),length);
-
- // fill in the CoAP response payload
+ memcpy(value_buffer,value.c_str(),length);
+
+ // fill in the CoAP response payload
coap_res_ptr->payload_len = length;
coap_res_ptr->payload_ptr = (uint8_t *)value_buffer;
-
- // build out the response and send...
+
+ // build out the response and send...
sn_nsdl_send_coap_message(address, coap_res_ptr);
- }
- else {
+ } else {
std::printf("ERROR: resource(GET) mask is munged (mask: 0x%x)\r\n",this->m_res_mask);
}
- }
- else if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_PUT)
- {
+ } else if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_PUT) {
std::printf("PUT requested for [%s]...\r\n",key.c_str());
- if(received_coap_ptr->payload_len > 0)
- {
+ if(received_coap_ptr->payload_len > 0) {
// process the PUT if we have registered a callback for it...
if ((this->m_res_mask&SN_GRS_PUT_ALLOWED) != 0) {
// binder interacts only with strings
string value = this->coapDataToString(received_coap_ptr->payload_ptr,received_coap_ptr->payload_len);
-
+
// call the resource put() to set the resource value
std::printf("Calling resource(PUT) with [%s]=[%s]...\r\n",key.c_str(),value.c_str());
this->put(value);
-
+
// build out the response and send...
std::printf("resource(PUT) completed for [%s]...\r\n",key.c_str());
coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CHANGED);
sn_nsdl_send_coap_message(address, coap_res_ptr);
- }
- else {
+ } else {
std::printf("ERROR: resource(PUT) mask is munged (mask: 0x%x)\r\n",this->m_res_mask);
}
- }
- else {
+ } else {
std::printf("ERROR: Binder(PUT) payload is NULL...\r\n");
}
}
@@ -145,16 +145,18 @@
sn_coap_parser_release_allocated_coap_msg_mem(coap_res_ptr);
return 0;
- }
-
- // default PUT (does nothing)
- void DynamicResource::put(const string value) {
- // not used by default
- ;
- }
-
- // convenience method to get the URI from its buffer field...
- string DynamicResource::coapDataToString(uint8_t *coap_data_ptr,int coap_data_ptr_length) {
+}
+
+// default PUT (does nothing)
+void DynamicResource::put(const string value)
+{
+ // not used by default
+ ;
+}
+
+// convenience method to get the URI from its buffer field...
+string DynamicResource::coapDataToString(uint8_t *coap_data_ptr,int coap_data_ptr_length)
+{
if (coap_data_ptr != NULL && coap_data_ptr_length > 0) {
char buf[MAX_VALUE_BUFFER_LENGTH+1];
memset(buf,0,MAX_VALUE_BUFFER_LENGTH+1);
@@ -162,4 +164,4 @@
return string(buf);
}
return string("");
- }
\ No newline at end of file
+}
--- a/api/DynamicResource.h Tue Jan 27 22:52:25 2015 +0000
+++ b/api/DynamicResource.h Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint Dynamic Resource class
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,98 +19,101 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #ifndef __DYNAMIC_RESOURCE_H__
- #define __DYNAMIC_RESOURCE_H__
-
- // Base Class
- #include "Resource.h"
-
- // NSDL Support
- #include "nsdl_support.h"
-
- class DynamicResource : public Resource<string> {
- public:
- /**
- Default constructor (char strings)
- @param logger input logger instance for this resource
- @param name input the Resource URI/Name
- @param res_type input type for the Resource
- @param res_mask input the resource enablement mask (GET, PUT, etc...)
- @param observable input the resource is Observable (default: FALSE)
- */
- DynamicResource(const Logger *logger,const char *name,const char *res_type,uint8_t res_mask,const bool observable = false);
-
- /**
- Default constructor (char strings)
- @param logger input logger instance for this resource
- @param name input the Resource URI/Name
- @param res_type input type for the Resource
- @param value input initial value for the Resource
- @param res_mask input the resource enablement mask (GET, PUT, etc...)
- @param observable input the resource is Observable (default: FALSE)
- */
- DynamicResource(const Logger *logger,const char *name,const char *res_type,const string value,uint8_t res_mask,const bool observable = false);
+
+#ifndef __DYNAMIC_RESOURCE_H__
+#define __DYNAMIC_RESOURCE_H__
+
+// Base Class
+#include "Resource.h"
+
+// NSDL Support
+#include "nsdl_support.h"
+
+/** DynamicResource class
+ */
+class DynamicResource : public Resource<string>
+{
+public:
+ /**
+ Default constructor (char strings)
+ @param logger input logger instance for this resource
+ @param name input the Resource URI/Name
+ @param res_type input type for the Resource
+ @param res_mask input the resource enablement mask (GET, PUT, etc...)
+ @param observable input the resource is Observable (default: FALSE)
+ */
+ DynamicResource(const Logger *logger,const char *name,const char *res_type,uint8_t res_mask,const bool observable = false);
+
+ /**
+ Default constructor (char strings)
+ @param logger input logger instance for this resource
+ @param name input the Resource URI/Name
+ @param res_type input type for the Resource
+ @param value input initial value for the Resource
+ @param res_mask input the resource enablement mask (GET, PUT, etc...)
+ @param observable input the resource is Observable (default: FALSE)
+ */
+ DynamicResource(const Logger *logger,const char *name,const char *res_type,const string value,uint8_t res_mask,const bool observable = false);
+
+ /**
+ constructor with string buffer for name
+ @param logger input logger instance for this resource
+ @param name input the Resource URI/Name
+ @param res_type input type for the Resource
+ @param value input initial value for the Resource
+ @param res_mask input the resource enablement mask (GET, PUT, etc...)
+ @param observable input the resource is Observable (default: FALSE)
+ */
+ DynamicResource(const Logger *logger,const string name,const string res_type,const string value,uint8_t res_mask,const bool observable = false);
- /**
- constructor with string buffer for name
- @param logger input logger instance for this resource
- @param name input the Resource URI/Name
- @param res_type input type for the Resource
- @param value input initial value for the Resource
- @param res_mask input the resource enablement mask (GET, PUT, etc...)
- @param observable input the resource is Observable (default: FALSE)
- */
- DynamicResource(const Logger *logger,const string name,const string res_type,const string value,uint8_t res_mask,const bool observable = false);
-
- /**
- Copy constructor
- @param resource input the DynamicResource that is to be deep copied
- */
- DynamicResource(const DynamicResource &resource);
-
- /**
- Destructor
- */
- virtual ~DynamicResource();
-
- /**
- Bind resource to endpoint
- @param p input pointer to the endpoint resources necessary for binding
- */
- virtual void bind(void *p);
-
- /**
- Process the CoAP message
- @param received_coap_ptr input the received coap pointer
- @param address input the NSDL address pointer
- @param proto input the NSDL protocol pointer
- @return 0 - success, 1 - failure
- */
- uint8_t process(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s *proto);
-
- /**
- Resource value getter (REQUIRED: must be implemented in derived class as all Binders MUST support and implement GET)
- @returns string value of the resource
- */
- virtual string get() = 0;
-
- /**
- Resource value setter (OPTIONAL: defaulted noop if not derived. Binders MAY implement PUT if needed)
- @param string value of the resource
- */
- virtual void put(const string value);
-
- protected:
-
- private:
-
- string m_res_type;
- uint8_t m_res_mask;
- bool m_observable;
-
- // convenience method to create a string from the NSDL CoAP data buffers...
- string coapDataToString(uint8_t *coap_data_ptr,int coap_data_ptr_length);
- };
-
- #endif // __DYNAMIC_RESOURCE_H__
\ No newline at end of file
+ /**
+ Copy constructor
+ @param resource input the DynamicResource that is to be deep copied
+ */
+ DynamicResource(const DynamicResource &resource);
+
+ /**
+ Destructor
+ */
+ virtual ~DynamicResource();
+
+ /**
+ Bind resource to endpoint
+ @param p input pointer to the endpoint resources necessary for binding
+ */
+ virtual void bind(void *p);
+
+ /**
+ Process the CoAP message
+ @param received_coap_ptr input the received coap pointer
+ @param address input the NSDL address pointer
+ @param proto input the NSDL protocol pointer
+ @return 0 - success, 1 - failure
+ */
+ uint8_t process(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s *proto);
+
+ /**
+ Resource value getter (REQUIRED: must be implemented in derived class as all Binders MUST support and implement GET)
+ @returns string value of the resource
+ */
+ virtual string get() = 0;
+
+ /**
+ Resource value setter (OPTIONAL: defaulted noop if not derived. Binders MAY implement PUT if needed)
+ @param string value of the resource
+ */
+ virtual void put(const string value);
+
+protected:
+
+private:
+
+ string m_res_type;
+ uint8_t m_res_mask;
+ bool m_observable;
+
+ // convenience method to create a string from the NSDL CoAP data buffers...
+ string coapDataToString(uint8_t *coap_data_ptr,int coap_data_ptr_length);
+};
+
+#endif // __DYNAMIC_RESOURCE_H__
--- a/api/Endpoint.cpp Tue Jan 27 22:52:25 2015 +0000
+++ b/api/Endpoint.cpp Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint base class
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,96 +19,105 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #include "Endpoint.h"
-
- // support for temporary mbedEndpointLib calls...
- #include "mbedEndpointLib.h"
-
- // Connector namespace
- namespace Connector {
- // Constructor
- Endpoint::Endpoint(const Logger *logger, const Options *options) {
- this->m_logger = (Logger *)logger;
- this->m_options = (Options *)options;
- }
-
- // Copy Constructor
- Endpoint::Endpoint(const Endpoint &ep) {
- this->m_logger = ep.m_logger;
- this->m_options = ep.m_options;
- }
-
- // Destructor
- Endpoint::~Endpoint() {
- }
-
- // plumb network
- void Endpoint::plumbNetwork(bool canActAsRouterNode) {
- // call into mbedEndpointLib for now...
- init_network(canActAsRouterNode);
- }
-
- // initialize the endpoint
- void Endpoint::initialize() {
- // Create the NSDL Resource Pointer...
- std::printf("Endpoint::initialize(): initializing NSP resource pointer...\r\n");
- sn_nsdl_resource_info_s *resource_ptr = (sn_nsdl_resource_info_s*)nsdl_alloc(sizeof(sn_nsdl_resource_info_s));
- if(!resource_ptr) return;
- memset(resource_ptr, 0, sizeof(sn_nsdl_resource_info_s));
-
- resource_ptr->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)nsdl_alloc(sizeof(sn_nsdl_resource_parameters_s));
- if(!resource_ptr->resource_parameters_ptr) {
- nsdl_free(resource_ptr);
- return;
- }
- memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));
-
- // Loop through Static Resources and bind each of them...
- std::printf("Endpoint::initialize(): adding static resources...\r\n");
- const StaticResourcesList *static_resources = this->m_options->getStaticResourceList();
- for(int i=0;i<static_resources->size();++i) {
- std::printf("Endpoint::initialize(): binding static resource: [%s]...\r\n",static_resources->at(i)->getName().c_str());
- static_resources->at(i)->bind(resource_ptr);
- }
-
- // Loop through Dynamic Resources and bind each of them...
- std::printf("Endpoint::initialize(): adding dynamic resources...\r\n");
- const DynamicResourcesList *dynamic_resources = this->m_options->getDynamicResourceList();
- for(int i=0;i<dynamic_resources->size();++i) {
- std::printf("Endpoint::initialize(): binding dynamic resource: [%s]...\r\n",dynamic_resources->at(i)->getName().c_str());
- dynamic_resources->at(i)->bind(resource_ptr);
- }
-
- // initialize the Network
- this->initNetwork();
-
- // clean up
- nsdl_free(resource_ptr->resource_parameters_ptr);
+
+#include "Endpoint.h"
+
+// support for temporary mbedEndpointLib calls...
+#include "mbedEndpointLib.h"
+
+// Connector namespace
+namespace Connector {
+
+// Constructor
+Endpoint::Endpoint(const Logger *logger, const Options *options)
+{
+ this->m_logger = (Logger *)logger;
+ this->m_options = (Options *)options;
+}
+
+// Copy Constructor
+Endpoint::Endpoint(const Endpoint &ep)
+{
+ this->m_logger = ep.m_logger;
+ this->m_options = ep.m_options;
+}
+
+// Destructor
+Endpoint::~Endpoint()
+{
+}
+
+// plumb network
+void Endpoint::plumbNetwork(bool canActAsRouterNode)
+{
+ // call into mbedEndpointLib for now...
+ init_network(canActAsRouterNode);
+}
+
+// initialize the endpoint
+void Endpoint::initialize()
+{
+ // Create the NSDL Resource Pointer...
+ std::printf("Endpoint::initialize(): initializing NSP resource pointer...\r\n");
+ sn_nsdl_resource_info_s *resource_ptr = (sn_nsdl_resource_info_s*)nsdl_alloc(sizeof(sn_nsdl_resource_info_s));
+ if(!resource_ptr) return;
+ memset(resource_ptr, 0, sizeof(sn_nsdl_resource_info_s));
+
+ resource_ptr->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)nsdl_alloc(sizeof(sn_nsdl_resource_parameters_s));
+ if(!resource_ptr->resource_parameters_ptr) {
nsdl_free(resource_ptr);
- }
-
- // initialize the NSDL Network
- void Endpoint::initNetwork() {
- // register with NSP
- DBG("Calling NSP_registration()...\r\n");
- NSP_registration();
- DBG("NSP_registration() completed\r\n");
- }
-
- // Finalize the endpoint's configuration and begin the endpoint's main even loop
- void Endpoint::start() {
- // mbedEndpointLib tasklet creation...
- int main_tasklet_id = arm_ns_tasklet_create(&tasklet_main);
- if(main_tasklet_id < 0) {
- //Tasklet cerate fail
- DBG("startTasklet: Tasklet creation failed...\r\n");
- return;
- }
-
- // mbedEndpointLib event dispatching
- DBG("startTasklet: Beginning event dispatch...\r\n");
- event_dispatch();
return;
}
-}
\ No newline at end of file
+ memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));
+
+ // Loop through Static Resources and bind each of them...
+ std::printf("Endpoint::initialize(): adding static resources...\r\n");
+ const StaticResourcesList *static_resources = this->m_options->getStaticResourceList();
+ for(int i=0; i<static_resources->size(); ++i) {
+ std::printf("Endpoint::initialize(): binding static resource: [%s]...\r\n",static_resources->at(i)->getName().c_str());
+ static_resources->at(i)->bind(resource_ptr);
+ }
+
+ // Loop through Dynamic Resources and bind each of them...
+ std::printf("Endpoint::initialize(): adding dynamic resources...\r\n");
+ const DynamicResourcesList *dynamic_resources = this->m_options->getDynamicResourceList();
+ for(int i=0; i<dynamic_resources->size(); ++i) {
+ std::printf("Endpoint::initialize(): binding dynamic resource: [%s]...\r\n",dynamic_resources->at(i)->getName().c_str());
+ dynamic_resources->at(i)->bind(resource_ptr);
+ }
+
+ // initialize the Network
+ this->initNetwork();
+
+ // clean up
+ nsdl_free(resource_ptr->resource_parameters_ptr);
+ nsdl_free(resource_ptr);
+}
+
+// initialize the NSDL Network
+void Endpoint::initNetwork()
+{
+ // register with NSP
+ DBG("Calling NSP_registration()...\r\n");
+ NSP_registration();
+ DBG("NSP_registration() completed\r\n");
+}
+
+// Finalize the endpoint's configuration and begin the endpoint's main even loop
+void Endpoint::start()
+{
+ // mbedEndpointLib tasklet creation...
+ int main_tasklet_id = arm_ns_tasklet_create(&tasklet_main);
+ if(main_tasklet_id < 0) {
+ //Tasklet cerate fail
+ DBG("startTasklet: Tasklet creation failed...\r\n");
+ return;
+ }
+
+ // mbedEndpointLib event dispatching
+ DBG("startTasklet: Beginning event dispatch...\r\n");
+ event_dispatch();
+ return;
+}
+
+} // namespace Connector
--- a/api/Endpoint.h Tue Jan 27 22:52:25 2015 +0000
+++ b/api/Endpoint.h Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint base class
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,66 +19,70 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #ifndef __ENDPOINT_H__
- #define __ENDPOINT_H__
-
- // Support for Logging/Debug output
- #include "Logger.h"
-
- // Options support
- #include "Options.h"
-
- // Connector namespace
- namespace Connector {
-
- class Endpoint {
-
- public:
- /**
- Default Constructor
- */
- Endpoint(const Logger *logger,const Options *ob);
-
- /**
- Copy Constructor
- @param ob input endpoint instance to deep copy
- */
- Endpoint(const Endpoint &ep);
-
- /**
- Destructor
- */
- virtual ~Endpoint();
-
- /**
- Plumb the underlying network
- @param canActAsRouterNode input boolean indicating whether this node can act as a router node or not.
- */
- static void plumbNetwork(bool canActAsRouterNode = false);
-
- /**
- Initialize the endpoint
- */
- void initialize();
-
- /**
- Finalize the endpoint's configuration and begin the endpoint's main even loop
- */
- static void start();
-
- protected:
-
- private:
- Logger *m_logger;
- Options *m_options;
-
- // initialize the NSDL network
- void initNetwork();
-
- // access the logger
- Logger *logger();
- };
- }
-
- #endif // __ENDPOINT_H__
\ No newline at end of file
+
+#ifndef __ENDPOINT_H__
+#define __ENDPOINT_H__
+
+// Support for Logging/Debug output
+#include "Logger.h"
+
+// Options support
+#include "Options.h"
+
+// Connector namespace
+namespace Connector {
+
+/** Endpoint class
+ */
+class Endpoint
+{
+
+public:
+ /**
+ Default Constructor
+ */
+ Endpoint(const Logger *logger,const Options *ob);
+
+ /**
+ Copy Constructor
+ @param ob input endpoint instance to deep copy
+ */
+ Endpoint(const Endpoint &ep);
+
+ /**
+ Destructor
+ */
+ virtual ~Endpoint();
+
+ /**
+ Plumb the underlying network
+ @param canActAsRouterNode input boolean indicating whether this node can act as a router node or not.
+ */
+ static void plumbNetwork(bool canActAsRouterNode = false);
+
+ /**
+ Initialize the endpoint
+ */
+ void initialize();
+
+ /**
+ Finalize the endpoint's configuration and begin the endpoint's main even loop
+ */
+ static void start();
+
+protected:
+
+private:
+ Logger *m_logger;
+ Options *m_options;
+
+ // initialize the NSDL network
+ void initNetwork();
+
+ // access the logger
+ Logger *logger();
+};
+
+} // namespace Connector
+
+#endif // __ENDPOINT_H__
--- a/api/InstancePointerTable.cpp Tue Jan 27 22:52:25 2015 +0000
+++ b/api/InstancePointerTable.cpp Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief instance pointer table header
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,45 +19,47 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #include "InstancePointerTable.h"
-
- // constructor
- InstancePointerTable::InstancePointerTable(const Logger *logger) {
- this->m_logger = (Logger *)logger;
- }
-
- // destructor
- InstancePointerTable::~InstancePointerTable() {
- }
-
- // add to the table
- void InstancePointerTable::add(string key,void *instance) {
- // get our index
- int index = this->indexFromKey(key);
- if (index >= 0) {
- // overwrite the existing reference we have...
- std::printf("InstancePointerTable: ADD(overwrite) instance: key[%s] index=%d\r\n",key.c_str(),index);
- this->m_instance_pointer_table[index].instance = instance;
- }
- else {
+
+#include "InstancePointerTable.h"
+
+// constructor
+InstancePointerTable::InstancePointerTable(const Logger *logger)
+{
+ this->m_logger = (Logger *)logger;
+}
+
+// destructor
+InstancePointerTable::~InstancePointerTable()
+{
+}
+
+// add to the table
+void InstancePointerTable::add(string key,void *instance)
+{
+ // get our index
+ int index = this->indexFromKey(key);
+ if (index >= 0) {
+ // overwrite the existing reference we have...
+ std::printf("InstancePointerTable: ADD(overwrite) instance: key[%s] index=%d\r\n",key.c_str(),index);
+ this->m_instance_pointer_table[index].instance = instance;
+ } else {
// get the next empty slot
index = this->nextEmptySlot();
- if (index >= 0) {
+ if (index >= 0) {
// set the table entry
this->m_instance_pointer_table[index].key = key;
this->m_instance_pointer_table[index].instance = instance;
std::printf("InstancePointerTable: ADD instance: key[%s] index=%d\r\n",key.c_str(),index);
- }
- else {
+ } else {
// table is FULL! Error...
std::printf("ERROR: InstancePointerTable is FULL... please expand table\r\n");
}
}
- }
-
- // get from the table
- void *InstancePointerTable::get(string key) {
+}
+
+// get from the table
+void *InstancePointerTable::get(string key)
+{
// get our index
int index = this->indexFromKey(key);
if (index >= 0) {
@@ -65,36 +67,47 @@
return this->m_instance_pointer_table[index].instance;
}
return NULL;
- }
-
- // find next empty slot
- int InstancePointerTable::nextEmptySlot() { return this->indexFromKey(""); }
-
- // lookup into the table
- int InstancePointerTable::indexFromKey(string key) {
- int index = -1;
- bool found = false;
-
- for(int i=0;i<IPT_MAX_ENTRIES && !found;++i) {
+}
+
+// find next empty slot
+int InstancePointerTable::nextEmptySlot()
+{
+ return this->indexFromKey("");
+}
+
+// lookup into the table
+int InstancePointerTable::indexFromKey(string key)
+{
+ int index = -1;
+ bool found = false;
+
+ for(int i=0; i<IPT_MAX_ENTRIES && !found; ++i) {
if (this->m_instance_pointer_table[i].key.compare(key) == 0) {
found = true;
index = i;
}
- }
-
- return index;
- }
-
- // initialize
- void InstancePointerTable::init() {
- for(int i=0;i<IPT_MAX_ENTRIES;++i) {
- this->m_instance_pointer_table[i].key = "";
- this->m_instance_pointer_table[i].instance = NULL;
- }
- }
-
- // set our logger
- void InstancePointerTable::setLogger(const Logger *logger) { this->m_logger = (Logger *)logger; }
-
- // get our logger
- Logger *InstancePointerTable::logger() { return this->m_logger; }
\ No newline at end of file
+ }
+
+ return index;
+}
+
+// initialize
+void InstancePointerTable::init()
+{
+ for(int i=0; i<IPT_MAX_ENTRIES; ++i) {
+ this->m_instance_pointer_table[i].key = "";
+ this->m_instance_pointer_table[i].instance = NULL;
+ }
+}
+
+// set our logger
+void InstancePointerTable::setLogger(const Logger *logger)
+{
+ this->m_logger = (Logger *)logger;
+}
+
+// get our logger
+Logger *InstancePointerTable::logger()
+{
+ return this->m_logger;
+}
--- a/api/InstancePointerTable.h Tue Jan 27 22:52:25 2015 +0000
+++ b/api/InstancePointerTable.h Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief instance pointer table header
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,73 +19,76 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #ifndef __INSTANCE_POINTER_TABLE_H__
- #define __INSTANCE_POINTER_TABLE_H__
-
- // Logger support
- #include "Logger.h"
-
- // string support
- #include <string>
-
- // Configuration
- #include "mbedConnectorInterface.h"
-
- // our table row structure
- typedef struct {
- string key;
- void *instance;
- } InstancePointerTableRow;
-
- class InstancePointerTable {
- public:
- /**
- Default constructor
- @param logger input the logger instance
- */
- InstancePointerTable(const Logger *logger = NULL);
-
- /**
- Destructor
- */
- virtual ~InstancePointerTable();
-
- /**
- Add pointer to the instance table
- @param key input the key for the new pointer
- @param instance input the instance pointer to save
- */
- void add(string key,void *instance);
-
- /**
- Get a instance pointer index by the name of the key
- @param key input the key to use for the lookup
- @returns the instance pointer if found or NULL if not found
- */
- void *get(string key);
-
- /**
- Set the Logger instance
- @param logger input the logger instance
- */
- void setLogger(const Logger *logger);
-
- private:
- Logger *m_logger;
- InstancePointerTableRow m_instance_pointer_table[IPT_MAX_ENTRIES];
-
- // initialize our table
- void init();
-
- // get the next empty slot
- int nextEmptySlot();
-
- // index from key
- int indexFromKey(string key);
-
- // get our logger
- Logger *logger();
- };
-
- #endif // __INSTANCE_POINTER_TABLE_H__
\ No newline at end of file
+
+#ifndef __INSTANCE_POINTER_TABLE_H__
+#define __INSTANCE_POINTER_TABLE_H__
+
+// Logger support
+#include "Logger.h"
+
+// string support
+#include <string>
+
+// Configuration
+#include "mbedConnectorInterface.h"
+
+// our table row structure
+typedef struct {
+ string key;
+ void *instance;
+} InstancePointerTableRow;
+
+/** InstancePointerTable class
+ */
+class InstancePointerTable
+{
+public:
+ /**
+ Default constructor
+ @param logger input the logger instance
+ */
+ InstancePointerTable(const Logger *logger = NULL);
+
+ /**
+ Destructor
+ */
+ virtual ~InstancePointerTable();
+
+ /**
+ Add pointer to the instance table
+ @param key input the key for the new pointer
+ @param instance input the instance pointer to save
+ */
+ void add(string key,void *instance);
+
+ /**
+ Get a instance pointer index by the name of the key
+ @param key input the key to use for the lookup
+ @returns the instance pointer if found or NULL if not found
+ */
+ void *get(string key);
+
+ /**
+ Set the Logger instance
+ @param logger input the logger instance
+ */
+ void setLogger(const Logger *logger);
+
+private:
+ Logger *m_logger;
+ InstancePointerTableRow m_instance_pointer_table[IPT_MAX_ENTRIES];
+
+ // initialize our table
+ void init();
+
+ // get the next empty slot
+ int nextEmptySlot();
+
+ // index from key
+ int indexFromKey(string key);
+
+ // get our logger
+ Logger *logger();
+};
+
+#endif // __INSTANCE_POINTER_TABLE_H__
--- a/api/InstancePointerTableHelper.h Tue Jan 27 22:52:25 2015 +0000
+++ b/api/InstancePointerTableHelper.h Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief instance pointer table helper functions for DynamicResource
* @author Doug Anson
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,49 +19,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #ifndef __INSTANCE_POINTER_TABLE_HELPER_H__
- #define __INSTANCE_POINTER_TABLE_HELPER_H__
+
+#ifndef __INSTANCE_POINTER_TABLE_HELPER_H__
+#define __INSTANCE_POINTER_TABLE_HELPER_H__
-// InstancePointerTable
- #include "InstancePointerTable.h"
- extern Logger logger;
- InstancePointerTable __nsdl_lookup_table(&logger); // Instance Pointer Table
-
-
- // lookup a DynamicResource instance indexed by our resource URI as the key
- extern "C" DynamicResource *__lookup_instance_pointer(const char *uri,const int uri_length) {
+// InstancePointerTable
+#include "InstancePointerTable.h"
+extern Logger logger;
+InstancePointerTable __nsdl_lookup_table(&logger); // Instance Pointer Table
+
+
+// lookup a DynamicResource instance indexed by our resource URI as the key
+extern "C" DynamicResource *__lookup_instance_pointer(const char *uri,const int uri_length)
+{
if (uri != NULL && uri_length > 0) {
string key(uri,uri_length);
return (DynamicResource *)__nsdl_lookup_table.get(key);
}
return NULL;
- }
-
- // callback function for NSDL library to call into... ASSUMPTION: 1 and only 1 DynamicResource<> instance per Resource URI...
- extern "C" uint8_t ipt_helper_nsdl_callback_stub(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto) {
+}
+
+// callback function for NSDL library to call into... ASSUMPTION: 1 and only 1 DynamicResource<> instance per Resource URI...
+extern "C" uint8_t ipt_helper_nsdl_callback_stub(sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s * proto)
+{
uint8_t status = 1;
- if (received_coap_ptr != NULL) {
+ if (received_coap_ptr != NULL) {
// retrieve our resource instance via lookup/index by our resource URI
DynamicResource *instance = __lookup_instance_pointer((const char *)received_coap_ptr->uri_path_ptr,received_coap_ptr->uri_path_len);
if (instance != NULL) {
std::printf("Instance retrieved.. processing callback...\r\n");
status = instance->process(received_coap_ptr,address,proto);
- }
- else {
+ } else {
std::printf("Unable to process callback: unable to lookup DynamicResource<> instance pointer... ignorning...\r\n");
}
- }
- else {
+ } else {
std::printf("Unable to process callback: received coap pointer is NULL... ignoring...\r\n");
}
return status;
- }
-
- // add a instance pointer to our lookup table keyed by the key
- extern "C" void ipt_helper_add_instance_pointer(const string *key,DynamicResource *instance) {
- __nsdl_lookup_table.add(*key,instance);
- if (key != NULL) delete key;
- }
-
- #endif // __INSTANCE_POINTER_TABLE_HELPER_H__
\ No newline at end of file
+}
+
+// add a instance pointer to our lookup table keyed by the key
+extern "C" void ipt_helper_add_instance_pointer(const string *key,DynamicResource *instance)
+{
+ __nsdl_lookup_table.add(*key,instance);
+ if (key != NULL) delete key;
+}
+
+#endif // __INSTANCE_POINTER_TABLE_HELPER_H__
--- a/api/Logger.cpp Tue Jan 27 22:52:25 2015 +0000
+++ b/api/Logger.cpp Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint logging class
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,25 +19,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #include "Logger.h"
-
- // Constructor
- Logger::Logger(const BufferedSerial *pc) {
- this->m_pc = (BufferedSerial *)pc;
- }
-
- // Copy Constructor
- Logger::Logger(const Logger &logger) {
- this->m_pc = logger.m_pc;
- }
-
- // Destructor
- Logger::~Logger() {
- }
-
- // Log output
- void Logger::log(const char *format,...) {
+
+#include "Logger.h"
+
+// Constructor
+Logger::Logger(const BufferedSerial *pc)
+{
+ this->m_pc = (BufferedSerial *)pc;
+}
+
+// Copy Constructor
+Logger::Logger(const Logger &logger)
+{
+ this->m_pc = logger.m_pc;
+}
+
+// Destructor
+Logger::~Logger()
+{
+}
+
+// Log output
+void Logger::log(const char *format,...)
+{
va_list args;
va_start(args,format);
if (this->m_pc != NULL) {
@@ -45,10 +49,9 @@
//this->m_pc->printf("\r\n");
std::printf(format,args);
std::printf("\r\n");
- }
- else {
+ } else {
std::printf(format,args);
std::printf("\r\n");
}
va_end(args);
- }
\ No newline at end of file
+}
--- a/api/Logger.h Tue Jan 27 22:52:25 2015 +0000
+++ b/api/Logger.h Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint logging class
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,48 +19,51 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #ifndef __LOGGER_H__
- #define __LOGGER_H__
-
- // mbed API
- #include "mbed.h"
-
- // Support for std args
- #include <stdarg.h>
+
+#ifndef __LOGGER_H__
+#define __LOGGER_H__
+
+// mbed API
+#include "mbed.h"
+
+// Support for std args
+#include <stdarg.h>
+
+// Depends on use of BufferedSerial
+#include "BufferedSerial.h"
+
+/** Logger class
+ */
+class Logger
+{
+public:
+ /**
+ Default constructor
+ @param pc input BufferedSerial instance for debugging (if NULL, no debugging output will occur in the library)
+ */
+ Logger(const BufferedSerial *pc);
- // Depends on use of BufferedSerial
- #include "BufferedSerial.h"
-
- class Logger {
- public:
- /**
- Default constructor
- @param pc input BufferedSerial instance for debugging (if NULL, no debugging output will occur in the library)
- */
- Logger(const BufferedSerial *pc);
-
- /**
- Copy constructor
- @param logger input Logger instance to deep copy
- */
- Logger(const Logger &logger);
-
- /**
- Destructor
- */
- virtual ~Logger();
-
- /**
- Log output
- @param format input format for the logging
- @param ... input (variable arguments to display)
- */
- void log(const char *format, ...);
- protected:
-
- private:
- BufferedSerial *m_pc;
- };
-
- #endif // __LOGGER_H__
\ No newline at end of file
+ /**
+ Copy constructor
+ @param logger input Logger instance to deep copy
+ */
+ Logger(const Logger &logger);
+
+ /**
+ Destructor
+ */
+ virtual ~Logger();
+
+ /**
+ Log output
+ @param format input format for the logging
+ @param ... input (variable arguments to display)
+ */
+ void log(const char *format, ...);
+protected:
+
+private:
+ BufferedSerial *m_pc;
+};
+
+#endif // __LOGGER_H__
--- a/api/Options.cpp Tue Jan 27 22:52:25 2015 +0000
+++ b/api/Options.cpp Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Options (immutable OptionsBuilder instance) class implementation
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,52 +19,90 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #include "Options.h"
-
- namespace Connector {
- // default constructor
- Options::Options() {
- }
-
- // copy constructor
- Options::Options(const Options &opt) {
- }
-
- // destructors
- Options::~Options() {
- }
-
- // lifetime pointer
- char *Options::getLifetime() { return this->m_lifetime; }
-
- // NSP domain
- string Options::getDomain() { return this->m_domain; }
-
- // Endpoint name
- string Options::getEndpointNodename() { return this->m_node_name; }
-
- // Endpoint Type
- string Options::getEndpointType() { return this->m_endpoint_type; }
-
- // NSP Port number
- int Options::getNSPPortNumber() { return this->m_nsp_port; }
-
- // NODE Radio Channel List
- uint32_t Options::setRadioChannelList() { return this->m_channel_list; }
-
- // NSP Read update period
- int Options::getReadUpdatePeriod() { return this->m_rd_update_period; }
-
- // NSP Address
- uint8_t *Options::getNSPAddress() { return this->m_nsp_address; }
-
- // NODE MAC Address
- uint8_t *Options::setMACAddress() { return this->m_mac_address; }
-
- // Static Resources
- StaticResourcesList *Options::getStaticResourceList() { return &this->m_static_resources; }
-
- // Dynamic Resources
- DynamicResourcesList *Options::getDynamicResourceList() { return &this->m_dynamic_resources; }
- }
\ No newline at end of file
+
+#include "Options.h"
+
+namespace Connector {
+
+// default constructor
+Options::Options()
+{
+}
+
+// copy constructor
+Options::Options(const Options &opt)
+{
+}
+
+// destructors
+Options::~Options()
+{
+}
+
+// lifetime pointer
+char *Options::getLifetime()
+{
+ return this->m_lifetime;
+}
+
+// NSP domain
+string Options::getDomain()
+{
+ return this->m_domain;
+}
+
+// Endpoint name
+string Options::getEndpointNodename()
+{
+ return this->m_node_name;
+}
+
+// Endpoint Type
+string Options::getEndpointType()
+{
+ return this->m_endpoint_type;
+}
+
+// NSP Port number
+int Options::getNSPPortNumber()
+{
+ return this->m_nsp_port;
+}
+
+// NODE Radio Channel List
+uint32_t Options::setRadioChannelList()
+{
+ return this->m_channel_list;
+}
+
+// NSP Read update period
+int Options::getReadUpdatePeriod()
+{
+ return this->m_rd_update_period;
+}
+
+// NSP Address
+uint8_t *Options::getNSPAddress()
+{
+ return this->m_nsp_address;
+}
+
+// NODE MAC Address
+uint8_t *Options::setMACAddress()
+{
+ return this->m_mac_address;
+}
+
+// Static Resources
+StaticResourcesList *Options::getStaticResourceList()
+{
+ return &this->m_static_resources;
+}
+
+// Dynamic Resources
+DynamicResourcesList *Options::getDynamicResourceList()
+{
+ return &this->m_dynamic_resources;
+}
+
+} // namespace Connector
--- a/api/Options.h Tue Jan 27 22:52:25 2015 +0000
+++ b/api/Options.h Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Options (immutable OptionsBuilder instance) class header
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,112 +19,117 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #ifndef __OPTIONS_H__
- #define __OPTIONS_H__
-
- // Static Resources
- #include "StaticResource.h"
-
- // Dynamic Resources
- #include "DynamicResource.h"
-
- // include the mbed connector resource list
- #include "mbedConnectorInterface.h"
-
- // Vector support
- #include <vector>
-
- // Resources list
- typedef vector<StaticResource *> StaticResourcesList;
- typedef vector<DynamicResource *> DynamicResourcesList;
-
- namespace Connector {
- class Options {
- public:
- /**
- Default constructor
- */
- Options();
-
- /**
- Copy constructor
- */
- Options(const Options &opt);
-
- /**
- Destructor
- */
- virtual ~Options();
-
- /**
- Get the node lifetime
- */
- char *getLifetime();
-
- /**
- Get the NSP domain
- */
- string getDomain();
-
- /**
- Get the node name
- */
- string getEndpointNodename();
-
- /**
- Get the node type
- */
- string getEndpointType();
-
- /**
- Get the NSP port number
- */
- int getNSPPortNumber();
-
- /**
- Get the node radio channel list
- */
- uint32_t setRadioChannelList();
-
- /**
- Get the NSP read update period
- */
- int getReadUpdatePeriod();
-
- /**
- Get the NSP address
- */
- uint8_t *getNSPAddress();
-
- /**
- Get the node MAC address
- */
- uint8_t *setMACAddress();
-
- /**
- Get the list of static resources
- */
- StaticResourcesList *getStaticResourceList();
-
- /**
- Get the list of dynamic resources
- */
- DynamicResourcesList *getDynamicResourceList();
-
- protected:
- char *m_lifetime;
- string m_domain;
- string m_node_name;
- string m_endpoint_type;
- uint32_t m_channel_list;
- int m_rd_update_period;
- int m_nsp_port;
- uint8_t m_nsp_address[NSP_IP_ADDRESS_LENGTH];
- uint8_t m_mac_address[NODE_MAC_ADDRESS_LENGTH];
- StaticResourcesList m_static_resources;
- DynamicResourcesList m_dynamic_resources;
- };
- }
-
- #endif // __OPTIONS_H__
\ No newline at end of file
+
+#ifndef __OPTIONS_H__
+#define __OPTIONS_H__
+
+// Static Resources
+#include "StaticResource.h"
+
+// Dynamic Resources
+#include "DynamicResource.h"
+
+// include the mbed connector resource list
+#include "mbedConnectorInterface.h"
+
+// Vector support
+#include <vector>
+
+// Resources list
+typedef vector<StaticResource *> StaticResourcesList;
+typedef vector<DynamicResource *> DynamicResourcesList;
+
+namespace Connector {
+
+/** Options class
+ */
+class Options
+{
+public:
+ /**
+ Default constructor
+ */
+ Options();
+
+ /**
+ Copy constructor
+ */
+ Options(const Options &opt);
+
+ /**
+ Destructor
+ */
+ virtual ~Options();
+
+ /**
+ Get the node lifetime
+ */
+ char *getLifetime();
+
+ /**
+ Get the NSP domain
+ */
+ string getDomain();
+
+ /**
+ Get the node name
+ */
+ string getEndpointNodename();
+
+ /**
+ Get the node type
+ */
+ string getEndpointType();
+
+ /**
+ Get the NSP port number
+ */
+ int getNSPPortNumber();
+
+ /**
+ Get the node radio channel list
+ */
+ uint32_t setRadioChannelList();
+
+ /**
+ Get the NSP read update period
+ */
+ int getReadUpdatePeriod();
+
+ /**
+ Get the NSP address
+ */
+ uint8_t *getNSPAddress();
+
+ /**
+ Get the node MAC address
+ */
+ uint8_t *setMACAddress();
+
+ /**
+ Get the list of static resources
+ */
+ StaticResourcesList *getStaticResourceList();
+
+ /**
+ Get the list of dynamic resources
+ */
+ DynamicResourcesList *getDynamicResourceList();
+
+protected:
+ char *m_lifetime;
+ string m_domain;
+ string m_node_name;
+ string m_endpoint_type;
+ uint32_t m_channel_list;
+ int m_rd_update_period;
+ int m_nsp_port;
+ uint8_t m_nsp_address[NSP_IP_ADDRESS_LENGTH];
+ uint8_t m_mac_address[NODE_MAC_ADDRESS_LENGTH];
+ StaticResourcesList m_static_resources;
+ DynamicResourcesList m_dynamic_resources;
+};
+
+} // namespace Connector
+
+#endif // __OPTIONS_H__
--- a/api/OptionsBuilder.cpp Tue Jan 27 22:52:25 2015 +0000
+++ b/api/OptionsBuilder.cpp Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP OptionsBuilder class implementation
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,92 +19,138 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #include "OptionsBuilder.h"
-
- // external included configuration file for the endpoint...
- #include "configuration.h"
-
- // Connector namespace
- namespace Connector {
- // Constructor
- OptionsBuilder::OptionsBuilder() {
- this->m_lifetime = NSP_LIFE_TIME;
- this->m_domain = NSP_DOMAIN;
- this->m_endpoint_type = NSP_ENDPOINT_TYPE;
- this->m_node_name = NODE_NAME;
- this->m_channel_list = NODE_CHANNEL_LIST;
- this->m_rd_update_period = NSP_RD_UPDATE_PERIOD;
- this->m_nsp_port = NSP_COAP_UDP_PORT;
-
- memset(this->m_nsp_address,0,NSP_IP_ADDRESS_LENGTH);
- memset(this->m_mac_address,0,NODE_MAC_ADDRESS_LENGTH);
- this->m_static_resources.clear();
- this->m_dynamic_resources.clear();
- }
-
- // Copy Constructor
- OptionsBuilder::OptionsBuilder(const OptionsBuilder &ob) {
- this->m_lifetime = ob.m_lifetime;
- this->m_domain = ob.m_domain;
- this->m_endpoint_type = ob.m_endpoint_type;
- this->m_static_resources = ob.m_static_resources;
- this->m_dynamic_resources = ob.m_dynamic_resources;
- }
-
- // Destructor
- OptionsBuilder::~OptionsBuilder() {
- this->m_static_resources.clear();
- this->m_dynamic_resources.clear();
- }
-
- // set lifetime
- OptionsBuilder &OptionsBuilder::setLifetime(const char *lifetime) { this->m_lifetime = (char *)lifetime; return *this; }
-
- // set domain
- OptionsBuilder &OptionsBuilder::setDomain(const char *domain) { this->m_domain = string(domain); return *this; }
-
- // set endpoint nodename
- OptionsBuilder &OptionsBuilder::setEndpointNodename(const char *node_name) { this->m_node_name = string(node_name); return *this; }
-
- // set lifetime
- OptionsBuilder &OptionsBuilder::setEndpointType(const char *endpoint_type) { this->m_endpoint_type = string(endpoint_type); return *this; }
-
- // set NSP port number
- OptionsBuilder &OptionsBuilder::setNSPPortNumber(const int port_num) { this->m_nsp_port = port_num; return *this; }
-
- // set low level radio channel list
- OptionsBuilder &OptionsBuilder::setRadioChannelList(const uint32_t channel_list) { this->m_channel_list = channel_list; return *this; }
-
- // set NSP read update period
- OptionsBuilder &OptionsBuilder::setReadUpdatePeriod(const int rd_update_period) { this->m_rd_update_period = rd_update_period; return *this; }
-
- // set NSP address
- OptionsBuilder &OptionsBuilder::setNSPAddress(const uint8_t *nsp_address,const int nsp_address_length) {
- if (nsp_address != NULL && nsp_address_length > 0) {
- int length = nsp_address_length;
- if (length > NSP_IP_ADDRESS_LENGTH) length = NSP_IP_ADDRESS_LENGTH;
- for(int i=0;i<length;++i) this->m_nsp_address[i] = nsp_address[i];
- }
- return *this;
- }
-
- // set MAC address
- OptionsBuilder &OptionsBuilder::setMACAddress(const uint8_t *mac_address,const int mac_address_length) {
- if (mac_address != NULL && mac_address_length > 0) {
- int length = mac_address_length;
- if (length > NODE_MAC_ADDRESS_LENGTH) length = NODE_MAC_ADDRESS_LENGTH;
- for(int i=0;i<length;++i) this->m_mac_address[i] = mac_address[i];
- }
- return *this;
- }
-
- // add static resource
- OptionsBuilder &OptionsBuilder::addResource(const StaticResource *resource) { this->m_static_resources.push_back((StaticResource *)resource); return *this; }
-
- // add dynamic resource
- OptionsBuilder &OptionsBuilder::addResource(const DynamicResource *resource) { this->m_dynamic_resources.push_back((DynamicResource *)resource); return *this; }
-
- // build out our immutable self
- Options *OptionsBuilder::build() { return (Options *)this; }
- }
\ No newline at end of file
+
+#include "OptionsBuilder.h"
+
+// external included configuration file for the endpoint...
+#include "configuration.h"
+
+// Connector namespace
+namespace Connector {
+
+// Constructor
+OptionsBuilder::OptionsBuilder()
+{
+ this->m_lifetime = NSP_LIFE_TIME;
+ this->m_domain = NSP_DOMAIN;
+ this->m_endpoint_type = NSP_ENDPOINT_TYPE;
+ this->m_node_name = NODE_NAME;
+ this->m_channel_list = NODE_CHANNEL_LIST;
+ this->m_rd_update_period = NSP_RD_UPDATE_PERIOD;
+ this->m_nsp_port = NSP_COAP_UDP_PORT;
+
+ memset(this->m_nsp_address,0,NSP_IP_ADDRESS_LENGTH);
+ memset(this->m_mac_address,0,NODE_MAC_ADDRESS_LENGTH);
+ this->m_static_resources.clear();
+ this->m_dynamic_resources.clear();
+}
+
+// Copy Constructor
+OptionsBuilder::OptionsBuilder(const OptionsBuilder &ob)
+{
+ this->m_lifetime = ob.m_lifetime;
+ this->m_domain = ob.m_domain;
+ this->m_endpoint_type = ob.m_endpoint_type;
+ this->m_static_resources = ob.m_static_resources;
+ this->m_dynamic_resources = ob.m_dynamic_resources;
+}
+
+// Destructor
+OptionsBuilder::~OptionsBuilder()
+{
+ this->m_static_resources.clear();
+ this->m_dynamic_resources.clear();
+}
+
+// set lifetime
+OptionsBuilder &OptionsBuilder::setLifetime(const char *lifetime)
+{
+ this->m_lifetime = (char *)lifetime;
+ return *this;
+}
+
+// set domain
+OptionsBuilder &OptionsBuilder::setDomain(const char *domain)
+{
+ this->m_domain = string(domain);
+ return *this;
+}
+
+// set endpoint nodename
+OptionsBuilder &OptionsBuilder::setEndpointNodename(const char *node_name)
+{
+ this->m_node_name = string(node_name);
+ return *this;
+}
+
+// set lifetime
+OptionsBuilder &OptionsBuilder::setEndpointType(const char *endpoint_type)
+{
+ this->m_endpoint_type = string(endpoint_type);
+ return *this;
+}
+
+// set NSP port number
+OptionsBuilder &OptionsBuilder::setNSPPortNumber(const int port_num)
+{
+ this->m_nsp_port = port_num;
+ return *this;
+}
+
+// set low level radio channel list
+OptionsBuilder &OptionsBuilder::setRadioChannelList(const uint32_t channel_list)
+{
+ this->m_channel_list = channel_list;
+ return *this;
+}
+
+// set NSP read update period
+OptionsBuilder &OptionsBuilder::setReadUpdatePeriod(const int rd_update_period)
+{
+ this->m_rd_update_period = rd_update_period;
+ return *this;
+}
+
+// set NSP address
+OptionsBuilder &OptionsBuilder::setNSPAddress(const uint8_t *nsp_address,const int nsp_address_length)
+{
+ if (nsp_address != NULL && nsp_address_length > 0) {
+ int length = nsp_address_length;
+ if (length > NSP_IP_ADDRESS_LENGTH) length = NSP_IP_ADDRESS_LENGTH;
+ for(int i=0; i<length; ++i) this->m_nsp_address[i] = nsp_address[i];
+ }
+ return *this;
+}
+
+// set MAC address
+OptionsBuilder &OptionsBuilder::setMACAddress(const uint8_t *mac_address,const int mac_address_length)
+{
+ if (mac_address != NULL && mac_address_length > 0) {
+ int length = mac_address_length;
+ if (length > NODE_MAC_ADDRESS_LENGTH) length = NODE_MAC_ADDRESS_LENGTH;
+ for(int i=0; i<length; ++i) this->m_mac_address[i] = mac_address[i];
+ }
+ return *this;
+}
+
+// add static resource
+OptionsBuilder &OptionsBuilder::addResource(const StaticResource *resource)
+{
+ this->m_static_resources.push_back((StaticResource *)resource);
+ return *this;
+}
+
+// add dynamic resource
+OptionsBuilder &OptionsBuilder::addResource(const DynamicResource *resource)
+{
+ this->m_dynamic_resources.push_back((DynamicResource *)resource);
+ return *this;
+}
+
+// build out our immutable self
+Options *OptionsBuilder::build()
+{
+ return (Options *)this;
+}
+
+} // namespace Connector
--- a/api/OptionsBuilder.h Tue Jan 27 22:52:25 2015 +0000
+++ b/api/OptionsBuilder.h Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP OptionsBuilder class header
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,118 +19,123 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #ifndef __OPTIONS_BUILDER_H__
- #define __OPTIONS_BUILDER_H__
-
- // base class support
- #include "Options.h"
-
- // Connector namespace
- namespace Connector {
- class OptionsBuilder : Options {
- public:
- /**
- Default Constructor
- */
- OptionsBuilder();
-
- /**
- Copy Constructor
- @param ob input options builder instance to deep copy
- */
- OptionsBuilder(const OptionsBuilder &ob);
-
- /**
- Destructor
- */
- virtual ~OptionsBuilder();
-
- /**
- Set the NSDL Endpoint Lifetime
- @param lifetime input the NSDL endpoint lifetime (seconds)
- @return instance to ourself
- */
- OptionsBuilder &setLifetime(const char *lifetime);
-
- /**
- Set the NSDL Domain
- @param domain input the NSDL domain to set
- @return instance to ourself
- */
- OptionsBuilder &setDomain(const char *domain);
-
- /**
- Set the Endpoint Node Name
- @param node_name input the node endpoint name
- @return instance to ourself
- */
- OptionsBuilder &setEndpointNodename(const char *node_name);
-
- /**
- Set the NSDL Endpoint Type
- @param endpoint_type input the NSDL endpoint type
- @return instance to ourself
- */
- OptionsBuilder &setEndpointType(const char *endpoint_type);
-
- /**
- Set the NSDL Port Number
- @param port_num input the NSDL port number
- @return instance to ourself
- */
- OptionsBuilder &setNSPPortNumber(const int port_num);
-
- /**
- Set the underlying radio stack channel list
- @param channel_list input the radio channel list
- @return instance to ourself
- */
- OptionsBuilder &setRadioChannelList(const uint32_t channel_list);
-
- /**
- Set the NSDL Read Update Period
- @param rd_update_period_ms input the NSDL read update period (in ms)
- @return instance to ourself
- */
- OptionsBuilder &setReadUpdatePeriod(const int rd_update_period_ms);
-
- /**
- Set the NSP IPv6 Address
- @param nsp_address input the NSP IPv6 address
- @param nsp_address_length input the length of the NSP IPv6 address buffer
- @return instance to ourself
- */
- OptionsBuilder &setNSPAddress(const uint8_t *nsp_address,const int nsp_address_length);
-
- /**
- Set the MAC address
- @param mac_address input the MAC address buffer
- @param mac_address_length input the MAC address buffer length
- @return instance to ourself
- */
- OptionsBuilder &setMACAddress(const uint8_t *mac_address,const int mac_address_length);
-
- /**
- Add a NSDL endpoint resource (static)
- @param static_resource input the NSDL static resource
- @return instance to ourself
- */
- OptionsBuilder &addResource(const StaticResource *static_resource);
-
- /**
- Add a NSDL endpoint resource (dynamic)
- @param dynamic_resource input the NSDL dynamic resource
- @return instance to ourself
- */
- OptionsBuilder &addResource(const DynamicResource *static_resource);
-
- /**
- Build our our immutable self
- */
- Options *build();
-
- };
- }
-
- #endif // __OPTIONS_BUILDER_H__
\ No newline at end of file
+
+#ifndef __OPTIONS_BUILDER_H__
+#define __OPTIONS_BUILDER_H__
+
+// base class support
+#include "Options.h"
+
+// Connector namespace
+namespace Connector {
+
+/** OptionsBuilder class
+ */
+class OptionsBuilder : Options
+{
+public:
+ /**
+ Default Constructor
+ */
+ OptionsBuilder();
+
+ /**
+ Copy Constructor
+ @param ob input options builder instance to deep copy
+ */
+ OptionsBuilder(const OptionsBuilder &ob);
+
+ /**
+ Destructor
+ */
+ virtual ~OptionsBuilder();
+
+ /**
+ Set the NSDL Endpoint Lifetime
+ @param lifetime input the NSDL endpoint lifetime (seconds)
+ @return instance to ourself
+ */
+ OptionsBuilder &setLifetime(const char *lifetime);
+
+ /**
+ Set the NSDL Domain
+ @param domain input the NSDL domain to set
+ @return instance to ourself
+ */
+ OptionsBuilder &setDomain(const char *domain);
+
+ /**
+ Set the Endpoint Node Name
+ @param node_name input the node endpoint name
+ @return instance to ourself
+ */
+ OptionsBuilder &setEndpointNodename(const char *node_name);
+
+ /**
+ Set the NSDL Endpoint Type
+ @param endpoint_type input the NSDL endpoint type
+ @return instance to ourself
+ */
+ OptionsBuilder &setEndpointType(const char *endpoint_type);
+
+ /**
+ Set the NSDL Port Number
+ @param port_num input the NSDL port number
+ @return instance to ourself
+ */
+ OptionsBuilder &setNSPPortNumber(const int port_num);
+
+ /**
+ Set the underlying radio stack channel list
+ @param channel_list input the radio channel list
+ @return instance to ourself
+ */
+ OptionsBuilder &setRadioChannelList(const uint32_t channel_list);
+
+ /**
+ Set the NSDL Read Update Period
+ @param rd_update_period_ms input the NSDL read update period (in ms)
+ @return instance to ourself
+ */
+ OptionsBuilder &setReadUpdatePeriod(const int rd_update_period_ms);
+
+ /**
+ Set the NSP IPv6 Address
+ @param nsp_address input the NSP IPv6 address
+ @param nsp_address_length input the length of the NSP IPv6 address buffer
+ @return instance to ourself
+ */
+ OptionsBuilder &setNSPAddress(const uint8_t *nsp_address,const int nsp_address_length);
+
+ /**
+ Set the MAC address
+ @param mac_address input the MAC address buffer
+ @param mac_address_length input the MAC address buffer length
+ @return instance to ourself
+ */
+ OptionsBuilder &setMACAddress(const uint8_t *mac_address,const int mac_address_length);
+
+ /**
+ Add a NSDL endpoint resource (static)
+ @param static_resource input the NSDL static resource
+ @return instance to ourself
+ */
+ OptionsBuilder &addResource(const StaticResource *static_resource);
+
+ /**
+ Add a NSDL endpoint resource (dynamic)
+ @param dynamic_resource input the NSDL dynamic resource
+ @return instance to ourself
+ */
+ OptionsBuilder &addResource(const DynamicResource *static_resource);
+
+ /**
+ Build our our immutable self
+ */
+ Options *build();
+
+};
+
+} // namespace Connector
+
+#endif // __OPTIONS_BUILDER_H__
--- a/api/Resource.h Tue Jan 27 22:52:25 2015 +0000
+++ b/api/Resource.h Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint Resource base class template
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,92 +19,105 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #ifndef __RESOURCE_H__
- #define __RESOURCE_H__
+
+#ifndef __RESOURCE_H__
+#define __RESOURCE_H__
+
+// logging facility
+#include "Logger.h"
+
+// string support
+#include <string>
+
+/** Resource class
+ */
+template <typename InnerType> class Resource
+{
+public:
+ /**
+ Default constructor
+ @param logger input the Logger instance this Resource is a part of
+ @param name input the Resource URI/Name
+ @param value input the Resource value
+ */
+ Resource(const Logger *logger,const string name,InnerType value) {
+ this->init(logger);
+ this->m_name = name;
+ this->m_value = value;
+ }
+
+ /**
+ Copy constructor
+ @param resource input the Resource that is to be deep copied
+ */
+ Resource(const Resource<InnerType> &resource) {
+ this->init(resource.m_logger);
+ this->m_endpoint = resource.m_endpoint;
+ this->m_name = resource.m_name;
+ this->m_value = resource.m_value;
+ }
+
+ /**
+ Destructor
+ */
+ virtual ~Resource() {
+ }
- // logging facility
- #include "Logger.h"
-
- // string support
- #include <string>
-
- template <typename InnerType> class Resource {
- public:
- /**
- Default constructor
- @param logger input the Logger instance this Resource is a part of
- @param name input the Resource URI/Name
- @param value input the Resource value
- */
- Resource(const Logger *logger,const string name,InnerType value) {
- this->init(logger);
- this->m_name = name;
- this->m_value = value;
- }
-
- /**
- Copy constructor
- @param resource input the Resource that is to be deep copied
- */
- Resource(const Resource<InnerType> &resource) {
- this->init(resource.m_logger);
- this->m_endpoint = resource.m_endpoint;
- this->m_name = resource.m_name;
- this->m_value = resource.m_value;
- }
-
- /**
- Destructor
- */
- virtual ~Resource() {
- }
-
- /**
- Get the resource name
- @return the name of the resource
- */
- string getName() { return this->m_name; }
-
- /**
- Get the resource value
- @return the value of the resource
- */
- InnerType getValue() { return this->m_value; }
-
- /**
- Set the resource name
- @param name input the resource name
- */
- void setName(const string name) { this->m_name = name; }
-
- /**
- Set the resource value
- @param value input the resource value
- */
- void setValue(const InnerType value) { this->m_value = value; }
-
- /**
- Bind resource to endpoint
- */
- virtual void bind(void *p) = 0;
-
- // access the logger()
- Logger *logger() { return this->m_logger; }
+ /**
+ Get the resource name
+ @return the name of the resource
+ */
+ string getName() {
+ return this->m_name;
+ }
+
+ /**
+ Get the resource value
+ @return the value of the resource
+ */
+ InnerType getValue() {
+ return this->m_value;
+ }
+
+ /**
+ Set the resource name
+ @param name input the resource name
+ */
+ void setName(const string name) {
+ this->m_name = name;
+ }
- protected:
- // initialize internals to Resource
- void init(const Logger *logger) {
- this->m_logger = (Logger *)logger;
- this->m_endpoint = NULL;
- this->m_name = "";
- this->m_value = "";
- }
-
- Logger *m_logger;
- void *m_endpoint;
- string m_name;
- InnerType m_value;
- };
-
- #endif // __RESOURCE_H__
\ No newline at end of file
+ /**
+ Set the resource value
+ @param value input the resource value
+ */
+ void setValue(const InnerType value) {
+ this->m_value = value;
+ }
+
+ /**
+ Bind resource to endpoint
+ */
+ virtual void bind(void *p) = 0;
+
+ // access the logger()
+ Logger *logger() {
+ return this->m_logger;
+ }
+
+protected:
+ // initialize internals to Resource
+ void init(const Logger *logger) {
+ this->m_logger = (Logger *)logger;
+ this->m_endpoint = NULL;
+ this->m_name = "";
+ this->m_value = "";
+ }
+
+ Logger *m_logger;
+ void *m_endpoint;
+ string m_name;
+ InnerType m_value;
+};
+
+#endif // __RESOURCE_H__
--- a/api/StaticResource.cpp Tue Jan 27 22:52:25 2015 +0000
+++ b/api/StaticResource.cpp Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint Static Resource class
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,34 +19,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #include "StaticResource.h"
-
- // NSDL libraries
- #include "nsdl_support.h"
-
- // Constructor
- StaticResource::StaticResource(const Logger *logger,const char *name, const char *value) : Resource<string>(logger,string(name),string(value)) {
- }
-
- // Constructor
- StaticResource::StaticResource(const Logger *logger,const char *name,const string value) : Resource<string>(logger,string(name),string(value)) {
- }
-
- // Constructor with buffer lengths
- StaticResource::StaticResource(const Logger *logger,const string name,const string value) : Resource<string>(logger,string(name),string(value)) {
- }
-
- // Copy constructor
- StaticResource::StaticResource(const StaticResource &resource) : Resource<string>((const Resource<string> &)resource) {
- }
-
- // Destructor
- StaticResource::~StaticResource() {
- }
-
- // Bind resource to Endpoint
- void StaticResource::bind(void *p) {
+
+#include "StaticResource.h"
+
+// NSDL libraries
+#include "nsdl_support.h"
+
+// Constructor
+StaticResource::StaticResource(const Logger *logger,const char *name, const char *value) : Resource<string>(logger,string(name),string(value))
+{
+}
+
+// Constructor
+StaticResource::StaticResource(const Logger *logger,const char *name,const string value) : Resource<string>(logger,string(name),string(value))
+{
+}
+
+// Constructor with buffer lengths
+StaticResource::StaticResource(const Logger *logger,const string name,const string value) : Resource<string>(logger,string(name),string(value))
+{
+}
+
+// Copy constructor
+StaticResource::StaticResource(const StaticResource &resource) : Resource<string>((const Resource<string> &)resource)
+{
+}
+
+// Destructor
+StaticResource::~StaticResource()
+{
+}
+
+// Bind resource to Endpoint
+void StaticResource::bind(void *p)
+{
if (p != NULL) {
sn_nsdl_resource_info_s *resource_ptr = (sn_nsdl_resource_info_s *)p;
std::printf("StaticResource: name[%s] value:[%s]\r\n",this->getName().c_str(),this->getValue().c_str());
@@ -56,8 +62,7 @@
int value_length = this->getValue().size();
nsdl_create_static_resource(resource_ptr,name_length,(uint8_t *)name,0,0,(uint8_t *)value,value_length);
std::printf("StaticResource[%s(%d)] value: %s(%d) bound\r\n",name,name_length,value,value_length);
- }
- else {
+ } else {
std::printf("StaticResource: NULL parameter in bind()\r\n");
}
- }
\ No newline at end of file
+}
--- a/api/StaticResource.h Tue Jan 27 22:52:25 2015 +0000
+++ b/api/StaticResource.h Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint Static Resource class
* @author Doug Anson/Chris Paola
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,64 +19,66 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- #ifndef __STATIC_RESOURCE_H__
- #define __STATIC_RESOURCE_H__
-
- // Base Class
- #include "Resource.h"
-
- // String class support
- #include <string>
-
- // StaticResource is a static (GET only) resource with a value type pinned as a string type
- class StaticResource : public Resource<string> {
- public:
- /**
- Default constructor
- @param logger input logger instance for this resource
- @param name input the Resource URI/Name
- @param value input the Resource value (a string)
- */
- StaticResource(const Logger *logger,const char *name,const char *value);
-
- /**
- string value constructor
- @param logger input logger instance for this resource
- @param name input the Resource URI/Name
- @param value input the Resource value (a string)
- */
- StaticResource(const Logger *logger,const char *name,const string value);
+
+#ifndef __STATIC_RESOURCE_H__
+#define __STATIC_RESOURCE_H__
+
+// Base Class
+#include "Resource.h"
+
+// String class support
+#include <string>
+
+/** StaticResource is a static (GET only) resource with a value type pinned as a string type
+ */
+class StaticResource : public Resource<string>
+{
+public:
+ /**
+ Default constructor
+ @param logger input logger instance for this resource
+ @param name input the Resource URI/Name
+ @param value input the Resource value (a string)
+ */
+ StaticResource(const Logger *logger,const char *name,const char *value);
+
+ /**
+ string value constructor
+ @param logger input logger instance for this resource
+ @param name input the Resource URI/Name
+ @param value input the Resource value (a string)
+ */
+ StaticResource(const Logger *logger,const char *name,const string value);
- /**
- constructor with buffer lengths
- @param logger input logger instance for this resource
- @param name input the Resource URI/Name
- #param name_length input the length of the Resource URI/Name
- @param value input the Resource value (or NULL)
- */
- StaticResource(const Logger *logger,const string name,const string value);
-
- /**
- Copy constructor
- @param resource input the StaticResource that is to be deep copied
- */
- StaticResource(const StaticResource &resource);
-
- /**
- Destructor
- */
- virtual ~StaticResource();
-
- /**
- Bind resource to endpoint
- @param p input pointer to the endpoint resources necessary for binding
- */
- virtual void bind(void *p);
-
- protected:
-
- private:
- };
-
- #endif // __STATIC_RESOURCE_H__
\ No newline at end of file
+ /**
+ constructor with buffer lengths
+ @param logger input logger instance for this resource
+ @param name input the Resource URI/Name
+ #param name_length input the length of the Resource URI/Name
+ @param value input the Resource value (or NULL)
+ */
+ StaticResource(const Logger *logger,const string name,const string value);
+
+ /**
+ Copy constructor
+ @param resource input the StaticResource that is to be deep copied
+ */
+ StaticResource(const StaticResource &resource);
+
+ /**
+ Destructor
+ */
+ virtual ~StaticResource();
+
+ /**
+ Bind resource to endpoint
+ @param p input pointer to the endpoint resources necessary for binding
+ */
+ virtual void bind(void *p);
+
+protected:
+
+private:
+};
+
+#endif // __STATIC_RESOURCE_H__
--- a/api/Utils.cpp Tue Jan 27 22:52:25 2015 +0000
+++ b/api/Utils.cpp Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
* @brief mbed CoAP Endpoint misc utils collection
* @author Doug Anson
* @version 1.0
- * @see
+ * @see
*
* Copyright (c) 2014
*
@@ -19,7 +19,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
// mbed Endpoint includes
#include "Endpoint.h"
#include "OptionsBuilder.h"
@@ -29,18 +29,19 @@
extern Logger logger;
// further simplifies the endpoint main() configuration by removing the final initialization details of the endpoint...
-void configure_endpoint() {
+void configure_endpoint()
+{
Connector::OptionsBuilder builder;
Connector::Options *options = configure_endpoint(builder);
-
- // alloc Endpoint resource
+
+ // alloc Endpoint resource
logger.log("configure_endpoint: allocating endpoint...\r\n");
Connector::Endpoint endpoint(&logger,options);
-
+
// initialize Endpoint resource
logger.log("configure_endpoint: initializing endpoint...\r\n");
- endpoint.initialize();
-
+ endpoint.initialize();
+
// DONE
logger.log("configure_endpoint: completed\r\n");
-}
\ No newline at end of file
+}
--- a/mbedConnectorInterface.h Tue Jan 27 22:52:25 2015 +0000 +++ b/mbedConnectorInterface.h Tue Jan 27 23:41:34 2015 +0000 @@ -3,7 +3,7 @@ * @brief mbed Connector Inteface configuration header file * @author Doug Anson * @version 1.0 - * @see + * @see * * Copyright (c) 2014 *
