From 722b6e0b965b32a6f9209e5529dddf9f96278ec4 Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Thu, 1 Sep 2011 09:19:26 +0200 Subject: [PATCH] Print out sender IPv6 address when receiving data. When sending data, include a counter in the message. --- examples/ipv6/simple-udp-rpl/unicast-receiver.c | 4 +++- examples/ipv6/simple-udp-rpl/unicast-sender.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/ipv6/simple-udp-rpl/unicast-receiver.c b/examples/ipv6/simple-udp-rpl/unicast-receiver.c index f7541b007..69ba6f943 100644 --- a/examples/ipv6/simple-udp-rpl/unicast-receiver.c +++ b/examples/ipv6/simple-udp-rpl/unicast-receiver.c @@ -67,7 +67,9 @@ receiver(struct simple_udp_connection *c, const uint8_t *data, uint16_t datalen) { - printf("Data received on port %d from port %d with length %d: '%s'\n", + printf("Data received from "); + uip_debug_ipaddr_print(sender_addr); + printf(" on port %d from port %d with length %d: '%s'\n", receiver_port, sender_port, datalen, data); } /*---------------------------------------------------------------------------*/ diff --git a/examples/ipv6/simple-udp-rpl/unicast-sender.c b/examples/ipv6/simple-udp-rpl/unicast-sender.c index ce90e7b1c..c984b12d5 100644 --- a/examples/ipv6/simple-udp-rpl/unicast-sender.c +++ b/examples/ipv6/simple-udp-rpl/unicast-sender.c @@ -118,12 +118,14 @@ PROCESS_THREAD(unicast_sender_process, ev, data) PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer)); addr = servreg_hack_lookup(SERVICE_ID); if(addr != NULL) { + static unsigned int message_number; char buf[20]; printf("Sending unicast to "); uip_debug_ipaddr_print(addr); printf("\n"); - sprintf(buf, "From %d", node_id); + sprintf(buf, "Message %d", message_number); + message_number++; simple_udp_sendto(&unicast_connection, buf, strlen(buf) + 1, addr); } else { printf("Service %d not found\n", SERVICE_ID);