Fix udp-client example, now using NETSTACK_ROUTING

This commit is contained in:
Simon Duquennoy 2017-12-10 12:17:42 -08:00
parent 5f4ad6d657
commit 0fc93b6d37

View File

@ -45,6 +45,7 @@ PROCESS_THREAD(udp_client_process, ev, data)
{ {
static struct etimer periodic_timer; static struct etimer periodic_timer;
static unsigned count; static unsigned count;
uip_ipaddr_t dest_ipaddr;
PROCESS_BEGIN(); PROCESS_BEGIN();
@ -56,25 +57,21 @@ PROCESS_THREAD(udp_client_process, ev, data)
while(1) { while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer)); 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 */ /* Send to DAG root */
rpl_dag_t *dag = rpl_get_any_dag(); LOG_INFO("Sending request %u to ", count);
if(dag != NULL) { /* Only a sanity check. Should never be NULL LOG_INFO_6ADDR(&dest_ipaddr);
as rpl_is_reachable() is true */ LOG_INFO_("\n");
LOG_INFO("Sending request %u to ", count); /* Set the number of transmissions to use for this packet -
LOG_INFO_6ADDR(&dag->dag_id); this can be used to create more reliable transmissions or
LOG_INFO_("\n"); less reliable than the default. Works end-to-end if
/* Set the number of transmissions to use for this packet - UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS is set to 1.
this can be used to create more reliable transmissions or */
less reliable than the default. Works end-to-end if uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, 1 + count % 5);
UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS is set to 1. simple_udp_sendto(&udp_conn, &count, sizeof(count), &dest_ipaddr);
*/ count++;
uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, 1 + count % 5);
simple_udp_sendto(&udp_conn, &count, sizeof(count), &dag->dag_id);
count++;
}
} else { } else {
LOG_INFO("Not reachable yet %p\n", rpl_get_any_dag()); LOG_INFO("Not reachable yet\n");
} }
/* Add some jitter */ /* Add some jitter */