Browse Source

doc: coap_server: fix msg size

The sizeof operator applied to a pointer to
char does not return the number of characters.
This leads to the message being cut off.
Instead we should use strlen.

Signed-off-by: Sandro Scherer <sand.scherer@gmail.com>
pull/89740/head
Sandro Scherer 2 months ago committed by Benjamin Cabé
parent
commit
b2213920f2
  1. 2
      doc/connectivity/networking/api/coap_server.rst

2
doc/connectivity/networking/api/coap_server.rst

@ -100,7 +100,7 @@ The following is an example of a CoAP resource registered with our service: @@ -100,7 +100,7 @@ The following is an example of a CoAP resource registered with our service:
/* Append payload */
coap_packet_append_payload_marker(&response);
coap_packet_append_payload(&response, (uint8_t *)msg, sizeof(msg));
coap_packet_append_payload(&response, (uint8_t *)msg, strlen(msg));
/* Send to response back to the client */
return coap_resource_send(resource, &response, addr, addr_len, NULL);

Loading…
Cancel
Save