Fix udp-client example, now using NETSTACK_ROUTING
@@ -45,6 +45,7 @@ PROCESS_THREAD(udp_client_process, ev, data)
{
static struct etimer periodic_timer;
static unsigned count;
+ uip_ipaddr_t dest_ipaddr;
PROCESS_BEGIN();
@@ -56,13 +57,10 @@ PROCESS_THREAD(udp_client_process, ev, data)
while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
- if(rpl_is_reachable()) {
+ if(NETSTACK_ROUTING.node_is_reachable() && NETSTACK_ROUTING.get_root_ipaddr(&dest_ipaddr)) {
/* Send to DAG root */
- rpl_dag_t *dag = rpl_get_any_dag();
- if(dag != NULL) { /* Only a sanity check. Should never be NULL
- as rpl_is_reachable() is true */
LOG_INFO("Sending request %u to ", count);
- LOG_INFO_6ADDR(&dag->dag_id);
+ LOG_INFO_6ADDR(&dest_ipaddr);
LOG_INFO_("\n");
/* Set the number of transmissions to use for this packet -
this can be used to create more reliable transmissions or
@@ -70,11 +68,10 @@ PROCESS_THREAD(udp_client_process, ev, data)
UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS is set to 1.
*/
uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, 1 + count % 5);
- simple_udp_sendto(&udp_conn, &count, sizeof(count), &dag->dag_id);
+ simple_udp_sendto(&udp_conn, &count, sizeof(count), &dest_ipaddr);
count++;
- }
} else {
- LOG_INFO("Not reachable yet %p\n", rpl_get_any_dag());
+ LOG_INFO("Not reachable yet\n");
}
/* Add some jitter */
