From cdfc788967acb543964c4a387c154f4bb1b2d9c9 Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Wed, 25 Jan 2012 06:34:10 -0800 Subject: [PATCH] Increased wait time between main loop polls; cleaned up the code to Contiki code style standards; moved process autostart code to after network setup --- platform/minimal-net/contiki-main.c | 244 +++++++++++++++------------- 1 file changed, 134 insertions(+), 110 deletions(-) diff --git a/platform/minimal-net/contiki-main.c b/platform/minimal-net/contiki-main.c index b31091900..2ab990cc8 100644 --- a/platform/minimal-net/contiki-main.c +++ b/platform/minimal-net/contiki-main.c @@ -70,53 +70,63 @@ PROCESS_THREAD(border_router_process, ev, data) PROCESS_PAUSE(); -{ rpl_dag_t *dag; - char buf[sizeof(dag_id)]; - memcpy(buf,dag_id,sizeof(dag_id)); - dag = rpl_set_root((uip_ip6addr_t *)buf); - -/* Assign separate addresses to the uip stack and the host network interface, but with the same prefix */ -/* E.g. bbbb::ff:fe00:200 to the stack and bbbb::1 to the host *fallback* network interface */ -/* Otherwise the host will trap packets intended for the stack, just as the stack will trap packets intended for the host */ -/* $ifconfig usb0 -arp on Ubuntu to skip the neighbor solicitations. Add explicit neighbors on other OSs */ - if(dag != NULL) { - printf("Created a new RPL dag\n"); + { + rpl_dag_t *dag; + char buf[sizeof(dag_id)]; + memcpy(buf,dag_id,sizeof(dag_id)); + dag = rpl_set_root((uip_ip6addr_t *)buf); + + /* Assign separate addresses to the uip stack and the host network + interface, but with the same prefix E.g. bbbb::ff:fe00:200 to + the stack and bbbb::1 to the host *fallback* network interface + Otherwise the host will trap packets intended for the stack, + just as the stack will trap packets intended for the host + $ifconfig usb0 -arp on Ubuntu to skip the neighbor + solicitations. Add explicit neighbors on other OSs */ + if(dag != NULL) { + printf("Created a new RPL dag\n"); + #if UIP_CONF_ROUTER_RECEIVE_RA -//Contiki stack will shut down until assigned an address from the interface RA -//Currently this requires changes in the core rpl-icmp6.c to pass the link-local RA broadcast - + /* Contiki stack will shut down until assigned an address from the + interface RA Currently this requires changes in the core + rpl-icmp6.c to pass the link-local RA broadcast. + */ + #else -void sprint_ip6(uip_ip6addr_t addr); - int i; - uip_ip6addr_t ipaddr; + { + static void sprint_ip6(uip_ip6addr_t addr); + int i; + uip_ip6addr_t ipaddr; #ifdef HARD_CODED_ADDRESS - uiplib_ipaddrconv(HARD_CODED_ADDRESS, &ipaddr); + uiplib_ipaddrconv(HARD_CODED_ADDRESS, &ipaddr); #else - uip_ip6addr(&ipaddr, 0xbbbb, 0, 0, 0, 0, 0, 0, 0x1); + uip_ip6addr(&ipaddr, 0xbbbb, 0, 0, 0, 0, 0, 0, 0x1); #endif - uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); - uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); - rpl_set_prefix(dag, &ipaddr, 64); + uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); + uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); + rpl_set_prefix(dag, &ipaddr, 64); - for (i=0;i 0) { - printf("%d processes in queue\n"); - }*/ tv.tv_sec = 0; - tv.tv_usec = 1; + tv.tv_usec = 1000; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); select(1, &fds, NULL, NULL, &tv);