mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
nanocoap_sock: support handling empty ACKs with separate response
This commit is contained in:
parent
0284aa5146
commit
084f0287a3
@ -251,6 +251,14 @@ extern "C" {
|
||||
#define CONFIG_COAP_RANDOM_FACTOR_1000 (1500)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Timeout in milliseconds for a separate (deferred) response
|
||||
* sent after an empty ACK.
|
||||
*/
|
||||
#ifndef CONFIG_COAP_SEPARATE_RESPONSE_TIMEOUT_MS
|
||||
#define CONFIG_COAP_SEPARATE_RESPONSE_TIMEOUT_MS (10 * MS_PER_SEC)
|
||||
#endif
|
||||
|
||||
/** @brief Maximum number of retransmissions for a confirmable request */
|
||||
#ifndef CONFIG_COAP_MAX_RETRANSMIT
|
||||
#define CONFIG_COAP_MAX_RETRANSMIT (4)
|
||||
|
@ -224,8 +224,17 @@ ssize_t nanocoap_sock_request_cb(nanocoap_sock_t *sock, coap_pkt_t *pkt,
|
||||
case COAP_TYPE_CON:
|
||||
_send_ack(sock, pkt);
|
||||
/* fall-through */
|
||||
case COAP_TYPE_NON:
|
||||
case COAP_TYPE_ACK:
|
||||
if (cb && coap_get_code(pkt) == COAP_CODE_EMPTY) {
|
||||
/* empty ACK, wait for separate response */
|
||||
state = STATE_RESPONSE_RCVD;
|
||||
deadline = _deadline_from_interval(CONFIG_COAP_SEPARATE_RESPONSE_TIMEOUT_MS
|
||||
* US_PER_MS);
|
||||
DEBUG("nanocoap: wait for separate response\n");
|
||||
continue;
|
||||
}
|
||||
/* fall-through */
|
||||
case COAP_TYPE_NON:
|
||||
/* call user callback */
|
||||
if (cb) {
|
||||
res = cb(arg, pkt);
|
||||
|
Loading…
Reference in New Issue
Block a user