wifi: Add an overloaded variant of WifiPhy::SetOperatingChannel

This commit is contained in:
Stefano Avallone
2023-05-03 17:13:08 +02:00
parent b412ab0a13
commit b50d5cd416
2 changed files with 28 additions and 2 deletions

View File

@@ -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<UintegerValue, UintegerValue, EnumValue, UintegerValue>(
&WifiPhy::SetOperatingChannel),
(void(WifiPhy::*)(const ChannelTuple&)) & WifiPhy::SetOperatingChannel),
MakeTupleChecker<UintegerValue, UintegerValue, EnumValue, UintegerValue>(
MakeUintegerChecker<uint8_t>(0, 233),
MakeUintegerChecker<uint16_t>(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;
}

View File

@@ -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.
*