[mle] add config and test for discovery request callback (#12284)

Introduces `OPENTHREAD_CONFIG_MLE_DISCOVERY_SCAN_REQUEST_CALLBACK_ENABLE`
to conditionally compile the MLE Discovery Request callback feature.
Disabling this feature allows for code size reduction on builds where
it is not needed.

A new Nexus test (`test_discover_scan.cpp`) is added to directly
validate the `otThreadSetDiscoveryRequestCallback()` API behavior.

This new test replaces a now-removed CLI-based test which used
 (`discover reqcallback`). This CLI command was originally added for
testing purposes. The CLI command is not helpful as an async event
would produce unsolicited output in the CLI. The new direct C++ test
is a cleaner approach.
This commit is contained in:
Abtin Keshavarzian
2026-02-03 07:58:39 -08:00
committed by GitHub
parent 0bbe9dc350
commit d388095b66
12 changed files with 206 additions and 37 deletions
+3 -1
View File
@@ -2749,9 +2749,10 @@ void Mle::HandleDiscoveryRequest(RxInfo &aRxInfo)
if (parsedDiscoveryRequestTlv)
{
#if OPENTHREAD_CONFIG_MLE_DISCOVERY_SCAN_REQUEST_CALLBACK_ENABLE
if (mDiscoveryRequestCallback.IsSet())
{
otThreadDiscoveryRequestInfo info;
DiscoveryRequestInfo info;
AsCoreType(&info.mExtAddress).SetFromIid(aRxInfo.mMessageInfo.GetPeerAddr().GetIid());
info.mVersion = discoveryRequestTlvValue.GetVersion();
@@ -2759,6 +2760,7 @@ void Mle::HandleDiscoveryRequest(RxInfo &aRxInfo)
mDiscoveryRequestCallback.Invoke(&info);
}
#endif
if (discoveryRequestTlvValue.GetJoinerFlag())
{