From 6940bb717054ff8f13a0ef5b4506f33551067ecd Mon Sep 17 00:00:00 2001 From: Sebastien Deronne Date: Wed, 8 Jun 2022 07:40:26 +0200 Subject: [PATCH] wifi: Add function to retrieve the center frequency of a given secondary channel --- src/wifi/model/wifi-phy-operating-channel.cc | 8 ++++++++ src/wifi/model/wifi-phy-operating-channel.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index 65bf6eb43..51d05fbe5 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -470,6 +470,14 @@ WifiPhyOperatingChannel::GetPrimaryChannelCenterFrequency (uint16_t primaryChann return freq; } +uint16_t +WifiPhyOperatingChannel::GetSecondaryChannelCenterFrequency (uint16_t secondaryChannelWidth) const +{ + const uint8_t primaryIndex = GetPrimaryChannelIndex (secondaryChannelWidth); + const uint16_t primaryCenterFrequency = GetPrimaryChannelCenterFrequency (secondaryChannelWidth); + return (primaryIndex % 2 == 0) ? (primaryCenterFrequency + secondaryChannelWidth) : (primaryCenterFrequency - secondaryChannelWidth); +} + uint8_t WifiPhyOperatingChannel::GetPrimaryChannelNumber (uint16_t primaryChannelWidth, WifiStandard standard) const diff --git a/src/wifi/model/wifi-phy-operating-channel.h b/src/wifi/model/wifi-phy-operating-channel.h index 728140999..054654c26 100644 --- a/src/wifi/model/wifi-phy-operating-channel.h +++ b/src/wifi/model/wifi-phy-operating-channel.h @@ -159,6 +159,7 @@ public: * \param index the index of the primary 20 MHz channel */ void SetPrimary20Index (uint8_t index); + /** * Get the center frequency of the primary channel of the given width. * @@ -167,6 +168,14 @@ public: */ uint16_t GetPrimaryChannelCenterFrequency (uint16_t primaryChannelWidth) const; + /** + * Get the center frequency of the secondary channel of the given width. + * + * \param secondaryChannelWidth the width of the secondary channel in MHz + * \return the center frequency of the secondary channel of the given width + */ + uint16_t GetSecondaryChannelCenterFrequency (uint16_t secondaryChannelWidth) const; + /** * Get the channel indices of all the 20 MHz channels included in the primary * channel of the given width, if such primary channel exists, or an empty set,