1 /*
2  * Copyright (c) 2024 Alexandre Bailon
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef COAP_UTILS_H
8 #define COAP_UTILS_H
9 
10 #include <zephyr/net/openthread.h>
11 #include <openthread/coap.h>
12 
13 #define COAP_MAX_BUF_SIZE   128
14 #define COAP_DEVICE_ID_SIZE 25
15 
16 typedef int (*coap_req_handler_put)(void *ctx, uint8_t *buf, int size);
17 typedef int (*coap_req_handler_get)(void *ctx, otMessage *msg, const otMessageInfo *msg_info);
18 
19 int coap_init(void);
20 int coap_req_handler(void *ctx, otMessage *msg, const otMessageInfo *msg_info,
21 		     coap_req_handler_put put_fn, coap_req_handler_get get_fn);
22 int coap_resp_send(otMessage *req, const otMessageInfo *req_info, uint8_t *buf, int len);
23 int coap_put_req_send(const char *addr, const char *uri, uint8_t *buf, int len,
24 		      otCoapResponseHandler handler, void *ctx);
25 int coap_get_req_send(const char *addr, const char *uri, uint8_t *buf, int len,
26 		      otCoapResponseHandler handler, void *ctx);
27 const char *coap_device_id(void);
28 int coap_get_data(otMessage *msg, void *buf, int *len);
29 
30 #endif /* COAP_UTILS_H */
31