52 #define LOG_MODULE "coap" 53 #define LOG_LEVEL LOG_LEVEL_COAP 70 coap_status_code = SERVICE_UNAVAILABLE_5_03;
71 coap_error_message =
"AlreadyInUse";
88 coap_transaction_t *
const t = coap_get_transaction_by_mid(coap_req->mid);
90 LOG_DBG(
"Separate ACCEPT: /");
91 LOG_DBG_COAP_STRING(coap_req->uri_path, coap_req->uri_path_len);
92 LOG_DBG_(
" MID %u\n", coap_req->mid);
95 if(coap_req->type == COAP_TYPE_CON) {
96 coap_message_t ack[1];
97 const coap_endpoint_t *ep;
99 ep = coap_get_src_endpoint(coap_req);
101 LOG_ERR(
"ERROR: no endpoint in request\n");
104 coap_init_message(ack, COAP_TYPE_ACK, 0, coap_req->mid);
115 separate_store->type =
116 coap_req->type == COAP_TYPE_CON ? COAP_TYPE_CON : COAP_TYPE_NON;
117 separate_store->mid = coap_get_mid();
119 memcpy(separate_store->token, coap_req->token, coap_req->token_len);
120 separate_store->token_len = coap_req->token_len;
122 separate_store->block1_num = coap_req->block1_num;
123 separate_store->block1_size = coap_req->block1_size;
125 separate_store->block2_num = coap_req->block2_num;
126 separate_store->block2_size = coap_req->block2_size > 0 ? MIN(COAP_MAX_BLOCK_SIZE, coap_req->block2_size) : COAP_MAX_BLOCK_SIZE;
129 coap_status_code = MANUAL_RESPONSE;
131 LOG_ERR(
"ERROR: Response transaction for separate request not found!\n");
132 coap_status_code = INTERNAL_SERVER_ERROR_5_00;
137 coap_separate_resume(coap_message_t *response, coap_separate_t *separate_store,
140 coap_init_message(response, separate_store->type, code,
141 separate_store->mid);
142 if(separate_store->token_len) {
143 coap_set_token(response, separate_store->token,
144 separate_store->token_len);
146 if(separate_store->block1_size) {
147 coap_set_header_block1(response, separate_store->block1_num,
148 0, separate_store->block1_size);
void coap_separate_accept(coap_message_t *coap_req, coap_separate_t *separate_store)
Initiate a separate response with an empty ACK.
CoAP module for separate responses.
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.
uint8_t * coap_databuf(void)
Returns a common data buffer that can be used when generating CoAP messages for transmission.
CoAP module for reliable transport
An implementation of the Constrained Application Protocol (RFC 7252).
Default definitions of C compiler quirk work-arounds.
void coap_separate_reject()
Reject a request that would require a separate response with an error message.