PROCESS_THREAD(rimeroute_process, ev, data) { static struct route_discovery_conn route_discovery_conn; rimeaddr_t *dest; PROCESS_BEGIN(); rimeroute_event = process_alloc_event(); route_discovery_open(&route_discovery_conn, CLOCK_SECOND * 10, ROUTE_DISCOVERY_CHANNEL, &route_discovery_callbacks); while(1) { PROCESS_WAIT_EVENT_UNTIL(ev == rimeroute_event); dest = data; PRINTF("discovering route to %d.%d\n", dest->u8[0], dest->u8[1]); route_discovery_discover(&route_discovery_conn, dest, PACKET_TIMEOUT); } route_discovery_close(&route_discovery_conn); PROCESS_END(); }
/*---------------------------------------------------------------------------*/ void mesh_open(struct mesh_conn *c, uint16_t channels, const struct mesh_callbacks *callbacks) { multihop_open(&c->multihop, channels, &data_callbacks); route_discovery_open(&c->route_discovery_conn, CLOCK_SECOND * 2, channels + 1, &route_discovery_callbacks); c->cb = callbacks; }
/*---------------------------------------------------------------------------*/ void uip_over_mesh_init(uint16_t channels) { PRINTF("Our address is %d.%d (%d.%d.%d.%d)\n", linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1], uip_hostaddr.u8[0], uip_hostaddr.u8[1], uip_hostaddr.u8[2], uip_hostaddr.u8[3]); unicast_open(&dataconn, channels, &data_callbacks); route_discovery_open(&route_discovery, ROUTE_DISCOVERY_INTERVAL, channels + 1, &rdc); trickle_open(&gateway_announce_conn, ROUTE_TRICKLE_INTERVAL, channels + 3, &trickle_call); route_init(); /* Set lifetime to 30 seconds for non-refreshed routes. */ route_set_lifetime(30); }