mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-22 10:30:13 +00:00
Updated Erbium (Er) examples and removed unsupported static routing module.
This commit is contained in:
parent
5e18efa10c
commit
c61dd6135e
@ -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
|
||||
|
@ -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
|
||||
-------------
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,155 +0,0 @@
|
||||
/*
|
||||
* static-routing.c
|
||||
*
|
||||
* Created on: Oct 12, 2010
|
||||
* Author: simonduq
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "static-routing.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#include <stdio.h>
|
||||
#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(i<node_rank) {
|
||||
add_route(i, node_rank-1);
|
||||
} else if(i>node_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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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_ */
|
Loading…
Reference in New Issue
Block a user