Skip to content

Commit

Permalink
MAC Ack wait fixed for OFDM (ARMmbed#2552)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso authored Jan 21, 2021
1 parent 5106b1d commit bc09cba
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,11 @@ int ws_bootstrap_set_rf_config(protocol_interface_info_entry_t *cur, phy_rf_chan
set_request.value_size = sizeof(phy_rf_channel_configuration_s);
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_request);
// Set Ack wait duration
uint16_t ack_wait_symbols = WS_ACK_WAIT_SYMBOLS + (WS_TACK_MAX_MS * (rf_configs.datarate / 1000));
uint8_t bits_per_symbol = 1;
if (rf_configs.modulation == M_OFDM) {
bits_per_symbol = 4;
}
uint16_t ack_wait_symbols = WS_ACK_WAIT_SYMBOLS + (WS_TACK_MAX_MS * (rf_configs.datarate / 1000) / bits_per_symbol);
set_request.attr = macAckWaitDuration;
set_request.value_pointer = &ack_wait_symbols;
set_request.value_size = sizeof(ack_wait_symbols);
Expand Down
2 changes: 1 addition & 1 deletion source/MAC/IEEE802_15_4/mac_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ typedef struct protocol_interface_rf_mac_setup {
int8_t bc_timer_id;
uint32_t mlme_tick_count;
uint32_t symbol_rate;
uint32_t symbol_time_us;
uint32_t symbol_time_ns;
uint32_t datarate;
uint8_t max_ED;
uint16_t mlme_ED_counter;
Expand Down
10 changes: 5 additions & 5 deletions source/MAC/IEEE802_15_4/mac_mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,11 @@ void mac_extended_mac_set(protocol_interface_rf_mac_setup_s *rf_mac_setup, const

static uint32_t mac_calc_ack_wait_duration(protocol_interface_rf_mac_setup_s *rf_mac_setup, uint16_t symbols)
{
uint32_t AckWaitDuration = 0;
uint32_t AckWaitDuration_us = 0;
if (rf_mac_setup->rf_csma_extension_supported) {
AckWaitDuration = symbols * rf_mac_setup->symbol_time_us;
AckWaitDuration_us = (symbols * rf_mac_setup->symbol_time_ns) / 1000;
}
return AckWaitDuration;
return AckWaitDuration_us;
}

static int8_t mac_mlme_set_ack_wait_duration(protocol_interface_rf_mac_setup_s *rf_mac_setup, const mlme_set_t *set_req)
Expand Down Expand Up @@ -1107,8 +1107,8 @@ static int mac_mlme_set_symbol_rate(protocol_interface_rf_mac_setup_s *rf_mac_se
{
if (rf_mac_setup->rf_csma_extension_supported) {
rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_GET_SYMBOLS_PER_SECOND, (uint8_t *) &rf_mac_setup->symbol_rate);
rf_mac_setup->symbol_time_us = 1000000 / rf_mac_setup->symbol_rate;
tr_debug("SW-MAC driver support rf extension %"PRIu32" symbol/seconds %"PRIu32" us symbol time length", rf_mac_setup->symbol_rate, rf_mac_setup->symbol_time_us);
rf_mac_setup->symbol_time_ns = 1000000000 / rf_mac_setup->symbol_rate;
tr_debug("SW-MAC driver support rf extension %"PRIu32" symbol/seconds %"PRIu32" ns symbol time length", rf_mac_setup->symbol_rate, rf_mac_setup->symbol_time_ns);
return 0;
}
return -1;
Expand Down
2 changes: 1 addition & 1 deletion source/MAC/IEEE802_15_4/mac_pd_sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ uint32_t mac_csma_backoff_get(protocol_interface_rf_mac_setup_s *rf_mac_setup)
uint32_t backoff_in_us;
//Multiple aUnitBackoffPeriod symbol time
if (rf_mac_setup->rf_csma_extension_supported) {
backoff_in_us = backoff * rf_mac_setup->aUnitBackoffPeriod * rf_mac_setup->symbol_time_us;
backoff_in_us = backoff * rf_mac_setup->aUnitBackoffPeriod * (rf_mac_setup->symbol_time_ns / 1000);
} else {
backoff_in_us = backoff * rf_mac_setup->backoff_period_in_10us * 10;
}
Expand Down
2 changes: 1 addition & 1 deletion source/Service_Libs/fhss/fhss_ws.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Max TX/RX slot length in milliseconds. Is used when datarate is not given by PHY or calculated slot length exceeds maximum allowed.
#define WS_TXRX_SLOT_LEN_MS_MAX 100
// Min TX/RX slot length in milliseconds. Is used when calculated slot length is under minimum allowed.
#define WS_TXRX_SLOT_LEN_MS_MIN 10
#define WS_TXRX_SLOT_LEN_MS_MIN 13
// Default minimum broadcast synchronization interval in seconds
#define DEFAULT_MIN_SYNCH_INTERVAL 60
// Drift compensation allowed if at least SYNCH_COMPENSATION_MIN_INTERVAL (seconds) since last synchronization
Expand Down

0 comments on commit bc09cba

Please sign in to comment.