Skip to content

Commit 6eb1255

Browse files
author
Jarkko Paso
committed
FHSS: WS bootstrap to start broadcast schedule
1 parent 659a1c4 commit 6eb1255

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
513513
cur->ws_info->hopping_schdule.fhss_bc_dwell_interval = ws_bs_ie.dwell_interval;
514514

515515
cur->ws_info->hopping_schdule.channel_function = ws_bs_ie.channel_function;
516-
// TODO: Restart unicast schedule if configuration changed, start broadcast schedule (FHSS)
517-
516+
// TODO: Restart unicast schedule if configuration changed
517+
ns_fhss_ws_set_parent(cur->ws_info->fhss_api, neighbor->mac64, &ws_neighbor->fhss_data.bc_timing_info);
518518

519519
if (!cur->ws_info->configuration_learned) {
520520
// Generate own hopping schedules Follow first parent broadcast and plans and also use same unicast dwell

source/MAC/IEEE802_15_4/mac_mcps_sap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@ void mcps_sap_pd_req_queue_write(protocol_interface_rf_mac_setup_s *rf_mac_setup
15071507
if ((rf_mac_setup->macBroadcastDisabled == true) && !mac_is_ack_request_set(buffer)) {
15081508
goto push_to_queue;
15091509
}
1510-
if (rf_mac_setup->fhss_api) {
1510+
if (rf_mac_setup->fhss_api && (buffer->asynch_request == false)) {
15111511
if (rf_mac_setup->fhss_api->check_tx_conditions(rf_mac_setup->fhss_api, !mac_is_ack_request_set(buffer),
15121512
buffer->msduHandle, mac_convert_frame_type_to_fhss(buffer->fcf_dsn.frametype), buffer->mac_payload_length,
15131513
rf_mac_setup->dev_driver->phy_driver->phy_header_length, rf_mac_setup->dev_driver->phy_driver->phy_tail_length) == false) {

source/MAC/IEEE802_15_4/mac_pd_sap.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
340340
if (rf_ptr->mac_tx_result == MAC_TX_DONE) {
341341
tx_is_done = true;
342342
}
343-
rf_ptr->fhss_api->data_tx_done(rf_ptr->fhss_api, waiting_ack, tx_is_done, rf_ptr->active_pd_data_request->msduHandle);
343+
if (rf_ptr->active_pd_data_request->asynch_request == false) {
344+
rf_ptr->fhss_api->data_tx_done(rf_ptr->fhss_api, waiting_ack, tx_is_done, rf_ptr->active_pd_data_request->msduHandle);
345+
}
344346
}
345347
return 0;
346348
}

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,13 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
107107
if (!fhss_structure) {
108108
return;
109109
}
110+
// TODO: check parent broadcast timing constantly and calculate drift error
110111
if (fhss_structure->ws->is_on_bc_channel == false) {
111112
fhss_start_timer(fhss_structure, fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval*1000, fhss_broadcast_handler);
112113
fhss_structure->ws->is_on_bc_channel = true;
113114
next_channel = fhss_ws_calc_bc_channel(fhss_structure);
115+
// TODO: Randomize polling TX queue when on broadcast channel
116+
fhss_structure->callbacks.tx_poll(fhss_structure->fhss_api);
114117
} else {
115118
uint32_t timeout = (fhss_structure->ws->fhss_configuration.fhss_broadcast_interval - fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) * 1000;
116119
fhss_start_timer(fhss_structure, timeout, fhss_broadcast_handler);
@@ -252,7 +255,7 @@ static int fhss_ws_tx_handle_callback(const fhss_api_t *api, bool is_broadcast_a
252255
if (!fhss_structure) {
253256
return -1;
254257
}
255-
if (is_broadcast_addr) {
258+
if (is_broadcast_addr || (fhss_structure->ws->is_on_bc_channel == true)) {
256259
return 0;
257260
}
258261
if (fhss_structure->fhss_state == FHSS_SYNCHRONIZED) {
@@ -288,13 +291,22 @@ static int fhss_ws_tx_handle_callback(const fhss_api_t *api, bool is_broadcast_a
288291

289292
static bool fhss_ws_check_tx_conditions_callback(const fhss_api_t *api, bool is_broadcast_addr, uint8_t handle, int frame_type, uint16_t frame_length, uint8_t phy_header_length, uint8_t phy_tail_length)
290293
{
291-
(void) api;
292-
(void) is_broadcast_addr;
293294
(void) handle;
294295
(void) frame_type;
295296
(void) frame_length;
296297
(void) phy_header_length;
297298
(void) phy_tail_length;
299+
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
300+
if (!fhss_structure) {
301+
return true;
302+
}
303+
if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_FIXED_CHANNEL) {
304+
return true;
305+
}
306+
// Do not allow broadcast destination on unicast channel
307+
if (is_broadcast_addr && (fhss_structure->ws->is_on_bc_channel == false)) {
308+
return false;
309+
}
298310
return true;
299311
}
300312

@@ -421,6 +433,16 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
421433
if (!fhss_structure->ws) {
422434
return -1;
423435
}
436+
if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_FIXED_CHANNEL) {
437+
return 0;
438+
}
439+
// Start broadcast schedule when BC intervals are known
440+
if (bc_timing_info->broadcast_interval && bc_timing_info->broadcast_dwell_interval) {
441+
fhss_start_timer(fhss_structure, (bc_timing_info->broadcast_interval-bc_timing_info->broadcast_interval_offset)*1000, fhss_broadcast_handler);
442+
fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval = bc_timing_info->broadcast_dwell_interval;
443+
fhss_structure->ws->fhss_configuration.fhss_broadcast_interval = bc_timing_info->broadcast_interval;
444+
fhss_structure->ws->bc_slot = bc_timing_info->broadcast_slot;
445+
}
424446
//TODO: support multiple parents
425447
fhss_structure->ws->parent_bc_info = bc_timing_info;
426448
return 0;

0 commit comments

Comments
 (0)