minor fixes to the simulation files
This commit is contained in:
parent
4246a8fbe6
commit
baa8f3c6f5
|
@ -10,6 +10,7 @@ static struct http_socket s;
|
||||||
static int bytes_received = 0;
|
static int bytes_received = 0;
|
||||||
static int restarts;
|
static int restarts;
|
||||||
static struct ctimer reconnect_timer;
|
static struct ctimer reconnect_timer;
|
||||||
|
static int connect = 0;
|
||||||
|
|
||||||
static void callback(struct http_socket *s, void *ptr,
|
static void callback(struct http_socket *s, void *ptr,
|
||||||
http_socket_event_t e,
|
http_socket_event_t e,
|
||||||
|
@ -22,9 +23,9 @@ AUTOSTART_PROCESSES(&http_example_process);
|
||||||
static void
|
static void
|
||||||
reconnect(void *dummy)
|
reconnect(void *dummy)
|
||||||
{
|
{
|
||||||
|
printf("#A color=orange\n");
|
||||||
rpl_set_mode(RPL_MODE_MESH);
|
rpl_set_mode(RPL_MODE_MESH);
|
||||||
http_socket_get(&s, "http://www.contiki-os.org/", 0, 0,
|
connect = 1;
|
||||||
callback, NULL);
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
|
@ -33,6 +34,8 @@ restart(void)
|
||||||
int scale;
|
int scale;
|
||||||
restarts++;
|
restarts++;
|
||||||
printf("restart %d\n", restarts);
|
printf("restart %d\n", restarts);
|
||||||
|
rpl_set_mode(RPL_MODE_FEATHER);
|
||||||
|
printf("#A color=red\n");
|
||||||
|
|
||||||
scale = restarts;
|
scale = restarts;
|
||||||
if(scale > 5) {
|
if(scale > 5) {
|
||||||
|
@ -62,6 +65,7 @@ callback(struct http_socket *s, void *ptr,
|
||||||
if(bytes_received > 0) {
|
if(bytes_received > 0) {
|
||||||
printf("HTTP socket closed, %d bytes received\n", bytes_received);
|
printf("HTTP socket closed, %d bytes received\n", bytes_received);
|
||||||
leds_off(LEDS_RED);
|
leds_off(LEDS_RED);
|
||||||
|
printf("#A color=blue\n");
|
||||||
rpl_set_mode(RPL_MODE_FEATHER);
|
rpl_set_mode(RPL_MODE_FEATHER);
|
||||||
} else {
|
} else {
|
||||||
restart();
|
restart();
|
||||||
|
@ -72,6 +76,7 @@ callback(struct http_socket *s, void *ptr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
PROCESS_THREAD(http_example_process, ev, data)
|
PROCESS_THREAD(http_example_process, ev, data)
|
||||||
{
|
{
|
||||||
static struct etimer et;
|
static struct etimer et;
|
||||||
|
@ -88,14 +93,19 @@ PROCESS_THREAD(http_example_process, ev, data)
|
||||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||||
|
|
||||||
http_socket_init(&s);
|
http_socket_init(&s);
|
||||||
http_socket_get(&s, "http://www.contiki-os.org/", 0, 0,
|
connect = 1;
|
||||||
callback, NULL);
|
|
||||||
leds_on(LEDS_RED);
|
leds_on(LEDS_RED);
|
||||||
restarts = 0;
|
restarts = 0;
|
||||||
etimer_set(&et, CLOCK_SECOND);
|
etimer_set(&et, CLOCK_SECOND * 5);
|
||||||
while(1) {
|
while(1) {
|
||||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||||
etimer_reset(&et);
|
etimer_reset(&et);
|
||||||
|
if(connect && rpl_has_downward_link()) {
|
||||||
|
printf("#A color=green\n");
|
||||||
|
http_socket_get(&s, "http://www.contiki-os.org/", 0, 0,
|
||||||
|
callback, NULL);
|
||||||
|
connect = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
|
|
|
@ -3,13 +3,23 @@
|
||||||
#include "ip64.h"
|
#include "ip64.h"
|
||||||
#include "net/netstack.h"
|
#include "net/netstack.h"
|
||||||
#include "net/rpl/rpl-dag-root.h"
|
#include "net/rpl/rpl-dag-root.h"
|
||||||
|
#include "net/rpl/rpl.h"
|
||||||
|
#include "net/ipv6/uip-ds6-route.h"
|
||||||
|
#include <stdio.h>
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
PROCESS(router_node_process, "Router node");
|
PROCESS(router_node_process, "Router node");
|
||||||
AUTOSTART_PROCESSES(&router_node_process);
|
AUTOSTART_PROCESSES(&router_node_process);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
uip_lladdr_t * uip_ds6_route_nexthop_lladdr(uip_ds6_route_t *route);
|
||||||
|
|
||||||
|
|
||||||
PROCESS_THREAD(router_node_process, ev, data)
|
PROCESS_THREAD(router_node_process, ev, data)
|
||||||
{
|
{
|
||||||
|
uip_ipaddr_t *nexthop = NULL;
|
||||||
|
uip_ds6_defrt_t *defrt;
|
||||||
|
uip_ipaddr_t *ipaddr;
|
||||||
|
uip_ds6_route_t *r;
|
||||||
|
static struct etimer et;
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
/* Set us up as a RPL root node. */
|
/* Set us up as a RPL root node. */
|
||||||
|
@ -18,9 +28,41 @@ PROCESS_THREAD(router_node_process, ev, data)
|
||||||
/* Initialize the IP64 module so we'll start translating packets */
|
/* Initialize the IP64 module so we'll start translating packets */
|
||||||
ip64_init();
|
ip64_init();
|
||||||
|
|
||||||
|
/* etimer_set(&et, CLOCK_SECOND * 60); */
|
||||||
|
/* PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); */
|
||||||
|
|
||||||
/* ... and do nothing more. */
|
/* ... and do nothing more. */
|
||||||
while(1) {
|
while(1) {
|
||||||
PROCESS_WAIT_EVENT();
|
etimer_set(&et, CLOCK_SECOND * 20);
|
||||||
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||||
|
|
||||||
|
defrt = NULL;
|
||||||
|
if((ipaddr = uip_ds6_defrt_choose()) != NULL) {
|
||||||
|
defrt = uip_ds6_defrt_lookup(ipaddr);
|
||||||
|
}
|
||||||
|
if(defrt != NULL) {
|
||||||
|
printf("DefRT: :: -> %02d", defrt->ipaddr.u8[15]);
|
||||||
|
printf(" lt:%lu inf:%d\n", stimer_remaining(&defrt->lifetime),
|
||||||
|
defrt->isinfinite);
|
||||||
|
} else {
|
||||||
|
printf("DefRT: :: -> NULL\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(uip_ds6_route_head() != NULL) {
|
||||||
|
printf("found head\n");
|
||||||
|
for(r = uip_ds6_route_head();
|
||||||
|
r != NULL;
|
||||||
|
r = uip_ds6_route_next(r)) {
|
||||||
|
nexthop = uip_ds6_route_nexthop(r);
|
||||||
|
if(nexthop != NULL) {
|
||||||
|
printf("Route: %02d -> %02d", r->ipaddr.u8[15], nexthop->u8[15]);
|
||||||
|
} else {
|
||||||
|
//printf("Route: %p %02d -> ? nbr-routes:%p", r, r->ipaddr.u8[15],
|
||||||
|
//r->neighbor_routes);
|
||||||
|
}
|
||||||
|
printf(" lt:%lu\n", r->state.lifetime);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
|
|
Loading…
Reference in a new issue