mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 23:27:46 +00:00
[trel] add otTrelSetEnabled API (#8731)
This commit is contained in:
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (286)
|
||||
#define OPENTHREAD_API_VERSION (287)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
+21
-12
@@ -73,6 +73,25 @@ typedef struct otTrelPeer
|
||||
*/
|
||||
typedef uint16_t otTrelPeerIterator;
|
||||
|
||||
/**
|
||||
* Enables or disables TREL operation.
|
||||
*
|
||||
* When @p aEnable is true, this function initiates an ongoing DNS-SD browse on the service name "_trel._udp" within the
|
||||
* local browsing domain to discover other devices supporting TREL. Device also registers a new service to be advertised
|
||||
* using DNS-SD, with the service name is "_trel._udp" indicating its support for TREL. Device is then ready to receive
|
||||
* TREL messages from peers.
|
||||
*
|
||||
* When @p aEnable is false, this function stops the DNS-SD browse on the service name "_trel._udp", stops advertising
|
||||
* TREL DNS-SD service, and clears the TREL peer table.
|
||||
*
|
||||
* @note By default the OpenThread stack enables the TREL operation on start.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aEnable A boolean to enable/disable the TREL operation.
|
||||
*
|
||||
*/
|
||||
void otTrelSetEnabled(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* This function enables TREL operation.
|
||||
*
|
||||
@@ -89,23 +108,13 @@ typedef uint16_t otTrelPeerIterator;
|
||||
void otTrelEnable(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function disables TREL operation.
|
||||
*
|
||||
* This function stops the DNS-SD browse on the service name "_trel._udp", stops advertising TREL DNS-SD service, and
|
||||
* clears the TREL peer table.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
* This function is deprecated.
|
||||
*
|
||||
*/
|
||||
void otTrelDisable(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function indicates whether the TREL operation is enabled.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
*
|
||||
* @retval TRUE if the TREL operation is enabled.
|
||||
* @retval FALSE if the TREL operation is disabled.
|
||||
* This function is deprecated.
|
||||
*
|
||||
*/
|
||||
bool otTrelIsEnabled(otInstance *aInstance);
|
||||
|
||||
+1
-8
@@ -7135,14 +7135,7 @@ template <> otError Interpreter::Process<Cmd("trel")>(Arg aArgs[])
|
||||
}
|
||||
else if (ParseEnableOrDisable(aArgs[0], enable) == OT_ERROR_NONE)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
otTrelEnable(GetInstancePtr());
|
||||
}
|
||||
else
|
||||
{
|
||||
otTrelDisable(GetInstancePtr());
|
||||
}
|
||||
otTrelSetEnabled(GetInstancePtr(), enable);
|
||||
}
|
||||
else if (aArgs[0] == "filter")
|
||||
{
|
||||
|
||||
@@ -43,6 +43,11 @@
|
||||
|
||||
using namespace ot;
|
||||
|
||||
void otTrelSetEnabled(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Trel::Interface>().SetEnabled(aEnable);
|
||||
}
|
||||
|
||||
void otTrelEnable(otInstance *aInstance) { AsCoreType(aInstance).Get<Trel::Interface>().Enable(); }
|
||||
|
||||
void otTrelDisable(otInstance *aInstance) { AsCoreType(aInstance).Get<Trel::Interface>().Disable(); }
|
||||
|
||||
@@ -76,6 +76,18 @@ void Interface::Init(void)
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::SetEnabled(bool aEnable)
|
||||
{
|
||||
if (aEnable)
|
||||
{
|
||||
Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
Disable();
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::Enable(void)
|
||||
{
|
||||
VerifyOrExit(!mEnabled);
|
||||
|
||||
@@ -151,6 +151,13 @@ public:
|
||||
*/
|
||||
typedef otTrelPeerIterator PeerIterator;
|
||||
|
||||
/**
|
||||
* This method enables or disables the TREL interface.
|
||||
*
|
||||
* @param[in] aEnable A boolean to enable/disable the TREL interface.
|
||||
*/
|
||||
void SetEnabled(bool aEnable);
|
||||
|
||||
/**
|
||||
* This method enables the TREL interface.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user