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

View file

@ -194,7 +194,7 @@ coap_notify_observers(resource_t *resource)
/*TODO implement special transaction for CON, sharing the same buffer to allow for more observers */
if((transaction = coap_new_transaction(coap_get_mid(), &obs->addr, obs->port))) {
if (obs->obs_counter % COAP_OBSERVE_REFRESH_INTERVAL == 0) {
if(obs->obs_counter % COAP_OBSERVE_REFRESH_INTERVAL == 0) {
PRINTF(" Force Confirmable for\n");
notification->type = COAP_TYPE_CON;
}
@ -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) */
}
}
}
}