From 89e0ae0904866d700d4f1def64ab638763c0e752 Mon Sep 17 00:00:00 2001 From: Jarkko Paso Date: Tue, 1 Sep 2020 09:23:27 +0300 Subject: [PATCH] WS: Restart auto CCA threshold after discovery (#2435) --- source/6LoWPAN/ws/ws_bootstrap.c | 10 ++++++++++ source/6LoWPAN/ws/ws_common.h | 1 + source/6LoWPAN/ws/ws_common_defines.h | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/6LoWPAN/ws/ws_bootstrap.c b/source/6LoWPAN/ws/ws_bootstrap.c index 670679385bea..a1a490709f55 100644 --- a/source/6LoWPAN/ws/ws_bootstrap.c +++ b/source/6LoWPAN/ws/ws_bootstrap.c @@ -1639,6 +1639,10 @@ bool ws_bootstrap_validate_channel_function(ws_us_ie_t *ws_us, ws_bs_ie_t *ws_bs static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, const struct mcps_data_ind_s *data, const struct mcps_data_ie_list *ie_ext, uint8_t message_type) { + // Store weakest heard packet RSSI + if (cur->ws_info->weakest_received_rssi > data->signal_dbm) { + cur->ws_info->weakest_received_rssi = data->signal_dbm; + } if (data->SrcAddrMode != MAC_ADDR_MODE_64_BIT) { // Not from long address @@ -2654,6 +2658,7 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur) cur->nwk_nd_re_scan_count = 0; cur->ws_info->configuration_learned = false; cur->ws_info->pan_timeout_timer = 0; + cur->ws_info->weakest_received_rssi = 0; // Clear learned neighbours ws_bootstrap_neighbor_list_clean(cur); @@ -3415,6 +3420,11 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur) cur->ws_info->trickle_pcs_running = false; cur->ws_info->trickle_pc_consistency_block_period = 0; ws_fhss_configure(cur, false); + int8_t new_default = cur->ws_info->weakest_received_rssi - 1; + if ((new_default < CCA_DEFAULT_DBM) && (new_default >= CCA_LOW_LIMIT) && (new_default <= CCA_HIGH_LIMIT)) { + // Restart automatic CCA threshold using weakest received RSSI as new default + mac_helper_start_auto_cca_threshold(cur->id, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->weakest_received_rssi - 1, CCA_HIGH_LIMIT, CCA_LOW_LIMIT); + } ws_bootstrap_start_authentication(cur); break; case ER_RPL_SCAN: diff --git a/source/6LoWPAN/ws/ws_common.h b/source/6LoWPAN/ws/ws_common.h index 784da50ee1bd..96a425c1308c 100644 --- a/source/6LoWPAN/ws/ws_common.h +++ b/source/6LoWPAN/ws/ws_common.h @@ -84,6 +84,7 @@ typedef struct ws_info_s { uint8_t pas_requests; // Amount of PAN solicits sent uint8_t eapol_tx_index; uint8_t device_min_sens; // Device min sensitivity set by the application + int8_t weakest_received_rssi; // Weakest received signal (dBm) parent_info_t parent_info[WS_PARENT_LIST_SIZE]; parent_info_list_t parent_list_free; parent_info_list_t parent_list_reserved; diff --git a/source/6LoWPAN/ws/ws_common_defines.h b/source/6LoWPAN/ws/ws_common_defines.h index 461bee679f94..58f570f8715f 100644 --- a/source/6LoWPAN/ws/ws_common_defines.h +++ b/source/6LoWPAN/ws/ws_common_defines.h @@ -332,7 +332,7 @@ typedef struct ws_bs_ie { /* * Automatic CCA threshold: default threshold and range in dBm. */ -#define CCA_DEFAULT_DBM -100 +#define CCA_DEFAULT_DBM -60 #define CCA_HIGH_LIMIT -60 #define CCA_LOW_LIMIT -100