Skip to content

Commit 6a4b5cd

Browse files
pdgendthenrikbrixandersen
authored andcommitted
net: lib: coap: Add packet pointer to client response callback data
Pass a pointer to the CoAP packet in the response data. This allows callback function to inspect for CoAP options. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent cbef867 commit 6a4b5cd

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

include/zephyr/net/coap_client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ struct coap_client_response_data {
4141
* @ref coap_response_code for positive.
4242
*/
4343
int16_t result_code;
44+
/** A pointer to the response CoAP packet. NULL for error result. */
45+
const struct coap_packet *packet;
4446
/** Payload offset from the beginning of a blockwise transfer. */
4547
size_t offset;
4648
/** Buffer containing the payload from the response. NULL for empty payload. */

subsys/net/lib/coap/coap_client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ static int handle_response(struct coap_client *client, const struct coap_packet
956956
if (!atomic_set(&internal_req->in_callback, 1)) {
957957
const struct coap_client_response_data resp_data = {
958958
.result_code = response_code,
959+
.packet = response,
959960
.offset = internal_req->offset,
960961
.payload = payload,
961962
.payload_len = payload_len,

0 commit comments

Comments
 (0)