Skip to content

Commit c4ef759

Browse files
author
Jarkko Paso
committed
MAC: Write FHSS synch info before calling PHY TX function
1 parent 9cca341 commit c4ef759

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

source/MAC/IEEE802_15_4/mac_pd_sap.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ int8_t mac_plme_cca_req(protocol_interface_rf_mac_setup_s *rf_mac_setup)
150150
phy_device_driver_s *dev_driver = rf_mac_setup->dev_driver->phy_driver;
151151

152152
rf_mac_setup->macRfRadioTxActive = true;
153+
154+
if (rf_mac_setup->fhss_api) {
155+
mac_pre_build_frame_t *active_buf = rf_mac_setup->active_pd_data_request;
156+
if (active_buf && (active_buf->fcf_dsn.frametype == FC_BEACON_FRAME)) {
157+
// FHSS synchronization info is written in the end of transmitted (Beacon) buffer
158+
dev_driver_tx_buffer_s *tx_buf = &rf_mac_setup->dev_driver_tx_buffer;
159+
uint8_t *synch_info = tx_buf->buf + rf_mac_setup->dev_driver->phy_driver->phy_header_length + tx_buf->len - FHSS_SYNCH_INFO_LENGTH;
160+
rf_mac_setup->fhss_api->write_synch_info(rf_mac_setup->fhss_api, synch_info, 0, FHSS_SYNCH_FRAME, 0);
161+
}
162+
}
153163
if (dev_driver->arm_net_virtual_tx_cb) {
154164
if (dev_driver->tx(tx_buf->buf, tx_buf->len, 1, PHY_LAYER_PAYLOAD) == 0) {
155165
timer_mac_start(rf_mac_setup, MAC_TX_TIMEOUT, NWKTX_TIMEOUT_PERIOD); /*Start Timeout timer for virtual packet loss*/
@@ -400,13 +410,6 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
400410
return -1;
401411
}
402412

403-
if (active_buf->fcf_dsn.frametype == FC_BEACON_FRAME) {
404-
// FHSS synchronization info is written in the end of transmitted (Beacon) buffer
405-
dev_driver_tx_buffer_s *tx_buf = &rf_ptr->dev_driver_tx_buffer;
406-
uint8_t *synch_info = tx_buf->buf + rf_ptr->dev_driver->phy_driver->phy_header_length + tx_buf->len - FHSS_SYNCH_INFO_LENGTH;
407-
rf_ptr->fhss_api->write_synch_info(rf_ptr->fhss_api, synch_info, 0, FHSS_SYNCH_FRAME, 0);
408-
}
409-
410413
// Change to destination channel and write synchronization info to Beacon frames here
411414
int tx_handle_retval = rf_ptr->fhss_api->tx_handle(rf_ptr->fhss_api, !mac_is_ack_request_set(active_buf),
412415
active_buf->DstAddr, mac_convert_frame_type_to_fhss(active_buf->fcf_dsn.frametype),

0 commit comments

Comments
 (0)