[mle] add discovery request callback (#5131)

This commit allows notifying the application a discovery request is
received, which is useful if the application wants to be more active
when a joiner comes.
This commit is contained in:
Yakun Xu
2020-08-12 01:22:10 +08:00
committed by GitHub
parent 644e0a30f7
commit 66dcbac15d
9 changed files with 124 additions and 15 deletions
+10
View File
@@ -287,6 +287,9 @@ Interpreter::Interpreter(Instance *aInstance)
#if OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE
otThreadSetReceiveDiagnosticGetCallback(mInstance, &Interpreter::HandleDiagnosticGetResponse, this);
#endif
#if OPENTHREAD_FTD
otThreadSetDiscoveryRequestCallback(mInstance, &Interpreter::HandleDiscoveryRequest, this);
#endif
mIcmpHandler.mReceiveCallback = Interpreter::HandleIcmpReceive;
mIcmpHandler.mContext = this;
@@ -4590,6 +4593,13 @@ void Interpreter::SignalPingReply(const Ip6::Address &aPeerAddress,
#endif
}
void Interpreter::HandleDiscoveryRequest(const otThreadDiscoveryRequestInfo &aInfo)
{
mServer->OutputFormat("~ Discovery Request from ");
OutputBytes(aInfo.mExtAddress.m8, sizeof(aInfo.mExtAddress.m8));
mServer->OutputFormat(": version=%u,joiner=%d\r\n", aInfo.mVersion, aInfo.mIsJoiner);
}
extern "C" void otCliSetUserCommands(const otCliCommand *aUserCommands, uint8_t aLength)
{
Server::sServer->GetInterpreter().SetUserCommands(aUserCommands, aLength);