From 56f877b63370614db6d7c085c404849d9eccb867 Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 19 Jun 2013 14:45:20 +0200 Subject: [PATCH 1/9] Fixed option header bug for large deltas. --- apps/er-coap-13/er-coap-13.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/apps/er-coap-13/er-coap-13.c b/apps/er-coap-13/er-coap-13.c index 5a9d99498..8f474730a 100644 --- a/apps/er-coap-13/er-coap-13.c +++ b/apps/er-coap-13/er-coap-13.c @@ -90,7 +90,7 @@ coap_parse_int_option(uint8_t *bytes, size_t length) while (i268) { - buffer[written++] = (*x-269)>>8; - buffer[written++] = (*x-269); + buffer[++written] = (*x-269)>>8; + buffer[++written] = (*x-269); } - else if (delta>12) + else if (*x>12) { - buffer[written++] = (*x-13); + buffer[++written] = (*x-13); } } while (x!=&length && (x=&length)); PRINTF("WRITTEN %u B opt header\n", written); - return written; + return ++written; } /*-----------------------------------------------------------------------------------*/ static @@ -148,14 +148,19 @@ coap_serialize_int_option(unsigned int number, unsigned int current_number, uint { size_t i = 0; - if (0xFF000000 & value) buffer[++i] = (uint8_t) (0xFF & value>>24); - if (0xFFFF0000 & value) buffer[++i] = (uint8_t) (0xFF & value>>16); - if (0xFFFFFF00 & value) buffer[++i] = (uint8_t) (0xFF & value>>8); - if (0xFFFFFFFF & value) buffer[++i] = (uint8_t) (0xFF & value); + if (0xFF000000 & value) ++i; + if (0xFFFF0000 & value) ++i; + if (0xFFFFFF00 & value) ++i; + if (0xFFFFFFFF & value) ++i; PRINTF("OPTION %u (delta %u, len %u)\n", number, number - current_number, i); - i += coap_set_option_header(number - current_number, i, buffer); + i = coap_set_option_header(number - current_number, i, buffer); + + if (0xFF000000 & value) buffer[i++] = (uint8_t) (value>>24); + if (0xFFFF0000 & value) buffer[i++] = (uint8_t) (value>>16); + if (0xFFFFFF00 & value) buffer[i++] = (uint8_t) (value>>8); + if (0xFFFFFFFF & value) buffer[i++] = (uint8_t) (value); return i; } @@ -319,8 +324,8 @@ coap_serialize_message(void *packet, uint8_t *buffer) coap_pkt->buffer[0] |= COAP_HEADER_TYPE_MASK & (coap_pkt->type)<buffer[0] |= COAP_HEADER_TOKEN_LEN_MASK & (coap_pkt->token_len)<buffer[1] = coap_pkt->code; - coap_pkt->buffer[2] = 0xFF & (coap_pkt->mid)>>8; - coap_pkt->buffer[3] = 0xFF & coap_pkt->mid; + coap_pkt->buffer[2] = (uint8_t) ((coap_pkt->mid)>>8); + coap_pkt->buffer[3] = (uint8_t) (coap_pkt->mid); /* set Token */ PRINTF("Token (len %u)", coap_pkt->token_len); From 3048126ff1e5f0d2e5d4125e6fda32386bc84150 Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 19 Jun 2013 14:45:57 +0200 Subject: [PATCH 2/9] Limited observe clock to 24 bits. --- apps/er-coap-13/er-coap-13.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/er-coap-13/er-coap-13.c b/apps/er-coap-13/er-coap-13.c index 8f474730a..8755e940c 100644 --- a/apps/er-coap-13/er-coap-13.c +++ b/apps/er-coap-13/er-coap-13.c @@ -1013,7 +1013,7 @@ coap_set_header_observe(void *packet, uint32_t observe) { coap_packet_t *const coap_pkt = (coap_packet_t *) packet; - coap_pkt->observe = observe; + coap_pkt->observe = 0x00FFFFFF & observe; SET_OPTION(coap_pkt, COAP_OPTION_OBSERVE); return 1; } From 78e3a75b9cfa7d226a922801eb62400e2ef92442 Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 19 Jun 2013 14:48:04 +0200 Subject: [PATCH 3/9] Updated buffer definition macro due to core changes. --- apps/er-coap-03/er-coap-03.h | 4 ++-- apps/er-coap-07/er-coap-07.h | 4 ++-- apps/er-coap-12/er-coap-12.h | 4 ++-- apps/er-coap-13/er-coap-13.h | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/er-coap-03/er-coap-03.h b/apps/er-coap-03/er-coap-03.h index 00a292bcb..fb69bd63a 100644 --- a/apps/er-coap-03/er-coap-03.h +++ b/apps/er-coap-03/er-coap-03.h @@ -85,8 +85,8 @@ #define COAP_MAX_ATTEMPTS 4 #endif /* COAP_MAX_ATTEMPTS */ -#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) -#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[uip_l2_l3_hdr_len]) +#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) +#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN]) #define SET_OPTION(packet, opt) ((packet)->options |= 1<options & 1<options |= 1L<options & 1L< */ -#ifndef COAP_12_H_ -#define COAP_12_H_ +#ifndef COAP_13_H_ +#define COAP_13_H_ #include /* for size_t */ #include "contiki-net.h" @@ -92,8 +92,8 @@ #define COAP_MAX_ATTEMPTS 4 #endif /* COAP_MAX_ATTEMPTS */ -#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) -#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[uip_l2_l3_hdr_len]) +#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) +#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN]) /* Bitmap for set options */ enum { OPTION_MAP_SIZE = sizeof(uint8_t) * 8 }; @@ -379,4 +379,4 @@ int coap_set_header_size(void *packet, uint32_t size); int coap_get_payload(void *packet, const uint8_t **payload); int coap_set_payload(void *packet, const void *payload, size_t length); -#endif /* COAP_12_H_ */ +#endif /* COAP_13_H_ */ From 5e18efa10cb71d2ebbc92c8861c0907454252c2d Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 19 Jun 2013 14:49:11 +0200 Subject: [PATCH 4/9] Updated copyright information. --- apps/er-coap-13/er-coap-13-engine.c | 2 +- apps/er-coap-13/er-coap-13-engine.h | 2 +- apps/er-coap-13/er-coap-13-observing.c | 2 +- apps/er-coap-13/er-coap-13-observing.h | 3 ++- apps/er-coap-13/er-coap-13-separate.c | 2 +- apps/er-coap-13/er-coap-13-separate.h | 2 +- apps/er-coap-13/er-coap-13-transactions.c | 2 +- apps/er-coap-13/er-coap-13-transactions.h | 2 +- apps/er-coap-13/er-coap-13.c | 2 +- apps/er-coap-13/er-coap-13.h | 2 +- 10 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/er-coap-13/er-coap-13-engine.c b/apps/er-coap-13/er-coap-13-engine.c index fed8fa889..c3f783ba5 100644 --- a/apps/er-coap-13/er-coap-13-engine.c +++ b/apps/er-coap-13/er-coap-13-engine.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/apps/er-coap-13/er-coap-13-engine.h b/apps/er-coap-13/er-coap-13-engine.h index 6df5f4048..4730a0791 100644 --- a/apps/er-coap-13/er-coap-13-engine.h +++ b/apps/er-coap-13/er-coap-13-engine.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/apps/er-coap-13/er-coap-13-observing.c b/apps/er-coap-13/er-coap-13-observing.c index 8fe62135a..eeb430877 100644 --- a/apps/er-coap-13/er-coap-13-observing.c +++ b/apps/er-coap-13/er-coap-13-observing.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/apps/er-coap-13/er-coap-13-observing.h b/apps/er-coap-13/er-coap-13-observing.h index fa2c7ec9b..3b6510a71 100644 --- a/apps/er-coap-13/er-coap-13-observing.h +++ b/apps/er-coap-13/er-coap-13-observing.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ #ifndef COAP_OBSERVING_H_ #define COAP_OBSERVING_H_ +#include "sys/stimer.h" #include "er-coap-13.h" #include "er-coap-13-transactions.h" diff --git a/apps/er-coap-13/er-coap-13-separate.c b/apps/er-coap-13/er-coap-13-separate.c index b5e135d18..85ec4ec0c 100644 --- a/apps/er-coap-13/er-coap-13-separate.c +++ b/apps/er-coap-13/er-coap-13-separate.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/apps/er-coap-13/er-coap-13-separate.h b/apps/er-coap-13/er-coap-13-separate.h index 850b117d2..d34eea606 100644 --- a/apps/er-coap-13/er-coap-13-separate.h +++ b/apps/er-coap-13/er-coap-13-separate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/apps/er-coap-13/er-coap-13-transactions.c b/apps/er-coap-13/er-coap-13-transactions.c index 650fead1e..6bdc49fc3 100644 --- a/apps/er-coap-13/er-coap-13-transactions.c +++ b/apps/er-coap-13/er-coap-13-transactions.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/apps/er-coap-13/er-coap-13-transactions.h b/apps/er-coap-13/er-coap-13-transactions.h index 22948a782..a127656d6 100644 --- a/apps/er-coap-13/er-coap-13-transactions.h +++ b/apps/er-coap-13/er-coap-13-transactions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/apps/er-coap-13/er-coap-13.c b/apps/er-coap-13/er-coap-13.c index 8755e940c..7fc596dde 100644 --- a/apps/er-coap-13/er-coap-13.c +++ b/apps/er-coap-13/er-coap-13.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/apps/er-coap-13/er-coap-13.h b/apps/er-coap-13/er-coap-13.h index 31fb98352..0d3e60c89 100644 --- a/apps/er-coap-13/er-coap-13.h +++ b/apps/er-coap-13/er-coap-13.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich * All rights reserved. * * Redistribution and use in source and binary forms, with or without From c61dd6135e91d60100bc6073c066346561d3d4e1 Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 19 Jun 2013 14:53:21 +0200 Subject: [PATCH 5/9] Updated Erbium (Er) examples and removed unsupported static routing module. --- examples/er-rest-example/Makefile | 31 ++-- examples/er-rest-example/README.md | 3 +- examples/er-rest-example/er-example-client.c | 7 +- examples/er-rest-example/er-example-server.c | 17 +- examples/er-rest-example/er-plugtest-server.c | 12 +- examples/er-rest-example/project-conf.h | 4 +- examples/er-rest-example/static-routing.c | 155 ------------------ examples/er-rest-example/static-routing.h | 20 --- 8 files changed, 22 insertions(+), 227 deletions(-) delete mode 100644 examples/er-rest-example/static-routing.c delete mode 100644 examples/er-rest-example/static-routing.h diff --git a/examples/er-rest-example/Makefile b/examples/er-rest-example/Makefile index 004f0df26..ece492af8 100644 --- a/examples/er-rest-example/Makefile +++ b/examples/er-rest-example/Makefile @@ -1,28 +1,23 @@ all: er-example-server er-example-client -# Use this target explicitly if requried: er-plugtest-server +# use this target explicitly if requried: er-plugtest-server -CONTIKI=../.. -CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" - -# for static routing, if enabled -ifeq ($(TARGET),$(filter $(TARGET),sky cooja)) -PROJECT_SOURCEFILES += static-routing.c -endif - -# variable for root Makefile.include -WITH_UIP6=1 -# for some platforms -UIP_CONF_IPV6=1 - -# radio configuration -#CFLAGS += -DRF_CHANNEL=20 -#CFLAGS += -DIEEE802154_CONF_PANID=0xCAFE # variable for this Makefile # configure CoAP implementation (3|7|12|13) (er-coap-07 also supports CoAP draft 08) WITH_COAP=13 -# new variable since slip-radio + +# variable for Makefile.include +WITH_UIP6=1 +# for some platforms +UIP_CONF_IPV6=1 +# temporary bugfix for Makefile.include / Makefile.uip +CFLAGS += -DUIP_CONF_IPV6=1 + +CONTIKI=../.. +CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" + +# variable for Makefile.include ifneq ($(TARGET), minimal-net) UIP_CONF_RPL=1 else diff --git a/examples/er-rest-example/README.md b/examples/er-rest-example/README.md index ea18deb25..1aa35b091 100644 --- a/examples/er-rest-example/README.md +++ b/examples/er-rest-example/README.md @@ -11,7 +11,8 @@ EXAMPLE FILES every 10 seconds and cycles through 4 resources on button press (target address is hard-coded). - er-plugtest-server.c: The server used for draft compliance testing at ETSI - IoT CoAP Plugtest in Paris, France, March 2012 (configured for minimal-net). + IoT CoAP Plugtests. Erbium (Er) participated in Paris, France, March 2012 and + Sophia-Antipolis, France, November 2012 (configured for minimal-net). PRELIMINARIES ------------- diff --git a/examples/er-rest-example/er-example-client.c b/examples/er-rest-example/er-example-client.c index e8d623687..d177bbe54 100644 --- a/examples/er-rest-example/er-example-client.c +++ b/examples/er-rest-example/er-example-client.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Matthias Kovatsch and other contributors. + * Copyright (c) 2013, Matthias Kovatsch * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,11 +43,6 @@ #include "contiki.h" #include "contiki-net.h" -#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE) -#warning "Compiling with static routing!" -#include "static-routing.h" -#endif - #include "dev/button-sensor.h" #if WITH_COAP == 3 diff --git a/examples/er-rest-example/er-example-server.c b/examples/er-rest-example/er-example-server.c index 4bdfb7ba2..36fbb5635 100644 --- a/examples/er-rest-example/er-example-server.c +++ b/examples/er-rest-example/er-example-server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Matthias Kovatsch and other contributors. + * Copyright (c) 2013, Matthias Kovatsch * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,8 +45,7 @@ /* Define which resources to include to meet memory constraints. */ #define REST_RES_HELLO 0 -#define REST_RES_MIRROR 0 /* causes largest code size */ -#define REST_RES_CHUNKS 0 +#define REST_RES_CHUNKS 1 #define REST_RES_SEPARATE 1 #define REST_RES_PUSHING 1 #define REST_RES_EVENT 1 @@ -56,14 +55,10 @@ #define REST_RES_LIGHT 0 #define REST_RES_BATTERY 0 #define REST_RES_RADIO 0 +#define REST_RES_MIRROR 0 /* causes largest code size */ -#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE) -#warning "Compiling with static routing!" -#include "static-routing.h" -#endif - #include "erbium.h" @@ -811,12 +806,6 @@ PROCESS_THREAD(rest_server_example, ev, data) PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN); PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE); -/* if static routes are used rather than RPL */ -#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE) - set_global_address(); - configure_routing(); -#endif - /* Initialize the REST engine. */ rest_init_engine(); diff --git a/examples/er-rest-example/er-plugtest-server.c b/examples/er-rest-example/er-plugtest-server.c index 55fb7fd95..5a791a09c 100644 --- a/examples/er-rest-example/er-plugtest-server.c +++ b/examples/er-rest-example/er-plugtest-server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Matthias Kovatsch and other contributors. + * Copyright (c) 2013, Matthias Kovatsch * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,10 +69,6 @@ #endif -#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE) -#warning "Compiling with static routing!" -#include "static-routing.h" -#endif #include "erbium.h" @@ -1240,12 +1236,6 @@ PROCESS_THREAD(plugtest_server, ev, data) PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN); PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE); -/* if static routes are used rather than RPL */ -#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) - set_global_address(); - configure_routing(); -#endif - /* Initialize the REST engine. */ rest_init_engine(); diff --git a/examples/er-rest-example/project-conf.h b/examples/er-rest-example/project-conf.h index 70116dba1..9ba0f0000 100644 --- a/examples/er-rest-example/project-conf.h +++ b/examples/er-rest-example/project-conf.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Institute for Pervasive Computing, ETH Zurich + * Copyright (c) 2013, Matthias Kovatsch * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,7 +66,7 @@ #define COAP_MAX_OBSERVERS 2 */ -/* Filtering can be disabled to save space. */ +/* Filtering .well-known/core per query can be disabled to save space. */ /* #undef COAP_LINK_FORMAT_FILTERING #define COAP_LINK_FORMAT_FILTERING 0 diff --git a/examples/er-rest-example/static-routing.c b/examples/er-rest-example/static-routing.c deleted file mode 100644 index 628594892..000000000 --- a/examples/er-rest-example/static-routing.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * static-routing.c - * - * Created on: Oct 12, 2010 - * Author: simonduq - */ - -#include -#include "static-routing.h" - -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#define PRINT6ADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15]) -#define PRINTLLADDR(lladdr) PRINTF(" %02x:%02x:%02x:%02x:%02x:%02x ",(lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3],(lladdr)->addr[4], (lladdr)->addr[5]) -#else -#define PRINTF(...) -#define PRINT6ADDR(addr) -#define PRINTLLADDR(addr) -#endif - -#include "contiki-net.h" -#include "node-id.h" - -int node_rank; - -struct id_to_addrs { - int id; - uint32_t addr; -}; - -const struct id_to_addrs motes_addrs[] = { -/* - * Static routing requires a map nodeid => address. - * The nodeid can be programmed with the sky-shell. - * The addresses should also be added to /etc/hosts. - * - * aaaa::212:7400:1160:f62d sky1 - * aaaa::212:7400:0da0:d748 sky2 - * aaaa::212:7400:116e:c325 sky3 - * aaaa::212:7400:116e:c444 sky4 - * aaaa::212:7400:115e:b717 sky5 - * - * Add the nodeid and last 4 bytes of the address to the map. - */ - {1, 0x1160f62d}, - {2, 0x0da0d748}, - {3, 0x116ec325}, - {4, 0x116ec444}, - {5, 0x115eb717}, -}; -/* Define the size of the map. */ -#define NODES_IN_MAP 5 - -uint32_t get_mote_suffix(int rank) { - if(--rank >=0 && rank<(sizeof(motes_addrs)/sizeof(struct id_to_addrs))) { - return motes_addrs[rank].addr; - } - return 0; -} - -int get_mote_id(uint32_t suffix) { -#if IN_COOJA - return suffix & 0xff; -#else - int i; - for(i=0; i<(sizeof(motes_addrs)/sizeof(struct id_to_addrs)); i++) { - if(suffix == motes_addrs[i].addr) { - return motes_addrs[i].id; - } - } - return 0; -#endif -} - -void set_global_address(void) { - uip_ipaddr_t ipaddr; - - uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); - uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); - uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); -} - -static void add_route_ext(int dest, int next) { - PRINTF("add route ext %d %d\n", dest, next); - uip_ipaddr_t ipaddr_dest, ipaddr_next; - uip_ip6addr(&ipaddr_dest, 0xaaaa, 0, 0, 0, 0, 0, 0, dest); -#if IN_COOJA - uip_ip6addr(&ipaddr_next, 0xfe80, 0, 0, 0, 0x0212, 0x7400 | next, next, next<<8 | next); -#else - uint32_t next_suffix = get_mote_suffix(next); - uip_ip6addr(&ipaddr_next, 0xfe80, 0, 0, 0, 0x0212, 0x7400, (next_suffix >> 16) & 0xffff, next_suffix & 0xffff); -#endif - uip_ds6_route_add(&ipaddr_dest, 128, &ipaddr_next, 0); -} - -void add_route(int dest, int next) { - PRINTF("add route %d %d\n", dest, next); - uip_ipaddr_t ipaddr_dest, ipaddr_next; -#if IN_COOJA - uip_ip6addr(&ipaddr_dest, 0xaaaa, 0, 0, 0, 0x0212, 0x7400 | dest, dest, dest<<8 | dest); - uip_ip6addr(&ipaddr_next, 0xfe80, 0, 0, 0, 0x0212, 0x7400 | next, next, next<<8 | next); -#else - uint32_t dest_suffix = get_mote_suffix(dest); - uint32_t next_suffix = get_mote_suffix(next); - uip_ip6addr(&ipaddr_dest, 0xaaaa, 0, 0, 0, 0x0212, 0x7400, (dest_suffix >> 16) & 0xffff, dest_suffix & 0xffff); - uip_ip6addr(&ipaddr_next, 0xfe80, 0, 0, 0, 0x0212, 0x7400, (next_suffix >> 16) & 0xffff, next_suffix & 0xffff); -#endif - uip_ds6_route_add(&ipaddr_dest, 128, &ipaddr_next, 0); -} - -void configure_routing(void) { - int i; -#if IN_COOJA - node_rank = node_id; -#else - node_rank = -1; - for(i=0; i<(sizeof(motes_addrs)/sizeof(struct id_to_addrs)); ++i) { - if(node_id == motes_addrs[i].id) { - node_rank = i+1; - break; - } - } - - if(node_rank == -1) { - printf("unable to configure routing, node_id=%d\n", node_id); - return; - } -#endif - - printf("configure_routing, node_id=%d, node_rank %d\n", node_id, node_rank); - - if (node_rank == 1) { /* border router #1 */ - add_route_ext(2, 2); - for(i=2; i<=NODES_IN_MAP; ++i) { - add_route(i, 2); - } - } else if (node_rank < NODES_IN_MAP) { /* other node */ - add_route_ext(1, node_rank-1); - add_route_ext(2, node_rank+1); - for(i=1; i<=NODES_IN_MAP; ++i) { - if(inode_rank) { - add_route(i, node_rank+1); - } - } - } else if (node_rank == NODES_IN_MAP) { /* 2nd border router */ - add_route_ext(1, NODES_IN_MAP-1); - for(i=1; i<=NODES_IN_MAP-1; ++i) { - add_route(i, NODES_IN_MAP-1); - } - } -} diff --git a/examples/er-rest-example/static-routing.h b/examples/er-rest-example/static-routing.h deleted file mode 100644 index 0dff0b7ba..000000000 --- a/examples/er-rest-example/static-routing.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * static-routing.h - * - * Created on: Oct 12, 2010 - * Author: simonduq - */ - -#ifndef STATICROUTING_H_ -#define STATICROUTING_H_ - -#include "contiki.h" - -extern int node_rank; -extern uint32_t get_mote_suffix(int id); -extern int get_mote_id(uint32_t suffix); -extern void add_route(int dest, int next); -extern void set_global_address(void); -extern void configure_routing(void); - -#endif /* STATICROUTING_H_ */ From bad066abadbc2cb4d383ba79beef6cca67acf258 Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 19 Jun 2013 15:17:14 +0200 Subject: [PATCH 6/9] Fixed RPL configuration according to core changes. --- examples/er-rest-example/Makefile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/er-rest-example/Makefile b/examples/er-rest-example/Makefile index ece492af8..171228ca3 100644 --- a/examples/er-rest-example/Makefile +++ b/examples/er-rest-example/Makefile @@ -11,20 +11,17 @@ WITH_COAP=13 WITH_UIP6=1 # for some platforms UIP_CONF_IPV6=1 -# temporary bugfix for Makefile.include / Makefile.uip -CFLAGS += -DUIP_CONF_IPV6=1 CONTIKI=../.. CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" # variable for Makefile.include ifneq ($(TARGET), minimal-net) -UIP_CONF_RPL=1 +CFLAGS += -DUIP_CONF_IPV6_RPL=1 else # minimal-net does not support RPL under Linux and is mostly used to test CoAP only ${info INFO: compiling without RPL} -UIP_CONF_RPL=0 -CFLAGS += -DUIP_CONF_ND6_DEF_MAXDADNS=0 +CFLAGS += -DUIP_CONF_IPV6_RPL=0 CFLAGS += -DHARD_CODED_ADDRESS=\"fdfd::10\" ${info INFO: compiling with large buffers} CFLAGS += -DUIP_CONF_BUFFER_SIZE=2048 From 75b958bb03d9eaa1ac5000b64836f41c1cec2e1d Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 19 Jun 2013 15:17:45 +0200 Subject: [PATCH 7/9] Added CoAP ping support. --- apps/er-coap-13/er-coap-13-engine.c | 18 +++++++++++++++--- apps/er-coap-13/er-coap-13.h | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/apps/er-coap-13/er-coap-13-engine.c b/apps/er-coap-13/er-coap-13-engine.c index c3f783ba5..9bde8b7f7 100644 --- a/apps/er-coap-13/er-coap-13-engine.c +++ b/apps/er-coap-13/er-coap-13-engine.c @@ -220,9 +220,14 @@ coap_receive(void) else { /* Responses */ - - if (message->type==COAP_TYPE_ACK) + if (message->type==COAP_TYPE_CON && message->code==0) { + PRINTF("Received Ping\n"); + coap_error_code = PING_RESPONSE; + } + else if (message->type==COAP_TYPE_ACK) + { + /* Transactions are closed through lookup below */ PRINTF("Received ACK\n"); } else if (message->type==COAP_TYPE_RST) @@ -261,6 +266,8 @@ coap_receive(void) } else { + coap_message_type_t reply_type = COAP_TYPE_ACK; + PRINTF("ERROR %u: %s\n", coap_error_code, coap_error_message); coap_clear_transaction(transaction); @@ -269,8 +276,13 @@ coap_receive(void) { coap_error_code = INTERNAL_SERVER_ERROR_5_00; } + if (coap_error_code == PING_RESPONSE) + { + coap_error_code = 0; + reply_type = COAP_TYPE_RST; + } /* Reuse input buffer for error message. */ - coap_init_message(message, COAP_TYPE_ACK, coap_error_code, message->mid); + coap_init_message(message, reply_type, coap_error_code, message->mid); coap_set_payload(message, coap_error_message, strlen(coap_error_message)); coap_send_message(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport, uip_appdata, coap_serialize_message(message, uip_appdata)); } diff --git a/apps/er-coap-13/er-coap-13.h b/apps/er-coap-13/er-coap-13.h index 0d3e60c89..aed0707f9 100644 --- a/apps/er-coap-13/er-coap-13.h +++ b/apps/er-coap-13/er-coap-13.h @@ -153,7 +153,8 @@ typedef enum { PACKET_SERIALIZATION_ERROR, /* Erbium hooks */ - MANUAL_RESPONSE + MANUAL_RESPONSE, + PING_RESPONSE } coap_status_t; From a8653f1a7021da3e1b71542b887df40e7f9bc505 Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 19 Jun 2013 15:59:45 +0200 Subject: [PATCH 8/9] Fixed stimer issues due to core changes for older Erbium versions. --- apps/er-coap-03/er-coap-03-observing.h | 1 + apps/er-coap-07/er-coap-07-observing.h | 1 + apps/er-coap-12/er-coap-12-observing.h | 1 + 3 files changed, 3 insertions(+) diff --git a/apps/er-coap-03/er-coap-03-observing.h b/apps/er-coap-03/er-coap-03-observing.h index cde1974ae..b9baad377 100644 --- a/apps/er-coap-03/er-coap-03-observing.h +++ b/apps/er-coap-03/er-coap-03-observing.h @@ -39,6 +39,7 @@ #ifndef COAP_OBSERVING_H_ #define COAP_OBSERVING_H_ +#include "sys/stimer.h" #include "er-coap-03.h" #include "er-coap-03-transactions.h" diff --git a/apps/er-coap-07/er-coap-07-observing.h b/apps/er-coap-07/er-coap-07-observing.h index 62f9f7df4..2fecdaf02 100644 --- a/apps/er-coap-07/er-coap-07-observing.h +++ b/apps/er-coap-07/er-coap-07-observing.h @@ -39,6 +39,7 @@ #ifndef COAP_OBSERVING_H_ #define COAP_OBSERVING_H_ +#include "sys/stimer.h" #include "er-coap-07.h" #include "er-coap-07-transactions.h" diff --git a/apps/er-coap-12/er-coap-12-observing.h b/apps/er-coap-12/er-coap-12-observing.h index 349a0fc4f..78aa64d05 100644 --- a/apps/er-coap-12/er-coap-12-observing.h +++ b/apps/er-coap-12/er-coap-12-observing.h @@ -39,6 +39,7 @@ #ifndef COAP_OBSERVING_H_ #define COAP_OBSERVING_H_ +#include "sys/stimer.h" #include "er-coap-12.h" #include "er-coap-12-transactions.h" From 9b56ffefa547d8c01f0927269f00f9efd9235c6a Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 19 Jun 2013 16:03:49 +0200 Subject: [PATCH 9/9] Fixed broken/unclear Ipv6 configuration with CFLAG. --- examples/er-rest-example/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/er-rest-example/Makefile b/examples/er-rest-example/Makefile index 171228ca3..0eac1a4e4 100644 --- a/examples/er-rest-example/Makefile +++ b/examples/er-rest-example/Makefile @@ -11,6 +11,8 @@ WITH_COAP=13 WITH_UIP6=1 # for some platforms UIP_CONF_IPV6=1 +# IPv6 make config disappeared completely +CFLAGS += -DUIP_CONF_IPV6=1 CONTIKI=../.. CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"