Michael Koster / mbedConnectorInterface

Fork of mbedConnectorInterface by Doug Anson

Files at this revision

API Documentation at this revision

Comitter:
ansond
Date:
Thu Mar 19 04:05:08 2015 +0000
Parent:
22:192b598ba389
Child:
24:a6915e19814e
Commit message:
updates for k64f hrm

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
mbedConnectorInterface.h Show annotated file Show diff for this revision Revisions of this file
--- a/api/DynamicResource.cpp	Fri Mar 13 06:22:41 2015 +0000
+++ b/api/DynamicResource.cpp	Thu Mar 19 04:05:08 2015 +0000
@@ -114,21 +114,17 @@
 
             // convert the string from the GET to something suitable for CoAP payloads
             this->logger()->log("Building payload for [%s]=[%s]...",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
-            coap_res_ptr->payload_len = length;
-            coap_res_ptr->payload_ptr = (uint8_t *)value_buffer;
+            coap_res_ptr->payload_len = value.size();
+            coap_res_ptr->payload_ptr = (uint8_t *)value.c_str();
             
             // Observation handling... 
             if(received_coap_ptr->token_ptr) {
                 if(this->m_obs_token_ptr) {
                     free(this->m_obs_token_ptr);
                     this->m_obs_token_ptr = NULL;
+                    this->m_obs_token_len = 0;
                 }
                 
                 this->m_obs_token_ptr = (uint8_t*)malloc(received_coap_ptr->token_len);
@@ -238,7 +234,7 @@
 
 // send the notification
 int DynamicResource::notify(uint8_t *data,int data_length) {
-    int status = sn_nsdl_send_observation_notification(this->m_obs_token_ptr,this->m_obs_token_len,data,data_length, &this->m_obs_number, 1,COAP_MSG_TYPE_NON_CONFIRMABLE,0);
+    int status = sn_nsdl_send_observation_notification(this->m_obs_token_ptr,this->m_obs_token_len,data,data_length,&this->m_obs_number,1,COAP_MSG_TYPE_NON_CONFIRMABLE,0);
     if (status == 0) {
         this->logger()->log("ERROR: resource(NOTIFY) send failed...");
     }
--- a/api/DynamicResource.h	Fri Mar 13 06:22:41 2015 +0000
+++ b/api/DynamicResource.h	Thu Mar 19 04:05:08 2015 +0000
@@ -123,6 +123,12 @@
     */
     int notify(const string data);
     
+    /**
+    Determine whether this dynamic resource is observable or not
+    @returns true - is observable, false - otherwise
+    */
+    bool isObservable() { return this->m_observable; }
+    
 protected:
     int notify(uint8_t *data,int data_length);
 
--- a/mbedConnectorInterface.h	Fri Mar 13 06:22:41 2015 +0000
+++ b/mbedConnectorInterface.h	Thu Mar 19 04:05:08 2015 +0000
@@ -40,7 +40,7 @@
 #define NODE_CHANNEL_LIST        0x07FFF800                                  // All channels
 
 // DynamicResource Configuration
-#define MAX_VALUE_BUFFER_LENGTH  256                                         // largest "value" a dynamic resource may assume as a string
+#define MAX_VALUE_BUFFER_LENGTH  128                                         // largest "value" a dynamic resource may assume as a string
 
 // Instance Pointer Table Configuration
 #define IPT_MAX_ENTRIES          5                                           // maximum number of unique pointers managed by the IPT (i.e. number of independent dynamic resources)