From b50d5cd41617e363eeb202f91948a931cac86bfd Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 3 May 2023 17:13:08 +0200 Subject: [PATCH] wifi: Add an overloaded variant of WifiPhy::SetOperatingChannel --- src/wifi/model/wifi-phy.cc | 16 ++++++++++++++-- src/wifi/model/wifi-phy.h | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 56ae598e1..fe4ec2684 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -89,7 +89,7 @@ WifiPhy::GetTypeId() "number uniquely identify a frequency channel for the given standard and band.", StringValue("{0, 0, BAND_UNSPECIFIED, 0}"), MakeTupleAccessor( - &WifiPhy::SetOperatingChannel), + (void(WifiPhy::*)(const ChannelTuple&)) & WifiPhy::SetOperatingChannel), MakeTupleChecker( MakeUintegerChecker(0, 233), MakeUintegerChecker(0, 160), @@ -1067,6 +1067,17 @@ WifiPhy::GetTxBandwidth(WifiMode mode, uint16_t maxAllowedWidth) const return std::min({GetChannelWidth(), GetMaximumChannelWidth(modulation), maxAllowedWidth}); } +void +WifiPhy::SetOperatingChannel(const WifiPhyOperatingChannel& channel) +{ + NS_LOG_FUNCTION(this << channel); + WifiPhy::ChannelTuple tuple(channel.GetNumber(), + channel.GetWidth(), + channel.GetPhyBand(), + channel.GetPrimaryChannelIndex(20)); + SetOperatingChannel(tuple); +} + void WifiPhy::SetOperatingChannel(const ChannelTuple& channelTuple) { @@ -1098,7 +1109,8 @@ WifiPhy::SetOperatingChannel(const ChannelTuple& channelTuple) if (delay.IsStrictlyPositive()) { // switching channel has been postponed - Simulator::Schedule(delay, &WifiPhy::SetOperatingChannel, this, channelTuple); + void (WifiPhy::*fp)(const ChannelTuple&) = &WifiPhy::SetOperatingChannel; + Simulator::Schedule(delay, fp, this, channelTuple); return; } diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index b1ae4f9f5..da9c00ba7 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -885,6 +885,20 @@ class WifiPhy : public Object * \param channelTuple the given channel settings */ void SetOperatingChannel(const ChannelTuple& channelTuple); + /** + * If the standard for this object has not been set yet, store the channel settings + * corresponding to the given operating channel. Otherwise, check if a channel switch + * can be performed now. If not, schedule another call to this method when channel switch + * can be performed. Otherwise, set the given operating channel and call ConfigureStandard + * if the PHY band has changed. + * + * Note that, in case a Spectrum PHY is used, a spectrum channel covering the + * operating channel bandwidth must have been already added when actually setting + * the operating channel. + * + * \param channel the given operating channel + */ + void SetOperatingChannel(const WifiPhyOperatingChannel& channel); /** * Configure whether it is prohibited to change PHY band after initialization. *