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>
This commit is contained in:
Sandro Scherer 2025-05-09 09:33:26 +02:00 committed by Benjamin Cabé
commit b2213920f2

View file

@ -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);