mirror of
https://github.com/espressif/openthread.git
synced 2026-08-24 11:19:51 +00:00
[mdns] change SetEnabled() to be idempotent (#11690)
This commit changes the `SetEnabled()` API to return `kErrorNone` when the component is already in the requested state (enabled or disabled). Previously, the method would return `kErrorAlready` in this scenario. Making this API idempotent simplifies caller logic, as they no longer need to handle the `kErrorAlready` case.
This commit is contained in:
@@ -52,7 +52,7 @@ extern "C" {
|
||||
*
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (518)
|
||||
#define OPENTHREAD_API_VERSION (519)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -170,7 +170,7 @@ typedef struct otMdnsLocalHostAddress
|
||||
* @param[in] aInfraIfIndex The network interface index for mDNS operation. Value is ignored when disabling
|
||||
*
|
||||
* @retval OT_ERROR_NONE Enabled or disabled the mDNS module successfully.
|
||||
* @retval OT_ERROR_ALREADY mDNS is already enabled on an enable request or is already disabled on a disable request.
|
||||
* @retval OT_ERROR_FAILED Failed to enable/disable mDNS.
|
||||
*/
|
||||
otError otMdnsSetEnabled(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex);
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ Error Core::SetEnabled(bool aEnable, uint32_t aInfraIfIndex, Requester aRequeste
|
||||
mAutoEnable = false;
|
||||
}
|
||||
|
||||
VerifyOrExit(aEnable != mIsEnabled, error = kErrorAlready);
|
||||
VerifyOrExit(aEnable != mIsEnabled);
|
||||
|
||||
mIsEnabled = aEnable;
|
||||
mInfraIfIndex = aInfraIfIndex;
|
||||
|
||||
@@ -175,7 +175,6 @@ public:
|
||||
* @param[in] aInfraIfIndex The network interface index for mDNS operation. Value is ignored when disabling.
|
||||
*
|
||||
* @retval kErrorNone Enabled or disabled the mDNS module successfully.
|
||||
* @retval kErrorAlready mDNS is already enabled on an enable request, or is already disabled on a disable request.
|
||||
* @retval kErrorFailed Failed to enable/disable mDNS.
|
||||
*/
|
||||
Error SetEnabled(bool aEnable, uint32_t aInfraIfIndex)
|
||||
|
||||
Reference in New Issue
Block a user