52#define LOG_MODULE "coap"
53#define LOG_LEVEL LOG_LEVEL_COAP
71 coap_status_code = SERVICE_UNAVAILABLE_5_03;
72#if COAP_MESSAGE_ON_ERROR
73 coap_error_message =
"AlreadyInUse";
93 coap_transaction_t *
const t = coap_get_transaction_by_mid(coap_req->mid);
95 LOG_DBG(
"Separate ACCEPT: /");
96 LOG_DBG_COAP_STRING(coap_req->uri_path, coap_req->uri_path_len);
97 LOG_DBG_(
" MID %u\n", coap_req->mid);
100 if(coap_req->type == COAP_TYPE_CON) {
101 coap_message_t ack[1];
102 const coap_endpoint_t *ep;
104 ep = coap_get_src_endpoint(coap_req);
106 LOG_ERR(
"ERROR: no endpoint in request\n");
109 coap_init_message(ack, COAP_TYPE_ACK, 0, coap_req->mid);
120 separate_store->type =
121 coap_req->type == COAP_TYPE_CON ? COAP_TYPE_CON : COAP_TYPE_NON;
122 separate_store->mid = coap_get_mid();
124 memcpy(separate_store->token, coap_req->token, coap_req->token_len);
125 separate_store->token_len = coap_req->token_len;
127 separate_store->block1_num = coap_req->block1_num;
128 separate_store->block1_size = coap_req->block1_size;
130 separate_store->block2_num = coap_req->block2_num;
131 separate_store->block2_size = coap_req->block2_size > 0 ? MIN(COAP_MAX_BLOCK_SIZE, coap_req->block2_size) : COAP_MAX_BLOCK_SIZE;
134 coap_status_code = MANUAL_RESPONSE;
136 LOG_ERR(
"ERROR: Response transaction for separate request not found!\n");
137 coap_status_code = INTERNAL_SERVER_ERROR_5_00;
142coap_separate_resume(coap_message_t *response, coap_separate_t *separate_store,
145 coap_init_message(response, separate_store->type, code,
146 separate_store->mid);
147 if(separate_store->token_len) {
148 coap_set_token(response, separate_store->token,
149 separate_store->token_len);
151 if(separate_store->block1_size) {
152 coap_set_header_block1(response, separate_store->block1_num,
153 0, separate_store->block1_size);
Default definitions of C compiler quirk work-arounds.
CoAP module for separate responses.
CoAP module for reliable transport.
An implementation of the Constrained Application Protocol (RFC 7252).
uint8_t * coap_databuf(void)
Returns a common data buffer that can be used when generating CoAP messages for transmission.
int coap_sendto(const coap_endpoint_t *ep, const uint8_t *data, uint16_t len)
Send a message to the specified CoAP endpoint.
void coap_endpoint_copy(coap_endpoint_t *dest, const coap_endpoint_t *src)
Copy a CoAP endpoint from one memory area to another.
void coap_separate_accept(coap_message_t *coap_req, coap_separate_t *separate_store)
Initiate a separate response with an empty ACK.
void coap_separate_reject()
Reject a request that would require a separate response with an error message.