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

Commit 28307de

Browse files
author
Mika Tervonen
committed
Randomize channel used in fixed channel
All devices randomize the fixed channel that is used Channel is set to MAC meaning devices are now on different channel Only call trickle inconsistents if timer is running Remove extra traces from llc and ETX
1 parent 51a498b commit 28307de

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ static void ws_bootstrap_pan_advertisement_analyse_active(struct protocol_interf
336336
if (pan_information->routing_cost <= cur->ws_info->pan_information.routing_cost) {
337337
trickle_consistent_heard(&cur->ws_info->trickle_pan_advertisement);
338338
} else {
339-
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery);
339+
if (trickle_running(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery)) {
340+
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery);
341+
}
340342
}
341343

342344
}
@@ -465,7 +467,9 @@ static void ws_bootstrap_pan_advertisement_solicit_analyse(struct protocol_inter
465467
* An inconsistent transmission is defined as:
466468
* A PAN Advertisement Solicit with NETNAME-IE matching that of the receiving node.
467469
*/
468-
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery);
470+
if (trickle_running(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery)) {
471+
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement,&trickle_params_pan_discovery);
472+
}
469473
/*
470474
* A consistent transmission is defined as
471475
* a PAN Advertisement Solicit with NETNAME-IE / Network Name matching that configured on the receiving node.
@@ -540,7 +544,9 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
540544
common_serial_number_greater_16(cur->ws_info->pan_information.pan_version, pan_version)) {
541545
// received version is lower se we need to reset the trickle
542546
tr_info("older pan version heard");
543-
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
547+
if (trickle_running(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery)) {
548+
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
549+
}
544550
return;
545551
}
546552
trickle_consistent_heard(&cur->ws_info->trickle_pan_config);
@@ -626,7 +632,9 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
626632
* A PAN Configuration Solicit with a PAN-ID matching that of the receiving node and
627633
* a NETNAME-IE / Network Name matching the network name configured on the receiving
628634
*/
629-
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
635+
if (trickle_running(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery)) {
636+
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
637+
}
630638
}
631639
static bool ws_bootstrap_network_found(protocol_interface_info_entry_t *cur)
632640
{
@@ -907,7 +915,7 @@ static void ws_bootstrap_fhss_activate(protocol_interface_info_entry_t *cur)
907915
tr_debug("MAC init");
908916
mac_helper_pib_boolean_set(cur, macRxOnWhenIdle, true);
909917
cur->lowpan_info &= ~INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE;
910-
ws_bootstrap_mac_activate(cur, 11, cur->ws_info->network_pan_id, true);
918+
ws_bootstrap_mac_activate(cur, cur->ws_info->hopping_schdule.fixed_channel, cur->ws_info->network_pan_id, true);
911919
return;
912920
}
913921

@@ -1032,6 +1040,7 @@ static void ws_bootstrap_network_discovery_configure(protocol_interface_info_ent
10321040
cur->ws_info->hopping_schdule.fhss_bc_dwell_interval = 200;
10331041
// By default, uses fixed channel
10341042
cur->ws_info->hopping_schdule.channel_function = WS_FIXED_CHANNEL;
1043+
cur->ws_info->hopping_schdule.fixed_channel = randLIB_get_random_in_range(11,25);
10351044

10361045
//Set Network names, Pan information configure, hopping schedule & GTKHash
10371046
ws_llc_set_network_name(cur, (uint8_t*)cur->ws_info->network_name, strlen(cur->ws_info->network_name));

source/6LoWPAN/ws/ws_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <string.h>
1818
#include "nsconfig.h"
1919
#include "ns_types.h"
20+
#include "randLIB.h"
2021
#include <ns_list.h>
2122
#include <nsdynmemLIB.h>
2223
#include "NWK_INTERFACE/Include/protocol.h"
@@ -151,6 +152,7 @@ int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur)
151152
cur->ws_info->hopping_schdule.fhss_bc_dwell_interval = 200;
152153
// By default, uses fixed channel
153154
cur->ws_info->hopping_schdule.channel_function = WS_FIXED_CHANNEL;
155+
cur->ws_info->hopping_schdule.fixed_channel = randLIB_get_random_in_range(11,25);
154156

155157
return 0;
156158
}

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
488488

489489
//Refresh Neighbor if unicast
490490
if (ws_utt.message_type == WS_FT_DATA && data->DstAddrMode && addr_check_broadcast(data->DstAddr, data->DstAddrMode)) {
491-
tr_debug("Refresh neigh index %u", neighbor_info.neighbor->index);
491+
//tr_debug("Refresh neigh index %u", neighbor_info.neighbor->index);
492492
mac_neighbor_table_neighbor_refresh(interface->mac_parameters->mac_neighbor_table, neighbor_info.neighbor, neighbor_info.neighbor->link_lifetime);
493493
etx_lqi_dbm_update(interface->id, data->mpduLinkQuality, data->signal_dbm, neighbor_info.neighbor->index);
494494
}

source/Service_Libs/etx/etx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ uint16_t etx_read(int8_t interface_id, addrtype_t addr_type, const uint8_t *addr
216216
attribute_index = neigh_table_ptr->attribute_index;
217217
}
218218

219-
tr_debug("Etx Read from atribute %u", attribute_index);
219+
//tr_debug("Etx Read from atribute %u", attribute_index);
220220

221221
etx_storage_t * entry = etx_storage_entry_get(interface_id, attribute_index);
222222

@@ -227,7 +227,7 @@ uint16_t etx_read(int8_t interface_id, addrtype_t addr_type, const uint8_t *addr
227227
uint16_t etx = etx_current_calc(entry->etx, entry->accumulated_failures);
228228
etx >>= 4;
229229

230-
tr_debug("Etx value %u", etx);
230+
//tr_debug("Etx value %u", etx);
231231

232232
return etx;
233233
}

0 commit comments

Comments
 (0)