fixed rpl-udp example
This commit is contained in:
parent
a2eec4c985
commit
0a3b890080
@ -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 {
|
||||
|
@ -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 */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
Loading…
Reference in New Issue
Block a user