Skip to content

Commit 6acee47

Browse files
author
Mika Tervonen
committed
modified RSL calculation and value in messaging
DEVICE_MIN_SENS is changed to uint8_t and value given as -174 to 80 dbm RSL_IE write is now given as uint8 Separated function to validate min sensitivity if default is incorrect Added RSL from DBm calculation function Removed the extra EAPOL wait if links are not above treshold
1 parent ee7f218 commit 6acee47

File tree

10 files changed

+55
-35
lines changed

10 files changed

+55
-35
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -910,13 +910,13 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
910910
if (memcmp(cur->ws_info->parent_info.addr, ADDR_UNSPECIFIED, 8) != 0) {
911911

912912
// if we dont have higher than threshold signal only signal level decides parent
913-
if (ws_neighbor_class_rssi_from_dbm_calculate(cur->ws_info->parent_info.signal_dbm) < (CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS) &&
914-
ws_neighbor_class_rssi_from_dbm_calculate(data->signal_dbm) > ws_neighbor_class_rssi_from_dbm_calculate(cur->ws_info->parent_info.signal_dbm)) {
913+
if (ws_neighbor_class_rsl_from_dbm_calculate(cur->ws_info->parent_info.signal_dbm) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS) &&
914+
ws_neighbor_class_rsl_from_dbm_calculate(data->signal_dbm) > ws_neighbor_class_rsl_from_dbm_calculate(cur->ws_info->parent_info.signal_dbm)) {
915915
// automatically select the best quality link from the below threshold
916916
goto parent_selected;
917917
}
918918
// Drop if signal quality is not good enough
919-
if (ws_neighbor_class_rssi_from_dbm_calculate(data->signal_dbm) < (CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
919+
if (ws_neighbor_class_rsl_from_dbm_calculate(data->signal_dbm) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
920920
tr_info("EAPOL target dropped Link quality too low");
921921
return;
922922
}
@@ -935,14 +935,6 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
935935
tr_info("EAPOL target dropped Lower link quality %u < %u current", data->signal_dbm, cur->ws_info->parent_info.signal_dbm);
936936
return;
937937
}
938-
939-
} else {
940-
// First advertise heard
941-
942-
if (ws_neighbor_class_rssi_from_dbm_calculate(data->signal_dbm) < (CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
943-
// First neighbor is too low we need to wait one extra trickle
944-
cur->bootsrap_state_machine_cnt += cur->ws_info->trickle_params_pan_discovery.Imin + randLIB_get_8bit() % 50;
945-
}
946938
}
947939

948940
parent_selected:

source/6LoWPAN/ws/ws_common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
#ifdef HAVE_WS
3636
#define TRACE_GROUP "wscm"
3737

38-
int8_t DEVICE_MIN_SENS = -93;
38+
// estimated sensitivity -93 dbm converted to Wi-SUN RSL range
39+
// This provides a range of -174 (0) to +80 (254) dBm
40+
uint8_t DEVICE_MIN_SENS = 174 - 93;
3941

4042
#define TRICKLE_IMIN_60_SECS (60 * 10)
4143
#define TRICKLE_IMIN_30_SECS (30 * 10)

source/6LoWPAN/ws/ws_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
*
6969
* Default value for us is -93
7070
*/
71-
extern int8_t DEVICE_MIN_SENS;
71+
extern uint8_t DEVICE_MIN_SENS;
7272

7373
/* Candidate parent Threshold
7474
*/

source/6LoWPAN/ws/ws_ie_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ uint8_t *ws_wh_fc_write(uint8_t *ptr, uint8_t flow_ctrl)
111111
return ptr;
112112
}
113113

114-
uint8_t *ws_wh_rsl_write(uint8_t *ptr, int8_t rssi)
114+
uint8_t *ws_wh_rsl_write(uint8_t *ptr, uint8_t rsl)
115115
{
116116
ptr = ws_wh_header_base_write(ptr, 1, WH_IE_RSL_TYPE);
117-
*ptr++ = rssi;
117+
*ptr++ = rsl;
118118
return ptr;
119119
}
120120

source/6LoWPAN/ws/ws_ie_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef struct ws_wp_network_name {
3636
uint8_t *ws_wh_utt_write(uint8_t *ptr, uint8_t message_type);
3737
uint8_t *ws_wh_bt_write(uint8_t *ptr);
3838
uint8_t *ws_wh_fc_write(uint8_t *ptr, uint8_t flow_ctrl);
39-
uint8_t *ws_wh_rsl_write(uint8_t *ptr, int8_t rssi);
39+
uint8_t *ws_wh_rsl_write(uint8_t *ptr, uint8_t rsl);
4040
uint8_t *ws_wh_vh_write(uint8_t *ptr, uint8_t *vendor_header, uint8_t vendor_header_length);
4141
uint8_t *ws_wh_ea_write(uint8_t *ptr, uint8_t *eui64);
4242

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,7 @@ static void ws_llc_ack_data_req_ext(const mac_api_t *api, mcps_ack_data_payload_
463463
//Write Data to block
464464
uint8_t *ptr = base->ws_enhanced_ack_elements;
465465
ptr = ws_wh_utt_write(ptr, WS_FT_ACK);
466-
uint8_t rsl = ws_neighbor_class_rssi_from_dbm_calculate(rssi);
467-
ws_wh_rsl_write(ptr, rsl);
466+
ws_wh_rsl_write(ptr, ws_neighbor_class_rsl_from_dbm_calculate(rssi));
468467
}
469468

470469
/** WS LLC MAC data extension indication */

source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,22 @@ void ws_neighbor_class_neighbor_broadcast_schedule_set(ws_neighbor_class_entry_t
134134
ws_neighbor->fhss_data.bc_timing_info.broadcast_schedule_id = ws_bs_ie->broadcast_schedule_identifier;
135135
}
136136

137-
uint8_t ws_neighbor_class_rssi_from_dbm_calculate(int8_t dbm_heard)
137+
void ws_neighbor_class_rf_sensitivity_calculate(uint8_t rsl_heard)
138138
{
139-
if (DEVICE_MIN_SENS > dbm_heard) {
139+
if (DEVICE_MIN_SENS > rsl_heard) {
140140
// We are hearing packet with lower than min_sens dynamically learn the sensitivity
141-
DEVICE_MIN_SENS = dbm_heard;
141+
DEVICE_MIN_SENS = rsl_heard;
142142
}
143-
return dbm_heard - DEVICE_MIN_SENS;
143+
}
144+
145+
uint8_t ws_neighbor_class_rsl_from_dbm_calculate(int8_t dbm_heard)
146+
{
147+
/* RSL MUST be calculated as the received signal level relative to standard
148+
* thermal noise (290oK) at 1 Hz bandwidth or 174 dBm.
149+
* This provides a range of -174 (0) to +80 (254) dBm.
150+
*/
151+
152+
return dbm_heard + 174;
144153
}
145154

146155
static void ws_neighbor_class_parent_set_analyze(ws_neighbor_class_entry_t *ws_neighbor)
@@ -151,24 +160,26 @@ static void ws_neighbor_class_parent_set_analyze(ws_neighbor_class_entry_t *ws_n
151160
return;
152161
}
153162

154-
if (ws_neighbor_class_rsl_in_get(ws_neighbor) < (CAND_PARENT_THRESHOLD - CAND_PARENT_HYSTERISIS) &&
155-
ws_neighbor_class_rsl_out_get(ws_neighbor) < (CAND_PARENT_THRESHOLD - CAND_PARENT_HYSTERISIS)) {
163+
if (ws_neighbor_class_rsl_in_get(ws_neighbor) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD - CAND_PARENT_HYSTERISIS) &&
164+
ws_neighbor_class_rsl_out_get(ws_neighbor) < (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD - CAND_PARENT_HYSTERISIS)) {
156165
ws_neighbor->candidate_parent = false;
157166
}
158167

159-
if (ws_neighbor_class_rsl_in_get(ws_neighbor) > (CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS) &&
160-
ws_neighbor_class_rsl_out_get(ws_neighbor) > (CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
168+
if (ws_neighbor_class_rsl_in_get(ws_neighbor) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS) &&
169+
ws_neighbor_class_rsl_out_get(ws_neighbor) > (DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
161170
ws_neighbor->candidate_parent = true;
162171
}
163172
}
164173

165174
void ws_neighbor_class_rsl_in_calculate(ws_neighbor_class_entry_t *ws_neighbor, int8_t dbm_heard)
166175
{
167-
uint8_t rssi = ws_neighbor_class_rssi_from_dbm_calculate(dbm_heard);
176+
uint8_t rsl = ws_neighbor_class_rsl_from_dbm_calculate(dbm_heard);
177+
// Calculate minimum sensitivity from heard packets.
178+
ws_neighbor_class_rf_sensitivity_calculate(rsl);
168179
if (ws_neighbor->rsl_in == RSL_UNITITIALIZED) {
169-
ws_neighbor->rsl_in = rssi << WS_RSL_SCALING;
180+
ws_neighbor->rsl_in = rsl << WS_RSL_SCALING;
170181
}
171-
ws_neighbor->rsl_in = ws_neighbor->rsl_in + rssi - (ws_neighbor->rsl_in >> WS_RSL_SCALING);
182+
ws_neighbor->rsl_in = ws_neighbor->rsl_in + rsl - (ws_neighbor->rsl_in >> WS_RSL_SCALING);
172183
ws_neighbor_class_parent_set_analyze(ws_neighbor);
173184
return;
174185
}

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,26 @@ void ws_neighbor_class_neighbor_broadcast_time_info_update(ws_neighbor_class_ent
134134
void ws_neighbor_class_neighbor_broadcast_schedule_set(ws_neighbor_class_entry_t *ws_neighbor, ws_bs_ie_t *ws_bs_ie);
135135

136136
/**
137-
* ws_neighbor_class_rssi_from_dbm_calculate
137+
* ws_neighbor_class_rf_sensitivity_calculate
138138
*
139-
* Calculates rssi value from dbm heard taking into account min sensitivity of radio
140-
* dynamically adjusts min sensitivity if value is not properly set
139+
* Calculates minimum heard RSL value from all packets.
140+
* This will dynamically adjusts min sensitivity if value is not properly set
141+
*
142+
* \param rsl_heard; rsl_heard heard from Radio
143+
*
144+
*/
145+
void ws_neighbor_class_rf_sensitivity_calculate(uint8_t rsl_heard);
146+
147+
/**
148+
* ws_neighbor_class_rsl_from_dbm_calculate
149+
*
150+
* Calculates rsl value from dbm heard.
151+
* This provides a range of -174 (0) to +80 (254) dBm.
141152
*
142153
* \param dbm_heard; dbm heard from the neighbour
143154
*
144155
*/
145-
uint8_t ws_neighbor_class_rssi_from_dbm_calculate(int8_t dbm_heard);
156+
uint8_t ws_neighbor_class_rsl_from_dbm_calculate(int8_t dbm_heard);
146157

147158
/** Helper macros to read RSL values from neighbour class.
148159
*

test/nanostack/unittest/stub/ws_ie_lib_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ uint8_t *ws_wh_fc_write(uint8_t *ptr, uint8_t flow_ctrl)
6969
return ptr;
7070
}
7171

72-
uint8_t *ws_wh_rsl_write(uint8_t *ptr, int8_t rssi)
72+
uint8_t *ws_wh_rsl_write(uint8_t *ptr, uint8_t rsl)
7373
{
7474
ptr += 4;
7575
return ptr;

test/nanostack/unittest/stub/ws_neighbour_class_stub.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ void ws_neighbor_class_neighbor_broadcast_schedule_set(ws_neighbor_class_entry_t
9090
{
9191

9292
}
93-
uint8_t ws_neighbor_class_rssi_from_dbm_calculate(int8_t dbm_heard)
93+
void ws_neighbor_class_rf_sensitivity_calculate(uint8_t rsl_heard)
94+
{
95+
96+
}
97+
98+
uint8_t ws_neighbor_class_rsl_from_dbm_calculate(int8_t dbm_heard)
9499
{
95100
return 0;
96101
}

0 commit comments

Comments
 (0)