Commit 1b0906a2 authored by Kishen Maloor's avatar Kishen Maloor

Fix separate response handling for notifications

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent 27c0247b
......@@ -370,8 +370,10 @@ oc_resource_set_request_handler(oc_resource_t *resource, oc_method_t method,
break;
}
handler->cb = callback;
handler->user_data = user_data;
if (handler) {
handler->cb = callback;
handler->user_data = user_data;
}
}
void
......@@ -431,7 +433,7 @@ oc_send_separate_response(oc_separate_response_t *handle,
while (cur != NULL) {
next = cur->next;
if (cur->observe > 0) {
if (cur->observe < 3) {
coap_transaction_t *t =
coap_new_transaction(coap_get_mid(), &cur->endpoint);
if (t) {
......
......@@ -730,10 +730,11 @@ coap_notify_observers(oc_resource_t *resource,
"notification");
#ifdef OC_BLOCK_WISE
if (coap_separate_accept(req, response.separate_response,
&obs->endpoint, 0, obs->block2_size) == 1)
&obs->endpoint, obs->obs_counter,
obs->block2_size) == 1)
#else /* OC_BLOCK_WISE */
if (coap_separate_accept(req, response.separate_response,
&obs->endpoint, 0) == 1)
&obs->endpoint, obs->obs_counter) == 1)
#endif /* !OC_BLOCK_WISE */
response.separate_response->active = 1;
} // separate response
......
......@@ -98,7 +98,8 @@ coap_separate_accept(void *request, oc_separate_response_t *separate_response,
separate_store != NULL; separate_store = separate_store->next) {
if (separate_store->token_len == coap_req->token_len &&
memcmp(separate_store->token, coap_req->token,
separate_store->token_len) == 0) {
separate_store->token_len) == 0 &&
separate_store->observe == observe) {
break;
}
}
......@@ -113,8 +114,6 @@ coap_separate_accept(void *request, oc_separate_response_t *separate_response,
oc_list_add(separate_response->requests, separate_store);
memcpy(&separate_store->endpoint, endpoint, sizeof(oc_endpoint_t));
/* store correct response type */
separate_store->type = COAP_TYPE_NON;
......@@ -131,6 +130,8 @@ coap_separate_accept(void *request, oc_separate_response_t *separate_response,
#endif /* OC_BLOCK_WISE */
}
memcpy(&separate_store->endpoint, endpoint, sizeof(oc_endpoint_t));
separate_store->observe = observe;
/* send separate ACK for CON */
......@@ -179,6 +180,9 @@ coap_separate_resume(void *response, coap_separate_t *separate_store,
if (separate_store->token_len) {
coap_set_token(response, separate_store->token, separate_store->token_len);
}
if (separate_store->observe == 0) {
coap_set_header_observe(response, 0);
}
}
/*---------------------------------------------------------------------------*/
void
......
......@@ -54,8 +54,7 @@
#include "transactions.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
typedef struct coap_separate
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment