mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
nanocoap: make use of coap_request_ctx_t
This commit is contained in:
parent
0898e499fc
commit
acfab72296
@ -14,7 +14,8 @@
|
||||
#include "suit/transport/coap.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
static ssize_t _riot_board_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, void *context)
|
||||
static ssize_t _riot_board_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
|
||||
coap_request_ctx_t *context)
|
||||
{
|
||||
(void)context;
|
||||
return coap_reply_simple(pkt, COAP_CODE_205, buf, len,
|
||||
|
@ -1849,13 +1849,14 @@ ssize_t coap_tree_handler(coap_pkt_t *pkt, uint8_t *resp_buf,
|
||||
* @param[in] pkt pointer to (parsed) CoAP packet
|
||||
* @param[out] resp_buf buffer for response
|
||||
* @param[in] resp_buf_len size of response buffer
|
||||
* @param[in] context ptr to a @ref coap_resource_subtree_t instance
|
||||
* @param[in] context pointer to request context, must contain context
|
||||
* to @ref coap_resource_subtree_t instance
|
||||
*
|
||||
* @returns size of the reply packet on success
|
||||
* @returns <0 on error
|
||||
*/
|
||||
ssize_t coap_subtree_handler(coap_pkt_t *pkt, uint8_t *resp_buf,
|
||||
size_t resp_buf_len, void *context);
|
||||
size_t resp_buf_len, coap_request_ctx_t *context);
|
||||
|
||||
/**
|
||||
* @brief Convert message code (request method) into a corresponding bit field
|
||||
|
@ -426,10 +426,10 @@ ssize_t coap_handle_req(coap_pkt_t *pkt, uint8_t *resp_buf, unsigned resp_buf_le
|
||||
}
|
||||
|
||||
ssize_t coap_subtree_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
|
||||
void *context)
|
||||
coap_request_ctx_t *context)
|
||||
{
|
||||
assert(context);
|
||||
coap_resource_subtree_t *subtree = context;
|
||||
coap_resource_subtree_t *subtree = context->context;
|
||||
return coap_tree_handler(pkt, buf, len, subtree->resources,
|
||||
subtree->resources_numof);
|
||||
}
|
||||
@ -461,7 +461,11 @@ ssize_t coap_tree_handler(coap_pkt_t *pkt, uint8_t *resp_buf,
|
||||
break;
|
||||
}
|
||||
else {
|
||||
return resource->handler(pkt, resp_buf, resp_buf_len, resource->context);
|
||||
coap_request_ctx_t ctx = {
|
||||
.resource = resource,
|
||||
.context = resource->context,
|
||||
};
|
||||
return resource->handler(pkt, resp_buf, resp_buf_len, &ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1196,7 +1200,7 @@ size_t coap_blockwise_put_bytes(coap_block_slicer_t *slicer, uint8_t *bufpos,
|
||||
}
|
||||
|
||||
ssize_t coap_well_known_core_default_handler(coap_pkt_t *pkt, uint8_t *buf, \
|
||||
size_t len, void *context)
|
||||
size_t len, coap_request_ctx_t *context)
|
||||
{
|
||||
(void)context;
|
||||
coap_block_slicer_t slicer;
|
||||
|
@ -33,7 +33,7 @@
|
||||
#endif
|
||||
|
||||
static ssize_t _version_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
|
||||
void *context)
|
||||
coap_request_ctx_t *context)
|
||||
{
|
||||
(void)context;
|
||||
return coap_reply_simple(pkt, COAP_CODE_205, buf, len,
|
||||
@ -41,7 +41,7 @@ static ssize_t _version_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
|
||||
}
|
||||
|
||||
static ssize_t _trigger_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
|
||||
void *context)
|
||||
coap_request_ctx_t *context)
|
||||
{
|
||||
(void)context;
|
||||
unsigned code;
|
||||
@ -66,12 +66,12 @@ static ssize_t _trigger_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
|
||||
|
||||
#ifdef MODULE_RIOTBOOT_SLOT
|
||||
static ssize_t _slot_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len,
|
||||
void *context)
|
||||
coap_request_ctx_t *context)
|
||||
{
|
||||
/* context is passed either as NULL or 0x1 for /active or /inactive */
|
||||
char c = '0';
|
||||
|
||||
if (context) {
|
||||
if (coap_request_ctx_get_context(context)) {
|
||||
c += riotboot_slot_other();
|
||||
}
|
||||
else {
|
||||
|
@ -32,7 +32,7 @@
|
||||
/* internal value that can be read/written via CoAP */
|
||||
static uint8_t internal_value = 0;
|
||||
|
||||
static ssize_t _value_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, void *context)
|
||||
static ssize_t _value_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, coap_request_ctx_t *context)
|
||||
{
|
||||
(void) context;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user