Skip to content

Commit e73e9b2

Browse files
author
Jarkko Paso
authored
Merge pull request ARMmbed#1682 from ARMmbed/IOTTHD-2460
FHSS: Do not change channel during asynch transmissions
2 parents 03f7105 + cbdd2a9 commit e73e9b2

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

source/MAC/IEEE802_15_4/mac_fhss_callbacks.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ int mac_set_channel(const fhss_api_t *fhss_api, uint8_t channel_number)
6666
if (!mac_setup) {
6767
return -1;
6868
}
69-
69+
if (mac_setup->active_pd_data_request && mac_setup->active_pd_data_request->asynch_request) {
70+
return -1;
71+
}
7072
return mac_mlme_rf_channel_change(mac_setup, channel_number);
7173
}
7274

source/MAC/IEEE802_15_4/mac_mcps_sap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,10 @@ static void mac_pd_data_confirm_handle(protocol_interface_rf_mac_setup_s *rf_mac
10531053
mac_pre_build_frame_t *buffer = rf_mac_setup->active_pd_data_request;
10541054
if (mac_data_request_confirmation_finnish(rf_mac_setup, buffer) ) {
10551055
rf_mac_setup->active_pd_data_request = NULL;
1056+
if (buffer->asynch_request && rf_mac_setup->fhss_api) {
1057+
// Must return to scheduled channel after asynch process by calling TX done
1058+
rf_mac_setup->fhss_api->data_tx_done(rf_mac_setup->fhss_api, false, true, buffer->msduHandle);
1059+
}
10561060
mcps_data_confirm_handle(rf_mac_setup, buffer);
10571061
} else {
10581062
if (mcps_pd_data_request(rf_mac_setup, buffer) != 0) {

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
115115
if (fhss_structure->ws->is_on_bc_channel == false) {
116116
fhss_start_timer(fhss_structure, fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval*1000, fhss_broadcast_handler);
117117
fhss_structure->ws->is_on_bc_channel = true;
118-
next_channel = fhss_ws_calc_bc_channel(fhss_structure);
118+
next_channel = fhss_structure->ws->bc_channel = fhss_ws_calc_bc_channel(fhss_structure);
119119
} else {
120120
uint32_t timeout = (fhss_structure->ws->fhss_configuration.fhss_broadcast_interval - fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) * 1000;
121121
fhss_start_timer(fhss_structure, timeout, fhss_broadcast_handler);
@@ -390,8 +390,12 @@ static void fhss_ws_data_tx_done_callback(const fhss_api_t *api, bool waiting_ac
390390
return;
391391
}
392392
if ((fhss_structure->fhss_state == FHSS_SYNCHRONIZED) && (fhss_structure->ws->fhss_configuration.ws_channel_function != WS_FIXED_CHANNEL)) {
393-
if ((waiting_ack == false) && (fhss_structure->ws->is_on_bc_channel == false)) {
394-
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, fhss_structure->rx_channel);
393+
if (waiting_ack == false) {
394+
if (fhss_structure->ws->is_on_bc_channel == false) {
395+
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, fhss_structure->rx_channel);
396+
} else {
397+
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, fhss_structure->ws->bc_channel);
398+
}
395399
}
396400
}
397401
// Buffer was successfully transmitted. Remove stored failure handle if exists.

source/Service_Libs/fhss/fhss_ws.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ typedef struct fhss_ws fhss_ws_t;
2525

2626
struct fhss_ws
2727
{
28+
uint8_t bc_channel;
2829
uint16_t uc_slot;
2930
uint16_t bc_slot;
3031
bool is_on_bc_channel;

test/nanostack/unittest/mac/fhss_callbacks/test_fhss_callbacks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ bool test_mac_set_channel()
123123
arm_device_driver_list_s dev_driver;
124124
phy_driver.phy_tx_done_cb = tx_done;
125125
dev_driver.phy_driver = &phy_driver;
126+
memset(&setup, 0, sizeof(protocol_interface_rf_mac_setup_s));
126127
setup.fhss_api = &fhss_api;
127128
setup.dev_driver = &dev_driver;
128129
mac_mlme_stub.int8_value = 0;

0 commit comments

Comments
 (0)