From 68400add4a46dae64844f64ad91b8515e186c790 Mon Sep 17 00:00:00 2001 From: Antti Yli-Tokola Date: Tue, 21 May 2019 09:30:04 +0300 Subject: [PATCH] Update mbed-coap to version 4.8.0 Make sn_coap_protocol_linked_list_duplication_info_remove API to public. User might want to delete some messages from the duplicate list. Enable support for unified client configuration. --- features/frameworks/mbed-coap/CHANGELOG.md | 6 ++ .../mbed-coap/mbed-coap/sn_coap_protocol.h | 15 ++++ .../mbed-coap/mbed-coap/sn_config.h | 8 ++ .../mbed-coap/source/sn_coap_protocol.c | 83 +++++++++---------- 4 files changed, 69 insertions(+), 43 deletions(-) diff --git a/features/frameworks/mbed-coap/CHANGELOG.md b/features/frameworks/mbed-coap/CHANGELOG.md index 4e0355bf70..faa56179a0 100644 --- a/features/frameworks/mbed-coap/CHANGELOG.md +++ b/features/frameworks/mbed-coap/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## [v4.8.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.8.0) +- Make `sn_coap_protocol_linked_list_duplication_info_remove` API to public. User might want to delete some messages from the duplicate list. +- Enable support for unified client configuration. + +-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.7.4...v4.8.0) + ## [v4.7.4](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.7.4) - Remove dependency to yotta tool diff --git a/features/frameworks/mbed-coap/mbed-coap/sn_coap_protocol.h b/features/frameworks/mbed-coap/mbed-coap/sn_coap_protocol.h index e045c78aa7..c3584cf7c8 100644 --- a/features/frameworks/mbed-coap/mbed-coap/sn_coap_protocol.h +++ b/features/frameworks/mbed-coap/mbed-coap/sn_coap_protocol.h @@ -298,6 +298,21 @@ extern void sn_coap_protocol_send_rst(struct coap_s *handle, uint16_t msg_id, sn */ extern uint16_t sn_coap_protocol_get_configured_blockwise_size(struct coap_s *handle); +/** + * \fn void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, const uint8_t *src_addr_ptr, const uint16_t port, const uint16_t msg_id); + * + * \brief Removes stored Duplication info from Linked list. + * + * \param *handle Pointer to CoAP library handle + * \param *addr_ptr is pointer to Address key to be removed + * \param port is Port key to be removed + * \param msg_id is Message ID key to be removed + */ +extern void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, + const uint8_t *src_addr_ptr, + const uint16_t port, + const uint16_t msg_id); + #endif /* SN_COAP_PROTOCOL_H_ */ #ifdef __cplusplus diff --git a/features/frameworks/mbed-coap/mbed-coap/sn_config.h b/features/frameworks/mbed-coap/mbed-coap/sn_config.h index 63652826ed..36fa59e3ba 100644 --- a/features/frameworks/mbed-coap/mbed-coap/sn_config.h +++ b/features/frameworks/mbed-coap/mbed-coap/sn_config.h @@ -21,6 +21,14 @@ #include MBED_CLIENT_USER_CONFIG_FILE #endif +#ifdef MBED_CLOUD_CLIENT_USER_CONFIG_FILE +#include MBED_CLOUD_CLIENT_USER_CONFIG_FILE +#endif + +#ifdef MBED_CLOUD_CLIENT_CONFIGURATION_ENABLED +#include "mbed-cloud-client/MbedCloudClientConfig.h" +#endif + /** * \brief Configuration options (set of defines and values) * diff --git a/features/frameworks/mbed-coap/source/sn_coap_protocol.c b/features/frameworks/mbed-coap/source/sn_coap_protocol.c index 773216bf29..9924b0e8c2 100644 --- a/features/frameworks/mbed-coap/source/sn_coap_protocol.c +++ b/features/frameworks/mbed-coap/source/sn_coap_protocol.c @@ -50,7 +50,6 @@ #if SN_COAP_DUPLICATION_MAX_MSGS_COUNT/* If Message duplication detection is not used at all, this part of code will not be compiled */ static void sn_coap_protocol_linked_list_duplication_info_store(struct coap_s *handle, sn_nsdl_addr_s *src_addr_ptr, uint16_t msg_id, void *param); static coap_duplication_info_s *sn_coap_protocol_linked_list_duplication_info_search(const struct coap_s *handle, const sn_nsdl_addr_s *scr_addr_ptr, const uint16_t msg_id); -static void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, uint8_t *scr_addr_ptr, uint16_t port, uint16_t msg_id); static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle); static bool sn_coap_protocol_update_duplicate_package_data(const struct coap_s *handle, const sn_nsdl_addr_s *dst_addr_ptr, const sn_coap_hdr_s *coap_msg_ptr, const int16_t data_size, const uint8_t *dst_packet_data_ptr); #endif @@ -1181,49 +1180,7 @@ static coap_duplication_info_s* sn_coap_protocol_linked_list_duplication_info_se return NULL; } -/**************************************************************************//** - * \fn static void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, uint8_t *addr_ptr, uint16_t port, uint16_t msg_id) - * - * \brief Removes stored Duplication info from Linked list - * - * \param *addr_ptr is pointer to Address key to be removed - * - * \param port is Port key to be removed - * - * \param msg_id is Message ID key to be removed - *****************************************************************************/ -static void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, uint8_t *addr_ptr, uint16_t port, uint16_t msg_id) -{ - /* Loop all stored duplication messages in Linked list */ - ns_list_foreach(coap_duplication_info_s, removed_duplication_info_ptr, &handle->linked_list_duplication_msgs) { - /* If message's Address is same than is searched */ - if (handle == removed_duplication_info_ptr->coap && 0 == memcmp(addr_ptr, - removed_duplication_info_ptr->address->addr_ptr, - removed_duplication_info_ptr->address->addr_len)) { - /* If message's Address prt is same than is searched */ - if (removed_duplication_info_ptr->address->port == port) { - /* If Message ID is same than is searched */ - if (removed_duplication_info_ptr->msg_id == msg_id) { - /* * * * Correct Duplication info found, remove it from Linked list * * * */ - ns_list_remove(&handle->linked_list_duplication_msgs, removed_duplication_info_ptr); - --handle->count_duplication_msgs; - - /* Free memory of stored Duplication info */ - handle->sn_coap_protocol_free(removed_duplication_info_ptr->address->addr_ptr); - removed_duplication_info_ptr->address->addr_ptr = 0; - handle->sn_coap_protocol_free(removed_duplication_info_ptr->address); - removed_duplication_info_ptr->address = 0; - handle->sn_coap_protocol_free(removed_duplication_info_ptr->packet_ptr); - removed_duplication_info_ptr->packet_ptr = 0; - handle->sn_coap_protocol_free(removed_duplication_info_ptr); - removed_duplication_info_ptr = 0; - return; - } - } - } - } -} /**************************************************************************//** * \fn static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct coap_s *handle) @@ -1255,6 +1212,46 @@ static void sn_coap_protocol_linked_list_duplication_info_remove_old_ones(struct #endif /* SN_COAP_DUPLICATION_MAX_MSGS_COUNT */ +void sn_coap_protocol_linked_list_duplication_info_remove(struct coap_s *handle, const uint8_t *scr_addr_ptr, const uint16_t port, const uint16_t msg_id) +{ +#if SN_COAP_DUPLICATION_MAX_MSGS_COUNT + /* Loop all stored duplication messages in Linked list */ + ns_list_foreach(coap_duplication_info_s, removed_duplication_info_ptr, &handle->linked_list_duplication_msgs) { + /* If message's Address is same than is searched */ + if (handle == removed_duplication_info_ptr->coap && 0 == memcmp(scr_addr_ptr, + removed_duplication_info_ptr->address->addr_ptr, + removed_duplication_info_ptr->address->addr_len)) { + /* If message's Address prt is same than is searched */ + if (removed_duplication_info_ptr->address->port == port) { + /* If Message ID is same than is searched */ + if (removed_duplication_info_ptr->msg_id == msg_id) { + /* * * * Correct Duplication info found, remove it from Linked list * * * */ + tr_info("sn_coap_protocol_linked_list_duplication_info_remove - message id %d removed", msg_id); + ns_list_remove(&handle->linked_list_duplication_msgs, removed_duplication_info_ptr); + --handle->count_duplication_msgs; + + /* Free memory of stored Duplication info */ + handle->sn_coap_protocol_free(removed_duplication_info_ptr->address->addr_ptr); + removed_duplication_info_ptr->address->addr_ptr = 0; + handle->sn_coap_protocol_free(removed_duplication_info_ptr->address); + removed_duplication_info_ptr->address = 0; + handle->sn_coap_protocol_free(removed_duplication_info_ptr->packet_ptr); + removed_duplication_info_ptr->packet_ptr = 0; + handle->sn_coap_protocol_free(removed_duplication_info_ptr); + removed_duplication_info_ptr = 0; + return; + } + } + } + } +#else + (void)handle; + (void)scr_addr_ptr; + (void)port; + (void)msg_id; +#endif //SN_COAP_DUPLICATION_MAX_MSGS_COUNT +} + #if SN_COAP_BLOCKWISE_ENABLED || SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE /**************************************************************************//** * \fn static void sn_coap_protocol_linked_list_blockwise_msg_remove(struct coap_s *handle, coap_blockwise_msg_s *removed_msg_ptr)