Skip to content

Commit

Permalink
Merge pull request ARMmbed#1682 from ARMmbed/IOTTHD-2460
Browse files Browse the repository at this point in the history
FHSS: Do not change channel during asynch transmissions
  • Loading branch information
Jarkko Paso committed Apr 27, 2018
2 parents 03f7105 + cbdd2a9 commit e73e9b2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion source/MAC/IEEE802_15_4/mac_fhss_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ int mac_set_channel(const fhss_api_t *fhss_api, uint8_t channel_number)
if (!mac_setup) {
return -1;
}

if (mac_setup->active_pd_data_request && mac_setup->active_pd_data_request->asynch_request) {
return -1;
}
return mac_mlme_rf_channel_change(mac_setup, channel_number);
}

Expand Down
4 changes: 4 additions & 0 deletions source/MAC/IEEE802_15_4/mac_mcps_sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,10 @@ static void mac_pd_data_confirm_handle(protocol_interface_rf_mac_setup_s *rf_mac
mac_pre_build_frame_t *buffer = rf_mac_setup->active_pd_data_request;
if (mac_data_request_confirmation_finnish(rf_mac_setup, buffer) ) {
rf_mac_setup->active_pd_data_request = NULL;
if (buffer->asynch_request && rf_mac_setup->fhss_api) {
// Must return to scheduled channel after asynch process by calling TX done
rf_mac_setup->fhss_api->data_tx_done(rf_mac_setup->fhss_api, false, true, buffer->msduHandle);
}
mcps_data_confirm_handle(rf_mac_setup, buffer);
} else {
if (mcps_pd_data_request(rf_mac_setup, buffer) != 0) {
Expand Down
10 changes: 7 additions & 3 deletions source/Service_Libs/fhss/fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
if (fhss_structure->ws->is_on_bc_channel == false) {
fhss_start_timer(fhss_structure, fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval*1000, fhss_broadcast_handler);
fhss_structure->ws->is_on_bc_channel = true;
next_channel = fhss_ws_calc_bc_channel(fhss_structure);
next_channel = fhss_structure->ws->bc_channel = fhss_ws_calc_bc_channel(fhss_structure);
} else {
uint32_t timeout = (fhss_structure->ws->fhss_configuration.fhss_broadcast_interval - fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) * 1000;
fhss_start_timer(fhss_structure, timeout, fhss_broadcast_handler);
Expand Down Expand Up @@ -390,8 +390,12 @@ static void fhss_ws_data_tx_done_callback(const fhss_api_t *api, bool waiting_ac
return;
}
if ((fhss_structure->fhss_state == FHSS_SYNCHRONIZED) && (fhss_structure->ws->fhss_configuration.ws_channel_function != WS_FIXED_CHANNEL)) {
if ((waiting_ack == false) && (fhss_structure->ws->is_on_bc_channel == false)) {
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, fhss_structure->rx_channel);
if (waiting_ack == false) {
if (fhss_structure->ws->is_on_bc_channel == false) {
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, fhss_structure->rx_channel);
} else {
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, fhss_structure->ws->bc_channel);
}
}
}
// Buffer was successfully transmitted. Remove stored failure handle if exists.
Expand Down
1 change: 1 addition & 0 deletions source/Service_Libs/fhss/fhss_ws.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ typedef struct fhss_ws fhss_ws_t;

struct fhss_ws
{
uint8_t bc_channel;
uint16_t uc_slot;
uint16_t bc_slot;
bool is_on_bc_channel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ bool test_mac_set_channel()
arm_device_driver_list_s dev_driver;
phy_driver.phy_tx_done_cb = tx_done;
dev_driver.phy_driver = &phy_driver;
memset(&setup, 0, sizeof(protocol_interface_rf_mac_setup_s));
setup.fhss_api = &fhss_api;
setup.dev_driver = &dev_driver;
mac_mlme_stub.int8_value = 0;
Expand Down

0 comments on commit e73e9b2

Please sign in to comment.