wifi: Prefer use of auto for variables using units
This commit is contained in:
@@ -280,7 +280,7 @@ main(int argc, char** argv)
|
||||
/* frequency range for spectrum analyzer */
|
||||
std::vector<double> freqs;
|
||||
MHz_u margin = 2; // 1MHz margin on each side
|
||||
int band = (bw + margin);
|
||||
const auto band = (bw + margin);
|
||||
freqs.reserve(4 * 10 * band);
|
||||
const MHz_u scale{0.1};
|
||||
for (int i = 0; i < (4 * 10 * band); ++i) // conversion to 100kHz scale
|
||||
|
||||
@@ -1222,10 +1222,9 @@ HePhy::GetPer20MHzDurations(const Ptr<const WifiPpdu> ppdu)
|
||||
|
||||
if (ppdu)
|
||||
{
|
||||
const MHz_u subchannelMinFreq = m_wifiPhy->GetFrequency() -
|
||||
(m_wifiPhy->GetChannelWidth() / 2) +
|
||||
(index * MHz_u{20});
|
||||
const MHz_u subchannelMaxFreq = subchannelMinFreq + MHz_u{20};
|
||||
const auto subchannelMinFreq = m_wifiPhy->GetFrequency() -
|
||||
(m_wifiPhy->GetChannelWidth() / 2) + (index * MHz_u{20});
|
||||
const auto subchannelMaxFreq = subchannelMinFreq + MHz_u{20};
|
||||
const auto ppduBw = ppdu->GetTxVector().GetChannelWidth();
|
||||
|
||||
if (ppduBw <= m_wifiPhy->GetChannelWidth() &&
|
||||
@@ -1480,14 +1479,15 @@ HePhy::StartTx(Ptr<const WifiPpdu> ppdu)
|
||||
}
|
||||
if (ppdu->GetType() == WIFI_PPDU_TYPE_UL_MU || ppdu->GetType() == WIFI_PPDU_TYPE_DL_MU)
|
||||
{
|
||||
dBm_u nonHeTxPower = m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain();
|
||||
const auto nonHeTxPower =
|
||||
m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain();
|
||||
|
||||
// temporarily set WifiPpdu flag to PSD_HE_PORTION for correct calculation of TX power for
|
||||
// the HE portion
|
||||
auto hePpdu = DynamicCast<const HePpdu>(ppdu);
|
||||
NS_ASSERT(hePpdu);
|
||||
hePpdu->SetTxPsdFlag(HePpdu::PSD_HE_PORTION);
|
||||
dBm_u heTxPower = m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain();
|
||||
const auto heTxPower = m_wifiPhy->GetTxPowerForTransmission(ppdu) + m_wifiPhy->GetTxGain();
|
||||
hePpdu->SetTxPsdFlag(HePpdu::PSD_NON_HE_PORTION);
|
||||
|
||||
// non-HE portion
|
||||
|
||||
@@ -1409,13 +1409,13 @@ PhyEntity::CanStartRx(Ptr<const WifiPpdu> ppdu) const
|
||||
// then we consider the primary20 channel
|
||||
const auto p20CenterFreq =
|
||||
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelCenterFrequency(primaryWidth);
|
||||
const uint16_t p20MinFreq = p20CenterFreq - (primaryWidth / 2);
|
||||
const uint16_t p20MaxFreq = p20CenterFreq + (primaryWidth / 2);
|
||||
const auto p20MinFreq = p20CenterFreq - (primaryWidth / 2);
|
||||
const auto p20MaxFreq = p20CenterFreq + (primaryWidth / 2);
|
||||
const auto txChannelWidth = (ppdu->GetTxChannelWidth() / ppdu->GetTxCenterFreqs().size());
|
||||
for (auto txCenterFreq : ppdu->GetTxCenterFreqs())
|
||||
{
|
||||
const uint16_t minTxFreq = txCenterFreq - txChannelWidth / 2;
|
||||
const uint16_t maxTxFreq = txCenterFreq + txChannelWidth / 2;
|
||||
const auto minTxFreq = txCenterFreq - txChannelWidth / 2;
|
||||
const auto maxTxFreq = txCenterFreq + txChannelWidth / 2;
|
||||
if ((p20MinFreq >= minTxFreq) && (p20MaxFreq <= maxTxFreq))
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -266,7 +266,7 @@ ReducedNeighborReport::GetOperatingChannel(std::size_t nbrApInfoId) const
|
||||
}
|
||||
|
||||
uint8_t primaryChannelNumber = m_nbrApInfoFields.at(nbrApInfoId).channelNumber;
|
||||
MHz_u primaryChannelCenterFrequency = startingFreq + primaryChannelNumber * MHz_u{5};
|
||||
auto primaryChannelCenterFrequency = startingFreq + primaryChannelNumber * MHz_u{5};
|
||||
|
||||
uint8_t channelNumber = 0;
|
||||
MHz_u frequency = 0;
|
||||
@@ -325,8 +325,8 @@ ReducedNeighborReport::GetOperatingChannel(std::size_t nbrApInfoId) const
|
||||
WifiPhyOperatingChannel channel;
|
||||
channel.Set({{channelNumber, frequency, width, band}}, WIFI_STANDARD_UNSPECIFIED);
|
||||
|
||||
MHz_u channelLowestFreq = frequency - width / 2;
|
||||
MHz_u primaryChannelLowestFreq = primaryChannelCenterFrequency - MHz_u{10};
|
||||
const auto channelLowestFreq = frequency - width / 2;
|
||||
const auto primaryChannelLowestFreq = primaryChannelCenterFrequency - MHz_u{10};
|
||||
channel.SetPrimary20Index(Count20MHzSubchannels(channelLowestFreq, primaryChannelLowestFreq));
|
||||
|
||||
return channel;
|
||||
|
||||
@@ -913,7 +913,7 @@ SpectrumWifiPhyGetBandTest::DoRun()
|
||||
const MHz_u separationWidth = 240;
|
||||
for (bool contiguous160Mhz : {true /* 160 MHz */, false /* 80+80MHz */})
|
||||
{
|
||||
MHz_u guardWidth = contiguous160Mhz ? channelWidth : (channelWidth / 2);
|
||||
const auto guardWidth = contiguous160Mhz ? channelWidth : (channelWidth / 2);
|
||||
uint32_t guardStopIndice = (indicesPer20MhzBand * Count20MHzSubchannels(guardWidth)) - 1;
|
||||
std::vector<WifiSpectrumBandIndices> previousExpectedIndices{};
|
||||
std::vector<WifiSpectrumBandFrequencies> previousExpectedFrequencies{};
|
||||
|
||||
@@ -258,11 +258,12 @@ WifiOfdmMaskSlopesTestCase::InterpolateAndAppendValues(IndexPowerVect& vect,
|
||||
return;
|
||||
}
|
||||
|
||||
double slope = (stop.second - start.second) / (stop.first - start.first);
|
||||
const auto slope = (stop.second - start.second) / (stop.first - start.first);
|
||||
for (uint32_t i = start.first; i <= stop.first; i++)
|
||||
{
|
||||
dB_u val = start.second + slope * (i - start.first);
|
||||
double multiplier = std::round(std::pow(10.0, static_cast<double>(m_precision)));
|
||||
const auto delta{i - start.first};
|
||||
dB_u val{start.second + slope * delta};
|
||||
const auto multiplier = std::round(std::pow(10.0, static_cast<double>(m_precision)));
|
||||
val = dB_u{std::floor(val * multiplier + 0.5) / multiplier};
|
||||
vect.emplace_back(i, val);
|
||||
NS_LOG_LOGIC("Append (" << i << ", " << val << ")");
|
||||
|
||||
Reference in New Issue
Block a user