Skip to content

Commit 28108e1

Browse files
author
Mika
committed
Added device min sensitivity setting and stack information
New API function created to set the DEVICE_MIN_SENSE Added Configuration override to the network stack Modified the neighbor class to support automatic and static modes
1 parent 7060c70 commit 28108e1

File tree

11 files changed

+68
-6
lines changed

11 files changed

+68
-6
lines changed

nanostack/ws_management_api.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ typedef struct ws_stack_info {
113113
uint8_t rsl_out;
114114
/** parent RSSI in measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
115115
uint8_t rsl_in;
116+
/** Device RF minimum sensitivity configuration. lowest level of radio signal strength packet heard. Range of -174 (0) to +80 (254) dBm*/
117+
uint8_t device_min_sens;
116118
/** ETX To border router */
117119
uint16_t routing_cost;
118120
/** Network PAN ID */
@@ -615,6 +617,30 @@ int ws_stack_info_get(
615617
int8_t interface_id,
616618
ws_stack_info_t *info_ptr);
617619

620+
/**
621+
* Set minimum RF sensitivity acceptable for the parent selection
622+
*
623+
* Set radio signal minimum sensitivity level acceptable for parent selection.
624+
* Range of -174 (0) to +80 (254) dBm.
625+
*
626+
* If device_min_sens is set to 0 then automatic adjustment is done by the stack.
627+
*
628+
* Setting a value that is not suitable for Radio might prevent the device joining to the network.
629+
*
630+
* NOTE: Currently lower EAPOL parents are accepted if there is no parents higher than
631+
* DEVICE_MIN_SENS + CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERESIS
632+
* NOTE: Currently not using this value to limit parents as it is only RECOMENDED in specification.
633+
*
634+
* \param interface_id Network interface ID.
635+
* \param device_min_sens value used in the parent selections.
636+
*
637+
* \return 0 Success.
638+
* \return <0 Failure.
639+
*/
640+
int ws_device_min_sens_set(
641+
int8_t interface_id,
642+
uint8_t device_min_sens);
643+
618644
#ifdef __cplusplus
619645
}
620646
#endif

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3576,6 +3576,7 @@ int ws_bootstrap_get_info(protocol_interface_info_entry_t *cur, struct ws_stack_
35763576
info_ptr->rsl_out = ws_neighbour->rsl_out;
35773577
info_ptr->routing_cost = ws_neighbour->routing_cost;
35783578
}
3579+
info_ptr->device_min_sens = DEVICE_MIN_SENS;
35793580
if (ws_bootstrap_state_discovery(cur)) {
35803581
info_ptr->join_state = 1;
35813582
} else if (ws_bootstrap_state_authenticate(cur)) {

source/6LoWPAN/ws/ws_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ typedef struct ws_info_s {
8383
uint8_t rpl_state; // state from rpl_event_t
8484
uint8_t pas_requests; // Amount of PAN solicits sent
8585
uint8_t eapol_tx_index;
86+
uint8_t device_min_sens; // Device min sensitivity set by the application
8687
parent_info_t parent_info[WS_PARENT_LIST_SIZE];
8788
parent_info_list_t parent_list_free;
8889
parent_info_list_t parent_list_reserved;

source/6LoWPAN/ws/ws_empty_functions.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,13 @@ int ws_stack_info_get(int8_t interface_id, ws_stack_info_t *info_ptr)
413413
return -1;
414414
}
415415

416+
int ws_device_min_sens_set(
417+
int8_t interface_id,
418+
uint8_t device_min_sens)
419+
{
420+
(void) interface_id;
421+
(void) device_min_sens;
422+
return -1;
423+
}
424+
416425
#endif // no HAVE_WS

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,8 @@ static void ws_llc_data_indication_cb(const mac_api_t *api, const mcps_data_ind_
724724
neighbor_info.ws_neighbor->unicast_data_rx = true;
725725
}
726726

727-
// Calculate RSL for all UDATA packages heard
727+
// Calculate RSL for all UDATA packets heard
728+
ws_neighbor_class_rf_sensitivity_calculate(interface->ws_info->device_min_sens, data->signal_dbm);
728729
ws_neighbor_class_rsl_in_calculate(neighbor_info.ws_neighbor, data->signal_dbm);
729730

730731
if (neighbor_info.neighbor) {

source/6LoWPAN/ws/ws_management_api.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,4 +741,18 @@ int ws_stack_info_get(int8_t interface_id, ws_stack_info_t *info_ptr)
741741
return ws_bootstrap_get_info(cur, info_ptr);
742742
}
743743

744+
int ws_device_min_sens_set(
745+
int8_t interface_id,
746+
uint8_t device_min_sens)
747+
{
748+
protocol_interface_info_entry_t *cur;
749+
cur = protocol_stack_interface_info_get_by_id(interface_id);
750+
if (!cur || !ws_info(cur)) {
751+
return -1;
752+
}
753+
DEVICE_MIN_SENS = device_min_sens;
754+
ws_info(cur)->device_min_sens = device_min_sens;
755+
return 0;
756+
}
757+
744758
#endif // HAVE_WS

source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,13 @@ void ws_neighbor_class_neighbor_broadcast_schedule_set(ws_neighbor_class_entry_t
281281
ws_neighbor->fhss_data.bc_timing_info.broadcast_schedule_id = ws_bs_ie->broadcast_schedule_identifier;
282282
}
283283

284-
void ws_neighbor_class_rf_sensitivity_calculate(uint8_t rsl_heard)
284+
void ws_neighbor_class_rf_sensitivity_calculate(uint8_t dev_min_sens_config, int8_t dbm_heard)
285285
{
286+
if (dev_min_sens_config != 0) {
287+
// Automatic mode disabled
288+
return;
289+
}
290+
uint8_t rsl_heard = ws_neighbor_class_rsl_from_dbm_calculate(dbm_heard);
286291
if (DEVICE_MIN_SENS > rsl_heard) {
287292
// We are hearing packet with lower than min_sens dynamically learn the sensitivity
288293
DEVICE_MIN_SENS = rsl_heard;
@@ -321,8 +326,6 @@ static void ws_neighbor_class_parent_set_analyze(ws_neighbor_class_entry_t *ws_n
321326
void ws_neighbor_class_rsl_in_calculate(ws_neighbor_class_entry_t *ws_neighbor, int8_t dbm_heard)
322327
{
323328
uint8_t rsl = ws_neighbor_class_rsl_from_dbm_calculate(dbm_heard);
324-
// Calculate minimum sensitivity from heard packets.
325-
ws_neighbor_class_rf_sensitivity_calculate(rsl);
326329
if (ws_neighbor->rsl_in == RSL_UNITITIALIZED) {
327330
ws_neighbor->rsl_in = rsl << WS_RSL_SCALING;
328331
}

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void ws_neighbor_class_neighbor_broadcast_schedule_set(ws_neighbor_class_entry_t
146146
* \param rsl_heard; rsl_heard heard from Radio
147147
*
148148
*/
149-
void ws_neighbor_class_rf_sensitivity_calculate(uint8_t rsl_heard);
149+
void ws_neighbor_class_rf_sensitivity_calculate(uint8_t dev_min_sens_config, int8_t dbm_heard);
150150

151151
/**
152152
* ws_neighbor_class_rsl_from_dbm_calculate

test/nanostack/unittest/6LoWPAN/ws_llc_data_service/test_ws_llc_data_service.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "6LoWPAN/ws/ws_llc.h"
3434
#include "6LoWPAN/ws/ws_mpx_header.h"
3535
#include "6LoWPAN/ws/ws_neighbor_class.h"
36+
#include "6LoWPAN/ws/ws_common.h"
3637
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
3738
#include "nsdynmemLIB_stub.h"
3839
#include "mac_ie_lib_stub.h"
@@ -52,6 +53,8 @@ static mcps_data_confirm_ext *data_confirmation_cb;
5253

5354
static protocol_interface_info_entry_t interface;
5455

56+
static ws_info_t ws_info;
57+
5558
static arm_15_4_mac_parameters_t mac_parameters;
5659

5760

@@ -142,8 +145,10 @@ static void interface_api_init(mac_api_t *api)
142145
{
143146
memset(&interface, 0, sizeof(protocol_interface_info_entry_t));
144147
memset(&mac_parameters, 0, sizeof(arm_15_4_mac_parameters_t));
148+
memset(&ws_info, 0, sizeof(ws_info_t));
145149
interface.mac_api = api;
146150
interface.mac_parameters = &mac_parameters;
151+
interface.ws_info = &ws_info;
147152
api->mcps_purge_req = &test_mcps_purge_request;
148153
api->mcps_data_req_ext = &test_mcps_data_request_ext;
149154
api->mac_mcps_extension_enable = &test_mac_api_enable_mcps_ext;

test/nanostack/unittest/stub/ws_common_stub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
ws_common_stub_def ws_common_stub;
3131

32+
uint8_t DEVICE_MIN_SENS = 174 - 93;
33+
3234
void ws_common_network_size_configure(protocol_interface_info_entry_t *cur, uint16_t network_size)
3335
{
3436
(void) cur;

test/nanostack/unittest/stub/ws_neighbour_class_stub.c

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

9292
}
93-
void ws_neighbor_class_rf_sensitivity_calculate(uint8_t rsl_heard)
93+
void ws_neighbor_class_rf_sensitivity_calculate(uint8_t dev_min_sens_config, int8_t dbm_heard)
9494
{
9595

9696
}

0 commit comments

Comments
 (0)