mirror of
https://github.com/espressif/openthread.git
synced 2026-09-04 08:10:11 +00:00
Restrict the non joinable beacons (#1783)
Respond to the beacon requests with the beacon only if they are joinable to reduce the traffic.
This commit is contained in:
+26
-2
@@ -633,7 +633,6 @@ void Mac::SendBeaconRequest(Frame &aFrame)
|
||||
aFrame.SetDstPanId(kShortAddrBroadcast);
|
||||
aFrame.SetDstAddr(kShortAddrBroadcast);
|
||||
aFrame.SetCommandId(Frame::kMacCmdBeaconRequest);
|
||||
|
||||
otLogInfoMac(GetInstance(), "Sending Beacon Request");
|
||||
}
|
||||
|
||||
@@ -1681,7 +1680,11 @@ otError Mac::HandleMacCommand(Frame &aFrame)
|
||||
mCounters.mRxBeaconRequest++;
|
||||
otLogInfoMac(GetInstance(), "Received Beacon Request");
|
||||
|
||||
if (mBeaconsEnabled)
|
||||
if ((mBeaconsEnabled)
|
||||
#if OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
|
||||
&& (IsBeaconJoinable())
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
|
||||
)
|
||||
{
|
||||
mTransmitBeacon = true;
|
||||
|
||||
@@ -1762,5 +1765,26 @@ void Mac::ResetCounters(void)
|
||||
memset(&mCounters, 0, sizeof(mCounters));
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
|
||||
bool Mac::IsBeaconJoinable(void)
|
||||
{
|
||||
uint8_t numUnsecurePorts;
|
||||
bool joinable = false;
|
||||
|
||||
mNetif.GetIp6Filter().GetUnsecurePorts(numUnsecurePorts);
|
||||
|
||||
if (numUnsecurePorts)
|
||||
{
|
||||
joinable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
joinable = false;
|
||||
}
|
||||
|
||||
return joinable;
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
|
||||
|
||||
} // namespace Mac
|
||||
} // namespace ot
|
||||
|
||||
@@ -608,6 +608,17 @@ public:
|
||||
*/
|
||||
void ResetCounters(void);
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
|
||||
/**
|
||||
* This method indicates if the beacon is joinable or non-joinable
|
||||
*
|
||||
* @retval true Beacon is joinable.
|
||||
* @retval false Beacon is non-joinable.
|
||||
*
|
||||
*/
|
||||
bool IsBeaconJoinable(void);
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
|
||||
|
||||
/**
|
||||
* This method returns the MAC counter.
|
||||
*
|
||||
|
||||
@@ -738,6 +738,16 @@
|
||||
#define OPENTHREAD_CONFIG_ENABLE_AUTO_START_SUPPORT 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
|
||||
*
|
||||
* Define to 1 if you want to enable beacon response for joinable networks.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE
|
||||
#define OPENTHREAD_CONFIG_ENABLE_BEACON_RSP_IF_JOINABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user