Skip to content

Commit

Permalink
WS: Restart auto CCA threshold after discovery (ARMmbed#2435)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso authored Sep 1, 2020
1 parent dbb09b1 commit 89e0ae0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions source/6LoWPAN/ws/ws_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/ws/ws_common_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 89e0ae0

Please sign in to comment.