Bugfixes for observing. Many thanks to Klaus Hartke.

This commit is contained in:
Matthias Kovatsch 2012-02-01 05:16:16 +01:00
parent c1aa211dc7
commit 860de0dd01
2 changed files with 3 additions and 7 deletions

View file

@ -223,11 +223,7 @@ handle_incoming_data(void)
{ {
PRINTF("Received RST\n"); PRINTF("Received RST\n");
/* Cancel possible subscriptions. */ /* Cancel possible subscriptions. */
if (IS_OPTION(message, COAP_OPTION_TOKEN)) coap_remove_observer_by_mid(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport, message->mid);
{
/* Erbium stores last MID for each observer. */
coap_remove_observer_by_mid(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport, message->mid);
}
} }
if ( (transaction = coap_get_transaction_by_mid(message->mid)) ) if ( (transaction = coap_get_transaction_by_mid(message->mid)) )

View file

@ -118,7 +118,7 @@ coap_remove_observer_by_token(uip_ipaddr_t *addr, uint16_t port, uint8_t *token,
for (obs = (coap_observer_t*)list_head(observers_list); obs; obs = obs->next) for (obs = (coap_observer_t*)list_head(observers_list); obs; obs = obs->next)
{ {
PRINTF("Remove check Token 0x%02X%02X\n", token[0], token[1]); PRINTF("Remove check Token 0x%02X%02X\n", token[0], token[1]);
if (uip_ipaddr_cmp(&obs->addr, addr) && obs->port==port && memcmp(obs->token, token, token_len)==0) if (uip_ipaddr_cmp(&obs->addr, addr) && obs->port==port && obs->token_len==token_len && memcmp(obs->token, token, token_len)==0)
{ {
coap_remove_observer(obs); coap_remove_observer(obs);
removed++; removed++;
@ -153,7 +153,7 @@ coap_remove_observer_by_mid(uip_ipaddr_t *addr, uint16_t port, uint16_t mid)
for (obs = (coap_observer_t*)list_head(observers_list); obs; obs = obs->next) for (obs = (coap_observer_t*)list_head(observers_list); obs; obs = obs->next)
{ {
PRINTF("Remove check URL %p\n", url); PRINTF("Remove check MID %u\n", mid);
if (uip_ipaddr_cmp(&obs->addr, addr) && obs->port==port && obs->last_mid==mid) if (uip_ipaddr_cmp(&obs->addr, addr) && obs->port==port && obs->last_mid==mid)
{ {
coap_remove_observer(obs); coap_remove_observer(obs);