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
Diff: api/DynamicResource.cpp
- Revision:
- 23:caa0260acc21
- Parent:
- 22:192b598ba389
- Child:
- 24:a6915e19814e
--- 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..."); }