From 5b704405fb95b79f8b1c170be4f78f35f707e859 Mon Sep 17 00:00:00 2001 From: Deepak Venugopal Date: Tue, 23 Oct 2018 09:15:05 +0200 Subject: [PATCH] announce reattach fix (#1873) Thread device attempts to reattach using parent request after hearing an announce --- source/6LoWPAN/Thread/thread_bootstrap.c | 8 +++++++- source/6LoWPAN/Thread/thread_common.c | 1 + source/6LoWPAN/Thread/thread_common.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/6LoWPAN/Thread/thread_bootstrap.c b/source/6LoWPAN/Thread/thread_bootstrap.c index eda9b0e185a..ca478837c04 100644 --- a/source/6LoWPAN/Thread/thread_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_bootstrap.c @@ -2149,6 +2149,12 @@ static bool thread_bootstrap_sync_after_reset_start(protocol_interface_info_entr uint16_t my_short_address; uint8_t parent_mac64[8]; + // link sync is allowed only once in bootstrap start and we might get here in other cases also + if (!cur->thread_info->link_sync_allowed) { + return false; + } + cur->thread_info->link_sync_allowed = false; + int link_info_err = thread_nvm_store_link_info_get(parent_mac64, &my_short_address); if ( link_info_err!= THREAD_NVM_FILE_SUCCESS) { tr_warning("thread_nvm_store_link_info_get returned %d", link_info_err); @@ -2157,7 +2163,7 @@ static bool thread_bootstrap_sync_after_reset_start(protocol_interface_info_entr link_info_err = thread_nvm_store_link_info_clear(); if ( link_info_err!= THREAD_NVM_FILE_SUCCESS) { tr_warning("thread_nvm_store_link_info_clear returned %d", link_info_err); - } + } if (thread_is_router_addr(my_short_address)) { thread_info(cur)->routerShortAddress = my_short_address; thread_dynamic_storage_build_mle_table(cur->id); diff --git a/source/6LoWPAN/Thread/thread_common.c b/source/6LoWPAN/Thread/thread_common.c index 960accb781d..8ed21dc6ad8 100644 --- a/source/6LoWPAN/Thread/thread_common.c +++ b/source/6LoWPAN/Thread/thread_common.c @@ -226,6 +226,7 @@ int8_t thread_bootstrap_up(protocol_interface_info_entry_t *cur) ret_val = nwk_6lowpan_up(cur); cur->nwk_nd_re_scan_count = 0; + cur->thread_info->link_sync_allowed = true; return ret_val; } diff --git a/source/6LoWPAN/Thread/thread_common.h b/source/6LoWPAN/Thread/thread_common.h index 80a018e213e..a98a19d09b1 100644 --- a/source/6LoWPAN/Thread/thread_common.h +++ b/source/6LoWPAN/Thread/thread_common.h @@ -328,6 +328,7 @@ typedef struct thread_info_s { bool networkDataRequested: 1; bool end_device_link_synch: 1; bool router_mc_addrs_registered: 1; + bool link_sync_allowed:1; bool leader_synced:1; // flag used by leader after restart } thread_info_t;