Skip to content

Commit

Permalink
Diagnostic TLV added (ARMmbed#1854)
Browse files Browse the repository at this point in the history
Tlv DIAGCOP_TLV_MAX_CHILD_TIMEOUT added.
  • Loading branch information
deepakvenugopal authored Oct 9, 2018
1 parent f2b38cf commit 942d8e7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nanostack/thread_diagcop_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions source/6LoWPAN/Thread/thread_diagnostic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions source/6LoWPAN/Thread/thread_router_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions source/6LoWPAN/Thread/thread_router_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 942d8e7

Please sign in to comment.