added back more textual representation of messages in rpl-udp example - good for debugging LLSEC encryption

This commit is contained in:
Joakim Eriksson 2018-10-20 22:27:02 +02:00
parent c42fae82da
commit 3542fa8d85
2 changed files with 12 additions and 7 deletions

View File

@ -32,8 +32,7 @@ udp_rx_callback(struct simple_udp_connection *c,
const uint8_t *data,
uint16_t datalen)
{
unsigned count = *(unsigned *)data;
LOG_INFO("Received response %u from ", count);
LOG_INFO("Received response '%s' from ", (char *) data);
LOG_INFO_6ADDR(sender_addr);
LOG_INFO_("\n");
}
@ -42,6 +41,7 @@ PROCESS_THREAD(udp_client_process, ev, data)
{
static struct etimer periodic_timer;
static unsigned count;
static char str[32];
uip_ipaddr_t dest_ipaddr;
PROCESS_BEGIN();
@ -59,7 +59,8 @@ PROCESS_THREAD(udp_client_process, ev, data)
LOG_INFO("Sending request %u to ", count);
LOG_INFO_6ADDR(&dest_ipaddr);
LOG_INFO_("\n");
simple_udp_sendto(&udp_conn, &count, sizeof(count), &dest_ipaddr);
snprintf(str, sizeof(str), "hello from the client:%d", count);
simple_udp_sendto(&udp_conn, str, strlen(str), &dest_ipaddr);
count++;
} else {
LOG_INFO("Not reachable yet\n");

View File

@ -54,15 +54,19 @@ udp_rx_callback(struct simple_udp_connection *c,
const uint8_t *data,
uint16_t datalen)
{
unsigned count = *(unsigned *)data;
LOG_INFO("Received request %u from ", count);
char *str = (char *)data;
char outstr[32];
LOG_INFO("Received request '%s' from ", str);
LOG_INFO_6ADDR(sender_addr);
LOG_INFO_("\n");
#if WITH_SERVER_REPLY
LOG_INFO("Sending response %u to ", count);
/* 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, &count, sizeof(count), sender_addr);
simple_udp_sendto(&udp_conn, outstr, strlen(outstr), sender_addr);
#endif /* WITH_SERVER_REPLY */
}
/*---------------------------------------------------------------------------*/