Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 3412f4a

Browse files
author
Jarkko Paso
committed
WS bootstrap: Moved calculating and setting FHSS hop to own function
1 parent c0e8cae commit 3412f4a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,19 @@ static void ws_bootstrap_ip_stack_activate(protocol_interface_info_entry_t *cur)
973973
ws_bootstrap_ip_stack_reset(cur);
974974
}
975975

976+
static void ws_set_fhss_hop(protocol_interface_info_entry_t *cur)
977+
{
978+
uint16_t own_rank = ws_bootstrap_route_cost_calculate(cur);
979+
uint16_t rank_inc = ws_bootstrap_get_min_rank_inc(cur);
980+
if (own_rank == 0xffff || rank_inc == 0xffff) {
981+
return;
982+
}
983+
// Calculate own hop count. This method gets inaccurate when hop count increases.
984+
uint8_t own_hop = (own_rank - rank_inc) / rank_inc;
985+
ns_fhss_ws_set_hop_count(cur->ws_info->fhss_api, own_hop);
986+
}
987+
988+
976989
static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
977990
{
978991

@@ -984,14 +997,7 @@ static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
984997
if (event == RPL_EVENT_DAO_DONE) {
985998
// Trigger statemachine check
986999
cur->bootsrap_state_machine_cnt = 1;
987-
uint16_t own_rank = ws_bootstrap_route_cost_calculate(cur);
988-
uint16_t rank_inc = ws_bootstrap_get_min_rank_inc(cur);
989-
if (own_rank == 0xffff || rank_inc == 0xffff) {
990-
return;
991-
}
992-
// Calculate own hop count. This method gets inaccurate when hop count increases.
993-
uint8_t own_hop = (own_rank - rank_inc) / rank_inc;
994-
ns_fhss_ws_set_hop_count(cur->ws_info->fhss_api, own_hop);
1000+
ws_set_fhss_hop(cur);
9951001

9961002
} else if(event == RPL_EVENT_LOCAL_REPAIR_NO_MORE_DIS) {
9971003
/*

0 commit comments

Comments
 (0)