Skip to content

Commit 942d8e7

Browse files
Diagnostic TLV added (ARMmbed#1854)
Tlv DIAGCOP_TLV_MAX_CHILD_TIMEOUT added.
1 parent f2b38cf commit 942d8e7

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

nanostack/thread_diagcop_lib.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
#define DIAGCOP_TLV_SUPPLY_VOLTAGE 15 /**< Can not reset*/
5656
#define DIAGCOP_TLV_CHILD_TABLE 16 /**< Can not reset*/
5757
#define DIAGCOP_TLV_CHANNEL_PAGES 17 /**< Can not reset*/
58-
#define DIAGCOP_TLV_TYPE_LIST 18 /**< List type*/
58+
#define DIAGCOP_TLV_TYPE_LIST 18 /**< Cannot reset*/
59+
#define DIAGCOP_TLV_MAX_CHILD_TIMEOUT 19 /**< Cannot reset*/
5960

6061
/**
6162
* \brief Write array TLV.

source/6LoWPAN/Thread/thread_diagnostic.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ static uint8_t *thread_diagnostic_get_build(protocol_interface_info_entry_t *cur
254254
uint8_t *ptr;
255255
int written_address_count = 0;
256256
uint16_t ipv6_address_count = 0;
257+
uint32_t max_child_timeout = 0;
257258
uint8_t extended_address[8] = {0};
258259

259260
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
352353
response_ptr = thread_diagcop_tlv_data_write_uint8(response_ptr, DIAGCOP_TLV_CHANNEL_PAGES, 0);
353354
break;
354355

356+
case DIAGCOP_TLV_MAX_CHILD_TIMEOUT:
357+
if (thread_router_bootstrap_child_max_timeout_get(cur, &max_child_timeout) == 0) {
358+
response_ptr = thread_diagcop_tlv_data_write_uint32(response_ptr, DIAGCOP_TLV_MAX_CHILD_TIMEOUT, max_child_timeout);
359+
}
360+
break;
361+
355362
default:
356363

357364
break;

source/6LoWPAN/Thread/thread_router_bootstrap.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,32 @@ static int mle_attach_child_id_response_build(protocol_interface_info_entry_t *c
11961196

11971197

11981198
}
1199+
1200+
int thread_router_bootstrap_child_max_timeout_get(protocol_interface_info_entry_t *cur, uint32_t *max_child_timeout)
1201+
{
1202+
uint16_t router_address = thread_info(cur)->routerShortAddress;
1203+
uint32_t max_timeout = 0;
1204+
if (router_address >= 0xfffe) {
1205+
router_address = mac_helper_mac16_address_get(cur);
1206+
}
1207+
if (router_address & THREAD_CHILD_MASK) {
1208+
return -1; //I am child
1209+
}
1210+
if (router_address >= 0xfffe) {
1211+
return -1;
1212+
}
1213+
mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list;
1214+
1215+
ns_list_foreach(mac_neighbor_table_entry_t, cur_entry, mac_table_list) {
1216+
if (thread_router_addr_from_addr(cur_entry->mac16) == router_address &&
1217+
!cur_entry->ffd_device && cur_entry->lifetime > max_timeout) {
1218+
max_timeout = cur_entry->lifetime;
1219+
}
1220+
}
1221+
*max_child_timeout = max_timeout;
1222+
return 0;
1223+
}
1224+
11991225
uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t *cur)
12001226
{
12011227
uint16_t child_count = 0;

source/6LoWPAN/Thread/thread_router_bootstrap.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ int thread_router_bootstrap_mle_advertise(struct protocol_interface_info_entry *
5252
void thread_router_bootstrap_child_information_clear(protocol_interface_info_entry_t *cur);
5353
int thread_router_bootstrap_reset_child_info(protocol_interface_info_entry_t *cur, struct mac_neighbor_table_entry *child);
5454
uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t *cur);
55+
56+
// max_child_timeout is longest MLE Timeout a router has registered for all of its active MTD children
57+
int thread_router_bootstrap_child_max_timeout_get(protocol_interface_info_entry_t *cur, uint32_t *max_child_timeout);
5558
void thread_router_bootstrap_child_id_handler(struct protocol_interface_info_entry *cur);
5659
void thread_router_bootstrap_child_id_reject(struct protocol_interface_info_entry *cur);
5760
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_
8184

8285
#define thread_router_bootstrap_child_information_clear(cur)
8386
#define thread_router_bootstrap_child_count_get(cur) 0
87+
#define thread_router_bootstrap_child_max_timeout_get(cur, max_child_timeout) 0
8488
#define thread_router_bootstrap_child_id_handler(cur)
8589
#define thread_router_bootstrap_child_id_reject(cur)
8690
#define thread_router_bootstrap_router_id_request(cur, status)

0 commit comments

Comments
 (0)