diff --git a/nanostack/thread_diagcop_lib.h b/nanostack/thread_diagcop_lib.h index 48b8399d53c..cbe721f8be7 100644 --- a/nanostack/thread_diagcop_lib.h +++ b/nanostack/thread_diagcop_lib.h @@ -55,7 +55,8 @@ #define DIAGCOP_TLV_SUPPLY_VOLTAGE 15 /**< Can not reset*/ #define DIAGCOP_TLV_CHILD_TABLE 16 /**< Can not reset*/ #define DIAGCOP_TLV_CHANNEL_PAGES 17 /**< Can not reset*/ -#define DIAGCOP_TLV_TYPE_LIST 18 /**< List type*/ +#define DIAGCOP_TLV_TYPE_LIST 18 /**< Cannot reset*/ +#define DIAGCOP_TLV_MAX_CHILD_TIMEOUT 19 /**< Cannot reset*/ /** * \brief Write array TLV. diff --git a/source/6LoWPAN/Thread/thread_diagnostic.c b/source/6LoWPAN/Thread/thread_diagnostic.c index fdce83ece82..6f74c6075d2 100644 --- a/source/6LoWPAN/Thread/thread_diagnostic.c +++ b/source/6LoWPAN/Thread/thread_diagnostic.c @@ -254,6 +254,7 @@ static uint8_t *thread_diagnostic_get_build(protocol_interface_info_entry_t *cur uint8_t *ptr; int written_address_count = 0; uint16_t ipv6_address_count = 0; + uint32_t max_child_timeout = 0; uint8_t extended_address[8] = {0}; arm_net_interface_address_list_size(cur->id, &ipv6_address_count); @@ -352,6 +353,12 @@ static uint8_t *thread_diagnostic_get_build(protocol_interface_info_entry_t *cur response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_CHANNEL_PAGES, 0); break; + case DIAGCOP_TLV_MAX_CHILD_TIMEOUT: + if (thread_router_bootstrap_child_max_timeout_get(cur, &max_child_timeout) == 0) { + response_ptr = thread_diagcop_tlv_data_write_uint32(response_ptr, DIAGCOP_TLV_MAX_CHILD_TIMEOUT, max_child_timeout); + } + break; + default: break; diff --git a/source/6LoWPAN/Thread/thread_router_bootstrap.c b/source/6LoWPAN/Thread/thread_router_bootstrap.c index 0a4a2741168..4c061ce934d 100644 --- a/source/6LoWPAN/Thread/thread_router_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_router_bootstrap.c @@ -1196,6 +1196,32 @@ static int mle_attach_child_id_response_build(protocol_interface_info_entry_t *c } + +int thread_router_bootstrap_child_max_timeout_get(protocol_interface_info_entry_t *cur, uint32_t *max_child_timeout) +{ + uint16_t router_address = thread_info(cur)->routerShortAddress; + uint32_t max_timeout = 0; + if (router_address >= 0xfffe) { + router_address = mac_helper_mac16_address_get(cur); + } + if (router_address & THREAD_CHILD_MASK) { + return -1; //I am child + } + if (router_address >= 0xfffe) { + return -1; + } + mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list; + + ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, mac_table_list) { + if (thread_router_addr_from_addr(cur_entry->mac16) == router_address && + !cur_entry->ffd_device && cur_entry->lifetime > max_timeout) { + max_timeout = cur_entry->lifetime; + } + } + *max_child_timeout = max_timeout; + return 0; +} + uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t *cur) { uint16_t child_count = 0; diff --git a/source/6LoWPAN/Thread/thread_router_bootstrap.h b/source/6LoWPAN/Thread/thread_router_bootstrap.h index 0143ce1e30c..5ab9f3fa087 100644 --- a/source/6LoWPAN/Thread/thread_router_bootstrap.h +++ b/source/6LoWPAN/Thread/thread_router_bootstrap.h @@ -52,6 +52,9 @@ int thread_router_bootstrap_mle_advertise(struct protocol_interface_info_entry * void thread_router_bootstrap_child_information_clear(protocol_interface_info_entry_t *cur); int thread_router_bootstrap_reset_child_info(protocol_interface_info_entry_t *cur, struct mac_neighbor_table_entry *child); uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t *cur); + +// max_child_timeout is longest MLE Timeout a router has registered for all of its active MTD children +int thread_router_bootstrap_child_max_timeout_get(protocol_interface_info_entry_t *cur, uint32_t *max_child_timeout); void thread_router_bootstrap_child_id_handler(struct protocol_interface_info_entry *cur); void thread_router_bootstrap_child_id_reject(struct protocol_interface_info_entry *cur); void thread_router_bootstrap_router_id_request(struct protocol_interface_info_entry *cur, uint8_t status); @@ -81,6 +84,7 @@ void thread_router_bootstrap_address_change_notify_send(protocol_interface_info_ #define thread_router_bootstrap_child_information_clear(cur) #define thread_router_bootstrap_child_count_get(cur) 0 +#define thread_router_bootstrap_child_max_timeout_get(cur, max_child_timeout) 0 #define thread_router_bootstrap_child_id_handler(cur) #define thread_router_bootstrap_child_id_reject(cur) #define thread_router_bootstrap_router_id_request(cur, status)