Update to observe-13 (cancellation).

This commit is contained in:
Matthias Kovatsch 2014-05-15 14:32:08 +02:00 committed by Matthias Kovatsch
parent 2683e13da5
commit ee493dd6af
1 changed files with 28 additions and 27 deletions

View File

@ -237,6 +237,7 @@ coap_observe_handler(resource_t *resource, void *request, void *response)
if(coap_req->code == COAP_GET && coap_res->code < 128) { /* GET request and response without error code */
if(IS_OPTION(coap_req, COAP_OPTION_OBSERVE)) {
if(coap_req->observe == 0) {
if(coap_add_observer(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport,
coap_req->token, coap_req->token_len,
@ -257,14 +258,14 @@ coap_observe_handler(resource_t *resource, void *request, void *response)
} else {
coap_res->code = SERVICE_UNAVAILABLE_5_03;
coap_set_payload(coap_res, "TooManyObservers", 16);
} /* if(added observer) */
} else { /* if (observe) */
}
} else if(coap_req->observe == 1) {
/* remove client if it is currently observe */
coap_remove_observer_by_token(&UIP_IP_BUF->srcipaddr,
UIP_UDP_BUF->srcport, coap_req->token,
coap_req->token_len);
/* if(observe) */
}
}
}
}