52#define LOG_MODULE "coap"
53#define LOG_LEVEL LOG_LEVEL_COAP
71 coap_status_code = SERVICE_UNAVAILABLE_5_03;
72 coap_error_message =
"AlreadyInUse";
91 coap_transaction_t *
const t = coap_get_transaction_by_mid(coap_req->mid);
93 LOG_DBG(
"Separate ACCEPT: /");
94 LOG_DBG_COAP_STRING(coap_req->uri_path, coap_req->uri_path_len);
95 LOG_DBG_(
" MID %u\n", coap_req->mid);
98 if(coap_req->type == COAP_TYPE_CON) {
99 coap_message_t ack[1];
100 const coap_endpoint_t *ep;
102 ep = coap_get_src_endpoint(coap_req);
104 LOG_ERR(
"ERROR: no endpoint in request\n");
107 coap_init_message(ack, COAP_TYPE_ACK, 0, coap_req->mid);
118 separate_store->type =
119 coap_req->type == COAP_TYPE_CON ? COAP_TYPE_CON : COAP_TYPE_NON;
120 separate_store->mid = coap_get_mid();
122 memcpy(separate_store->token, coap_req->token, coap_req->token_len);
123 separate_store->token_len = coap_req->token_len;
125 separate_store->block1_num = coap_req->block1_num;
126 separate_store->block1_size = coap_req->block1_size;
128 separate_store->block2_num = coap_req->block2_num;
129 separate_store->block2_size = coap_req->block2_size > 0 ? MIN(COAP_MAX_BLOCK_SIZE, coap_req->block2_size) : COAP_MAX_BLOCK_SIZE;
132 coap_status_code = MANUAL_RESPONSE;
134 LOG_ERR(
"ERROR: Response transaction for separate request not found!\n");
135 coap_status_code = INTERNAL_SERVER_ERROR_5_00;
140coap_separate_resume(coap_message_t *response, coap_separate_t *separate_store,
143 coap_init_message(response, separate_store->type, code,
144 separate_store->mid);
145 if(separate_store->token_len) {
146 coap_set_token(response, separate_store->token,
147 separate_store->token_len);
149 if(separate_store->block1_size) {
150 coap_set_header_block1(response, separate_store->block1_num,
151 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.