Print out sender IPv6 address when receiving data. When sending data, include a counter in the message.

This commit is contained in:
Adam Dunkels 2011-09-01 09:19:26 +02:00
parent 6220e231a2
commit 722b6e0b96
2 changed files with 6 additions and 2 deletions

View file

@ -67,7 +67,9 @@ receiver(struct simple_udp_connection *c,
const uint8_t *data, const uint8_t *data,
uint16_t datalen) 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); receiver_port, sender_port, datalen, data);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View file

@ -118,12 +118,14 @@ PROCESS_THREAD(unicast_sender_process, ev, data)
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer));
addr = servreg_hack_lookup(SERVICE_ID); addr = servreg_hack_lookup(SERVICE_ID);
if(addr != NULL) { if(addr != NULL) {
static unsigned int message_number;
char buf[20]; char buf[20];
printf("Sending unicast to "); printf("Sending unicast to ");
uip_debug_ipaddr_print(addr); uip_debug_ipaddr_print(addr);
printf("\n"); 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); simple_udp_sendto(&unicast_connection, buf, strlen(buf) + 1, addr);
} else { } else {
printf("Service %d not found\n", SERVICE_ID); printf("Service %d not found\n", SERVICE_ID);