Skip to content

Commit 590dfeb

Browse files
author
Antti Yli-Tokola
committed
Update mbed-coap to version 4.6.0
* Added new API which clears one item from the resend queue by token
1 parent ec4c33c commit 590dfeb

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

features/frameworks/mbed-coap/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [v4.6.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.6.0)
4+
**New feature:**
5+
- Add new API which clears one item from the resend queue based on token
6+
7+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v4.5.1...v4.6.0)
8+
39
## [v4.5.1](https://github.com/ARMmbed/mbed-coap/releases/tag/v4.5.1)
410
**Closed issues:**
511
- IOTCLT-2883 - Blockwise observations not completing

features/frameworks/mbed-coap/mbed-coap/sn_coap_protocol.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ extern void sn_coap_protocol_remove_sent_blockwise_message(struct coap_s *handle
224224
*/
225225
extern int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t msg_id);
226226

227+
/**
228+
* \fn void sn_coap_protocol_delete_retransmission_by_token(struct coap_s *handle)
229+
*
230+
* \param *handle Pointer to CoAP library handle
231+
* \token Token to be removed
232+
* \token_len Length of the token
233+
* \return returns 0 when success, -1 for invalid parameter, -2 if message was not found
234+
*
235+
* \brief If re-transmissions are enabled, this function removes message from retransmission buffer.
236+
*/
237+
extern int8_t sn_coap_protocol_delete_retransmission_by_token(struct coap_s *handle, uint8_t *token, uint8_t token_len);
238+
227239
/**
228240
* \fn int8_t sn_coap_convert_block_size(uint16_t block_size)
229241
*

features/frameworks/mbed-coap/module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mbed-coap",
3-
"version": "4.5.1",
3+
"version": "4.6.0",
44
"description": "COAP library",
55
"keywords": [
66
"coap",

features/frameworks/mbed-coap/source/sn_coap_protocol.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,36 @@ int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t ms
363363
return -2;
364364
}
365365

366+
int8_t sn_coap_protocol_delete_retransmission_by_token(struct coap_s *handle, uint8_t *token, uint8_t token_len)
367+
{
368+
#if ENABLE_RESENDINGS /* If Message resending is not used at all, this part of code will not be compiled */
369+
if (handle == NULL || token == NULL || token_len == 0) {
370+
tr_error("sn_coap_protocol_delete_retransmission_by_token NULL");
371+
return -1;
372+
}
373+
374+
ns_list_foreach(coap_send_msg_s, stored_msg, &handle->linked_list_resent_msgs) {
375+
uint8_t stored_token_len = (stored_msg->send_msg_ptr->packet_ptr[0] & 0x0F);
376+
if (stored_token_len == token_len) {
377+
uint8_t stored_token[8];
378+
memcpy(stored_token, &stored_msg->send_msg_ptr->packet_ptr[4], stored_token_len);
379+
if (memcmp(stored_token, token, stored_token_len) == 0) {
380+
uint16_t temp_msg_id = (stored_msg->send_msg_ptr->packet_ptr[2] << 8);
381+
temp_msg_id += (uint16_t)stored_msg->send_msg_ptr->packet_ptr[3];
382+
tr_debug("sn_coap_protocol_delete_retransmission_by_token - removed msg_id: %d", temp_msg_id);
383+
ns_list_remove(&handle->linked_list_resent_msgs, stored_msg);
384+
--handle->count_resent_msgs;
385+
386+
/* Free memory of stored message */
387+
sn_coap_protocol_release_allocated_send_msg_mem(handle, stored_msg);
388+
return 0;
389+
}
390+
}
391+
}
392+
#endif
393+
return -2;
394+
}
395+
366396

367397
int8_t prepare_blockwise_message(struct coap_s *handle, sn_coap_hdr_s *src_coap_msg_ptr)
368398
{

0 commit comments

Comments
 (0)