Merge pull request #539 from carlosgp143/contrib/coap-send-feedback

Feedback in CoAP send request
This commit is contained in:
Simon Duquennoy 2018-05-24 13:08:19 +02:00 committed by GitHub
commit 700eb851a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -65,7 +65,7 @@ static void coap_request_callback(void *callback_data, coap_message_t *response)
/*---------------------------------------------------------------------------*/
static void
static int
progress_request(coap_request_state_t *state) {
coap_message_t *request = state->request;
request->mid = coap_get_mid();
@ -83,7 +83,9 @@ progress_request(coap_request_state_t *state) {
coap_send_transaction(state->transaction);
LOG_DBG("Requested #%"PRIu32" (MID %u)\n", state->block_num, request->mid);
return 1;
}
return 0;
}
/*---------------------------------------------------------------------------*/
@ -134,7 +136,7 @@ coap_request_callback(void *callback_data, coap_message_t *response)
/*---------------------------------------------------------------------------*/
void
int
coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
coap_message_t *request,
void (*callback)(coap_request_state_t *state))
@ -151,7 +153,7 @@ coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
state->remote_endpoint = endpoint;
state->callback = callback;
progress_request(state);
return progress_request(state);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -65,7 +65,15 @@ struct coap_request_state {
void (*callback)(coap_request_state_t *state);
};
void coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
/**
* \brief Send a CoAP request to a remote endpoint
* \param state The state to handle the CoAP request
* \param endpoint The destination endpoint
* \param request The request to be sent
* \param callback callback to execute when the response arrives or the timeout expires
* \return 1 if there is a transaction available to send, 0 otherwise
*/
int coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
coap_message_t *request,
void (*callback)(coap_request_state_t *state));