Skip to content

Commit

Permalink
Fixed missing TX ime calculation for pre-builded MAC packet send.
Browse files Browse the repository at this point in the history
Change-Id: Iea6eb869a11138fbaffabe61140bd03a9bb36cd8
  • Loading branch information
Juha Heiskanen authored and juhhei01 committed Apr 19, 2018
1 parent c3aa7d1 commit 14e1597
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions source/MAC/IEEE802_15_4/mac_mcps_sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,15 @@ static void mcps_generic_sequence_number_allocate(protocol_interface_rf_mac_setu
}


static uint32_t mcps_generic_backoff_calc(protocol_interface_rf_mac_setup_s *rf_ptr)
{
uint32_t random_period = mac_csma_backoff_get(rf_ptr);
if (rf_ptr->fhss_api) {
return mcps_calculate_tx_time(rf_ptr, random_period);
}
return random_period;
}

static int8_t mcps_generic_packet_build(protocol_interface_rf_mac_setup_s *rf_ptr, mac_pre_build_frame_t *buffer)
{
phy_device_driver_s *dev_driver = rf_ptr->dev_driver->phy_driver;
Expand All @@ -1411,6 +1420,7 @@ static int8_t mcps_generic_packet_build(protocol_interface_rf_mac_setup_s *rf_pt
tx_buf->len = buffer->mac_payload_length;

memcpy(ptr, buffer->mac_payload, buffer->mac_payload_length );
buffer->tx_time = mcps_generic_backoff_calc(rf_ptr);
return 0;
}

Expand Down Expand Up @@ -1466,13 +1476,7 @@ static int8_t mcps_generic_packet_build(protocol_interface_rf_mac_setup_s *rf_pt

tx_buf->len = frame_length;
uint8_t *mhr_start = ptr;

uint32_t random_period = mac_csma_backoff_get(rf_ptr);
if (rf_ptr->fhss_api) {
buffer->tx_time = mcps_calculate_tx_time(rf_ptr, random_period);
} else {
buffer->tx_time = random_period;
}
buffer->tx_time = mcps_generic_backoff_calc(rf_ptr);

ptr = mac_generic_packet_write(rf_ptr, ptr, buffer);

Expand Down Expand Up @@ -1506,6 +1510,7 @@ static int8_t mcps_generic_packet_rebuild(protocol_interface_rf_mac_setup_s *rf_
tx_buf->len = buffer->mac_payload_length;

memcpy(ptr, buffer->mac_payload, buffer->mac_payload_length );
buffer->tx_time = mcps_generic_backoff_calc(rf_ptr);
return 0;
}

Expand Down Expand Up @@ -1533,12 +1538,8 @@ static int8_t mcps_generic_packet_rebuild(protocol_interface_rf_mac_setup_s *rf_
tx_buf->len = frame_length;
uint8_t *mhr_start = ptr;

uint32_t random_period = mac_csma_backoff_get(rf_ptr);
if (rf_ptr->fhss_api) {
buffer->tx_time = mcps_calculate_tx_time(rf_ptr, random_period);
} else {
buffer->tx_time = random_period;
}
buffer->tx_time = mcps_generic_backoff_calc(rf_ptr);

ptr = mac_generic_packet_write(rf_ptr, ptr, buffer);

if (buffer->fcf_dsn.securityEnabled) {
Expand Down

0 comments on commit 14e1597

Please sign in to comment.