Skip to content

Commit 2be763f

Browse files
author
Tero Heinonen
committed
Modified coap response callback, added parameters (#23)
* Modified coap response callback, added parameters for source address and source port. * version v4.0.0
1 parent eae41d1 commit 2be763f

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

coap-service/coap_service_api.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ extern "C" {
6262
* Function that handles CoAP service message receiving and parsing
6363
*
6464
* \param msg_id Id number of the current message.
65+
* \param source_address IPv6 source address.
66+
* \param source_port Source port
6567
* \param response_ptr Pointer to CoAP header structure.
6668
*
6769
* \return 0 for success / -1 for failure
6870
*/
69-
typedef int coap_service_response_recv(int8_t service_id, uint16_t msg_id, sn_coap_hdr_s *response_ptr);
71+
typedef int coap_service_response_recv(int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *response_ptr);
7072

7173
/**
7274
* \brief CoAP service request callback

module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coap-service",
3-
"version": "3.0.0",
3+
"version": "4.0.0",
44
"description": "CoAP Service library",
55
"keywords": [
66
"coap",

source/coap_message_handler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static int8_t coap_rx_function(sn_coap_hdr_s *resp_ptr, sn_nsdl_addr_s *address_
104104
this = transaction_find_client_by_token(resp_ptr->token_ptr);
105105
}
106106
if (this && this->resp_cb) {
107-
this->resp_cb(this->service_id, resp_ptr->msg_id, NULL);
107+
this->resp_cb(this->service_id, address_ptr->addr_ptr, address_ptr->port, NULL);
108108
}
109109
transaction_delete(this);
110110
return 0;
@@ -227,7 +227,7 @@ int16_t coap_message_handler_coap_msg_process(coap_msg_handler_t *handle, int8_t
227227
}
228228
tr_debug("Service %d, response received", this->service_id);
229229
if (this->resp_cb) {
230-
this->resp_cb(this->service_id, coap_message->msg_id, coap_message);
230+
this->resp_cb(this->service_id, source_addr_ptr, port, coap_message);
231231
}
232232
sn_coap_parser_release_allocated_coap_msg_mem(handle->coap, coap_message);
233233
transaction_delete(this);

source/include/coap_message_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
* \return 0 for success / -1 for failure
3636
*/
37-
typedef int coap_message_handler_response_recv(int8_t service_id, uint16_t msg_id, sn_coap_hdr_s *response_ptr);
37+
typedef int coap_message_handler_response_recv(int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *response_ptr);
3838

3939
typedef struct coap_msg_handler_s {
4040
void *(*sn_coap_service_malloc)(uint16_t);

0 commit comments

Comments
 (0)