diff --git a/examples/rpl-udp/udp-client.c b/examples/rpl-udp/udp-client.c index fb13a2073..8628e834c 100644 --- a/examples/rpl-udp/udp-client.c +++ b/examples/rpl-udp/udp-client.c @@ -32,7 +32,7 @@ udp_rx_callback(struct simple_udp_connection *c, const uint8_t *data, uint16_t datalen) { - LOG_INFO("Received response '%s' from ", (char *) data); + LOG_INFO("Received response '%.*s' from ", datalen, (char *) data); LOG_INFO_6ADDR(sender_addr); LOG_INFO_("\n"); } @@ -59,7 +59,7 @@ PROCESS_THREAD(udp_client_process, ev, data) LOG_INFO("Sending request %u to ", count); LOG_INFO_6ADDR(&dest_ipaddr); LOG_INFO_("\n"); - snprintf(str, sizeof(str), "hello from the client:%d", count); + snprintf(str, sizeof(str), "hello %d", count); simple_udp_sendto(&udp_conn, str, strlen(str), &dest_ipaddr); count++; } else { diff --git a/examples/rpl-udp/udp-server.c b/examples/rpl-udp/udp-server.c index d69a97c78..072eb8ae8 100644 --- a/examples/rpl-udp/udp-server.c +++ b/examples/rpl-udp/udp-server.c @@ -54,19 +54,13 @@ udp_rx_callback(struct simple_udp_connection *c, const uint8_t *data, uint16_t datalen) { - char *str = (char *)data; - char outstr[32]; - LOG_INFO("Received request '%s' from ", str); + LOG_INFO("Received request '%.*s' from ", datalen, (char *) data); LOG_INFO_6ADDR(sender_addr); LOG_INFO_("\n"); #if WITH_SERVER_REPLY - /* send the number that came in - and is at the end */ - snprintf(outstr, sizeof(outstr), "hello from the server:%s", - &data[strlen("hello from the client:")]); - LOG_INFO("Sending response '%s' to ", outstr); - LOG_INFO_6ADDR(sender_addr); - LOG_INFO_("\n"); - simple_udp_sendto(&udp_conn, outstr, strlen(outstr), sender_addr); + /* send back the same string to the client as an echo reply */ + LOG_INFO("Sending response.\n"); + simple_udp_sendto(&udp_conn, data, datalen, sender_addr); #endif /* WITH_SERVER_REPLY */ } /*---------------------------------------------------------------------------*/