Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e717316

Browse files
authoredJan 23, 2024
Merge branch 'project-chip:master' into master
2 parents 78dc4fa + 166c4b5 commit e717316

12 files changed

+108
-121
lines changed
 

‎src/app/CommandSender.cpp

+5-13
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ CHIP_ERROR GetRef(ParserT aParser, Optional<uint16_t> & aRef, bool commandRefExp
6363
CommandSender::CommandSender(Callback * apCallback, Messaging::ExchangeManager * apExchangeMgr, bool aIsTimedRequest,
6464
bool aSuppressResponse) :
6565
mExchangeCtx(*this),
66-
mpCallback(apCallback), mpExchangeMgr(apExchangeMgr), mSuppressResponse(aSuppressResponse), mTimedRequest(aIsTimedRequest)
66+
mCallbackHandle(apCallback), mpExchangeMgr(apExchangeMgr), mSuppressResponse(aSuppressResponse), mTimedRequest(aIsTimedRequest)
6767
{
6868
assertChipStackLockedByCurrentThread();
6969
}
7070

7171
CommandSender::CommandSender(ExtendableCallback * apExtendableCallback, Messaging::ExchangeManager * apExchangeMgr,
7272
bool aIsTimedRequest, bool aSuppressResponse) :
7373
mExchangeCtx(*this),
74-
mpExtendableCallback(apExtendableCallback), mpExchangeMgr(apExchangeMgr), mSuppressResponse(aSuppressResponse),
75-
mTimedRequest(aIsTimedRequest)
74+
mCallbackHandle(apExtendableCallback), mpExchangeMgr(apExchangeMgr), mSuppressResponse(aSuppressResponse),
75+
mTimedRequest(aIsTimedRequest), mUseExtendableCallback(true)
7676
{
7777
assertChipStackLockedByCurrentThread();
7878
}
@@ -86,12 +86,6 @@ CHIP_ERROR CommandSender::AllocateBuffer()
8686
{
8787
if (!mBufferAllocated)
8888
{
89-
// We are making sure that both callbacks are not set. This should never happen as the constructors
90-
// are strongly typed and only one should ever be set, but explicit check is here to ensure that is
91-
// always the case.
92-
bool bothCallbacksAreSet = mpExtendableCallback != nullptr && mpCallback != nullptr;
93-
VerifyOrDie(!bothCallbacksAreSet);
94-
9589
mCommandMessageWriter.Reset();
9690

9791
System::PacketBufferHandle commandPacket = System::PacketBufferHandle::New(chip::app::kMaxSecureSduLengthBytes);
@@ -417,8 +411,7 @@ CHIP_ERROR CommandSender::ProcessInvokeResponseIB(InvokeResponseIB::Parser & aIn
417411
// When using ExtendableCallbacks, we are adhering to a different API contract where path
418412
// specific errors are sent to the OnResponse callback. For more information on the history
419413
// of this issue please see https://github.com/project-chip/connectedhomeip/issues/30991
420-
bool usingExtendableCallbacks = mpExtendableCallback != nullptr;
421-
if (statusIB.IsSuccess() || usingExtendableCallbacks)
414+
if (statusIB.IsSuccess() || mUseExtendableCallback)
422415
{
423416
const ConcreteCommandPath concretePath = ConcreteCommandPath(endpointId, clusterId, commandId);
424417
ResponseData responseData = { concretePath, statusIB };
@@ -456,8 +449,7 @@ CHIP_ERROR CommandSender::PrepareCommand(const CommandPathParams & aCommandPathP
456449
//
457450
// We must not be in the middle of preparing a command, and must not have already sent InvokeRequestMessage.
458451
//
459-
bool usingExtendableCallbacks = mpExtendableCallback != nullptr;
460-
bool canAddAnotherCommand = (mState == State::AddedCommand && mBatchCommandsEnabled && usingExtendableCallbacks);
452+
bool canAddAnotherCommand = (mState == State::AddedCommand && mBatchCommandsEnabled && mUseExtendableCallback);
461453
VerifyOrReturnError(mState == State::Idle || canAddAnotherCommand, CHIP_ERROR_INCORRECT_STATE);
462454
VerifyOrReturnError(mFinishedCommandCount < mRemoteMaxPathsPerInvoke, CHIP_ERROR_MAXIMUM_PATHS_PER_INVOKE_EXCEEDED);
463455

‎src/app/CommandSender.h

+28-20
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class CommandSender final : public Messaging::ExchangeDelegate
455455
private:
456456
friend class TestCommandInteraction;
457457

458-
enum class State
458+
enum class State : uint8_t
459459
{
460460
Idle, ///< Default state that the object starts out in, where no work has commenced
461461
AddingCommand, ///< In the process of adding a command.
@@ -466,6 +466,14 @@ class CommandSender final : public Messaging::ExchangeDelegate
466466
AwaitingDestruction, ///< The object has completed its work and is awaiting destruction by the application.
467467
};
468468

469+
union CallbackHandle
470+
{
471+
CallbackHandle(Callback * apCallback) : legacyCallback(apCallback) {}
472+
CallbackHandle(ExtendableCallback * apExtendableCallback) : extendableCallback(apExtendableCallback) {}
473+
Callback * legacyCallback;
474+
ExtendableCallback * extendableCallback;
475+
};
476+
469477
void MoveToState(const State aTargetState);
470478
const char * GetStateStr() const;
471479

@@ -513,46 +521,45 @@ class CommandSender final : public Messaging::ExchangeDelegate
513521
void OnResponseCallback(const ResponseData & aResponseData)
514522
{
515523
// mpExtendableCallback and mpCallback are mutually exclusive.
516-
if (mpExtendableCallback)
524+
if (mUseExtendableCallback && mCallbackHandle.extendableCallback)
517525
{
518-
mpExtendableCallback->OnResponse(this, aResponseData);
526+
mCallbackHandle.extendableCallback->OnResponse(this, aResponseData);
519527
}
520-
else if (mpCallback)
528+
else if (mCallbackHandle.legacyCallback)
521529
{
522-
mpCallback->OnResponse(this, aResponseData.path, aResponseData.statusIB, aResponseData.data);
530+
mCallbackHandle.legacyCallback->OnResponse(this, aResponseData.path, aResponseData.statusIB, aResponseData.data);
523531
}
524532
}
525533

526534
void OnErrorCallback(CHIP_ERROR aError)
527535
{
528536
// mpExtendableCallback and mpCallback are mutually exclusive.
529-
if (mpExtendableCallback)
537+
if (mUseExtendableCallback && mCallbackHandle.extendableCallback)
530538
{
531539
ErrorData errorData = { aError };
532-
mpExtendableCallback->OnError(this, errorData);
540+
mCallbackHandle.extendableCallback->OnError(this, errorData);
533541
}
534-
else if (mpCallback)
542+
else if (mCallbackHandle.legacyCallback)
535543
{
536-
mpCallback->OnError(this, aError);
544+
mCallbackHandle.legacyCallback->OnError(this, aError);
537545
}
538546
}
539547

540548
void OnDoneCallback()
541549
{
542550
// mpExtendableCallback and mpCallback are mutually exclusive.
543-
if (mpExtendableCallback)
551+
if (mUseExtendableCallback && mCallbackHandle.extendableCallback)
544552
{
545-
mpExtendableCallback->OnDone(this);
553+
mCallbackHandle.extendableCallback->OnDone(this);
546554
}
547-
else if (mpCallback)
555+
else if (mCallbackHandle.legacyCallback)
548556
{
549-
mpCallback->OnDone(this);
557+
mCallbackHandle.legacyCallback->OnDone(this);
550558
}
551559
}
552560

553561
Messaging::ExchangeHolder mExchangeCtx;
554-
Callback * mpCallback = nullptr;
555-
ExtendableCallback * mpExtendableCallback = nullptr;
562+
CallbackHandle mCallbackHandle;
556563
Messaging::ExchangeManager * mpExchangeMgr = nullptr;
557564
InvokeRequestMessage::Builder mInvokeRequestBuilder;
558565
// TODO Maybe we should change PacketBufferTLVWriter so we can finalize it
@@ -564,15 +571,16 @@ class CommandSender final : public Messaging::ExchangeDelegate
564571
Optional<uint16_t> mTimedInvokeTimeoutMs;
565572
TLV::TLVType mDataElementContainerType = TLV::kTLVType_NotSpecified;
566573

567-
State mState = State::Idle;
568574
chip::System::PacketBufferTLVWriter mCommandMessageWriter;
569575
uint16_t mFinishedCommandCount = 0;
570576
uint16_t mRemoteMaxPathsPerInvoke = 1;
571577

572-
bool mSuppressResponse = false;
573-
bool mTimedRequest = false;
574-
bool mBufferAllocated = false;
575-
bool mBatchCommandsEnabled = false;
578+
State mState = State::Idle;
579+
bool mSuppressResponse = false;
580+
bool mTimedRequest = false;
581+
bool mBufferAllocated = false;
582+
bool mBatchCommandsEnabled = false;
583+
bool mUseExtendableCallback = false;
576584
};
577585

578586
} // namespace app

‎src/app/clusters/barrier-control-server/barrier-control-server.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ typedef struct
7474
} State;
7575
static State state;
7676

77-
#ifdef EMBER_SCRIPTED_TEST
78-
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_OPEN_PERIOD_ATTRIBUTE
79-
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_CLOSE_PERIOD_ATTRIBUTE
80-
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_EVENTS_ATTRIBUTE
81-
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_CLOSE_EVENTS_ATTRIBUTE
82-
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_OPEN_EVENTS_ATTRIBUTE
83-
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_CLOSE_EVENTS_ATTRIBUTE
84-
#endif
85-
8677
/**********************************************************
8778
* Matter timer scheduling glue logic
8879
*********************************************************/

‎src/app/util/af.h

-8
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,6 @@ int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t
252252

253253
/** @} END addtogroup */
254254

255-
#if !defined(DOXYGEN_SHOULD_SKIP_THIS)
256-
#if defined(EMBER_TEST)
257-
#define EMBER_TEST_ASSERT(x) assert(x)
258-
#else
259-
#define EMBER_TEST_ASSERT(x)
260-
#endif
261-
#endif
262-
263255
/**
264256
* Returns the pointer to the data version storage for the given endpoint and
265257
* cluster. Can return null in the following cases:

‎src/app/util/attribute-storage.cpp

+9-24
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,6 @@ constexpr const EmberAfDeviceType fixedDeviceTypeList[] = FIXED_DEVI
132132
// Not const, because these need to mutate.
133133
DataVersion fixedEndpointDataVersions[ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT];
134134

135-
#if !defined(EMBER_SCRIPTED_TEST)
136-
#define endpointNumber(x) fixedEndpoints[x]
137-
#define endpointDeviceTypeList(x) \
138-
Span<const EmberAfDeviceType>(&fixedDeviceTypeList[fixedDeviceTypeListOffsets[x]], fixedDeviceTypeListLengths[x])
139-
// Added 'Macro' to silence MISRA warning about conflict with synonymous vars.
140-
#define endpointTypeMacro(x) (&(generatedEmberAfEndpointTypes[fixedEmberAfEndpointTypes[x]]))
141-
#endif
142-
143135
AttributeAccessInterface * gAttributeAccessOverrides = nullptr;
144136

145137
// shouldUnregister returns true if the given AttributeAccessInterface should be
@@ -186,12 +178,10 @@ void emberAfEndpointConfigure()
186178
static_assert(FIXED_ENDPOINT_COUNT <= std::numeric_limits<decltype(ep)>::max(),
187179
"FIXED_ENDPOINT_COUNT must not exceed the size of the endpoint data type");
188180

189-
#if !defined(EMBER_SCRIPTED_TEST)
190181
uint16_t fixedEndpoints[] = FIXED_ENDPOINT_ARRAY;
191182
uint16_t fixedDeviceTypeListLengths[] = FIXED_DEVICE_TYPE_LENGTHS;
192183
uint16_t fixedDeviceTypeListOffsets[] = FIXED_DEVICE_TYPE_OFFSETS;
193184
uint8_t fixedEmberAfEndpointTypes[] = FIXED_ENDPOINT_TYPES;
194-
#endif
195185

196186
#if ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT > 0
197187
// Initialize our data version storage. If
@@ -210,10 +200,11 @@ void emberAfEndpointConfigure()
210200
DataVersion * currentDataVersions = fixedEndpointDataVersions;
211201
for (ep = 0; ep < FIXED_ENDPOINT_COUNT; ep++)
212202
{
213-
emAfEndpoints[ep].endpoint = endpointNumber(ep);
214-
emAfEndpoints[ep].deviceTypeList = endpointDeviceTypeList(ep);
215-
emAfEndpoints[ep].endpointType = endpointTypeMacro(ep);
216-
emAfEndpoints[ep].dataVersions = currentDataVersions;
203+
emAfEndpoints[ep].endpoint = fixedEndpoints[ep];
204+
emAfEndpoints[ep].deviceTypeList =
205+
Span<const EmberAfDeviceType>(&fixedDeviceTypeList[fixedDeviceTypeListOffsets[ep]], fixedDeviceTypeListLengths[ep]);
206+
emAfEndpoints[ep].endpointType = &generatedEmberAfEndpointTypes[fixedEmberAfEndpointTypes[ep]];
207+
emAfEndpoints[ep].dataVersions = currentDataVersions;
217208

218209
emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isEnabled);
219210
emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isFlatComposition);
@@ -918,10 +909,7 @@ uint16_t emberAfGetClusterServerEndpointIndex(EndpointId endpoint, ClusterId clu
918909

919910
bool emberAfEndpointIsEnabled(EndpointId endpoint)
920911
{
921-
uint16_t index = findIndexFromEndpoint(endpoint,
922-
false); // ignore disabled endpoints?
923-
924-
EMBER_TEST_ASSERT(kEmberInvalidEndpointIndex != index);
912+
uint16_t index = findIndexFromEndpoint(endpoint, false /* ignoreDisabledEndpoints */);
925913

926914
if (kEmberInvalidEndpointIndex == index)
927915
{
@@ -933,8 +921,7 @@ bool emberAfEndpointIsEnabled(EndpointId endpoint)
933921

934922
bool emberAfEndpointEnableDisable(EndpointId endpoint, bool enable)
935923
{
936-
uint16_t index = findIndexFromEndpoint(endpoint,
937-
false); // ignore disabled endpoints?
924+
uint16_t index = findIndexFromEndpoint(endpoint, false /* ignoreDisabledEndpoints */);
938925
bool currentlyEnabled;
939926

940927
if (kEmberInvalidEndpointIndex == index)
@@ -990,15 +977,13 @@ bool emberAfEndpointEnableDisable(EndpointId endpoint, bool enable)
990977
// Returns the index of a given endpoint. Does not consider disabled endpoints.
991978
uint16_t emberAfIndexFromEndpoint(EndpointId endpoint)
992979
{
993-
return findIndexFromEndpoint(endpoint,
994-
true); // ignore disabled endpoints?
980+
return findIndexFromEndpoint(endpoint, true /* ignoreDisabledEndpoints */);
995981
}
996982

997983
// Returns the index of a given endpoint. Considers disabled endpoints.
998984
uint16_t emberAfIndexFromEndpointIncludingDisabledEndpoints(EndpointId endpoint)
999985
{
1000-
return findIndexFromEndpoint(endpoint,
1001-
false); // ignore disabled endpoints?
986+
return findIndexFromEndpoint(endpoint, false /* ignoreDisabledEndpoints */);
1002987
}
1003988

1004989
EndpointId emberAfEndpointFromIndex(uint16_t index)

‎src/app/util/attribute-storage.h

-16
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,8 @@
2525
#include <app/util/endpoint-config-api.h>
2626
#include <lib/support/CodeUtils.h>
2727

28-
#if !defined(EMBER_SCRIPTED_TEST)
2928
#include <app/att-storage.h>
30-
#endif
31-
32-
#if !defined(ATTRIBUTE_STORAGE_CONFIGURATION) && defined(EMBER_TEST)
33-
#define ATTRIBUTE_STORAGE_CONFIGURATION "attribute-storage-test.h"
34-
#endif
35-
36-
// ATTRIBUTE_STORAGE_CONFIGURATION macro
37-
// contains the file that contains the initial set-up of the
38-
// attribute data structures. If it is missing
39-
// we use the provider sample.
40-
#ifndef ATTRIBUTE_STORAGE_CONFIGURATION
41-
// #error "Must define ATTRIBUTE_STORAGE_CONFIGURATION to specify the App. Builder default attributes file."
4229
#include <zap-generated/endpoint_config.h>
43-
#else
44-
#include ATTRIBUTE_STORAGE_CONFIGURATION
45-
#endif
4630

4731
// If we have fixed number of endpoints, then max is the same.
4832
#ifdef FIXED_ENDPOINT_COUNT

‎src/app/util/attribute-table.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@
3232

3333
using namespace chip;
3434

35-
//------------------------------------------------------------------------------
36-
37-
//------------------------------------------------------------------------------
38-
// External Declarations
39-
40-
//------------------------------------------------------------------------------
41-
// Forward Declarations
42-
43-
//------------------------------------------------------------------------------
44-
// Globals
45-
4635
EmberAfStatus emberAfWriteAttributeExternal(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr,
4736
EmberAfAttributeType dataType)
4837
{

‎src/app/util/attribute-table.h

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
#include <app/util/af.h>
2121

22-
#define ZCL_NULL_ATTRIBUTE_TABLE_INDEX 0xFFFF
23-
2422
// Remote devices writing attributes of local device
2523
EmberAfStatus emberAfWriteAttributeExternal(chip::EndpointId endpoint, chip::ClusterId cluster, chip::AttributeId attributeID,
2624
uint8_t * dataPtr, EmberAfAttributeType dataType);

‎src/app/util/config.h

-15
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,9 @@
2121

2222
#if !CHIP_CONFIG_SKIP_APP_SPECIFIC_GENERATED_HEADER_INCLUDES
2323

24-
// include generated configuration information from AppBuilder.
25-
// ZA_GENERATED_HEADER is defined in the project file
26-
#ifdef ZA_GENERATED_HEADER
27-
#include ZA_GENERATED_HEADER
28-
#else
2924
#include <zap-generated/gen_config.h>
30-
#endif
3125

32-
#ifdef ATTRIBUTE_STORAGE_CONFIGURATION
33-
#include ATTRIBUTE_STORAGE_CONFIGURATION
34-
#else
3526
#include <zap-generated/endpoint_config.h>
36-
#endif
3727

3828
#endif // !CHIP_CONFIG_SKIP_APP_SPECIFIC_GENERATED_HEADER_INCLUDES
3929

@@ -42,8 +32,3 @@
4232
#ifndef EMBER_BINDING_TABLE_SIZE
4333
#define EMBER_BINDING_TABLE_SIZE 10
4434
#endif // EMBER_BINDING_TABLE_SIZE
45-
46-
/**
47-
* @brief CHIP uses millisecond ticks
48-
*/
49-
#define MILLISECOND_TICKS_PER_SECOND 1000

‎src/platform/silabs/ThreadStackManagerImpl.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,19 @@ class ThreadStackManagerImpl final : public ThreadStackManager,
7272

7373
using ThreadStackManager::InitThreadStack;
7474
CHIP_ERROR InitThreadStack(otInstance * otInst);
75+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
76+
void RemoveAllSrpServices();
77+
#endif
7578

7679
private:
7780
// ===== Methods that implement the ThreadStackManager abstract interface.
7881

7982
CHIP_ERROR _InitThreadStack(void);
80-
83+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
84+
static void OnSrpClientRemoveCallback(otError aError, const otSrpClientHostInfo * aHostInfo,
85+
const otSrpClientService * aServices, const otSrpClientService * aRemovedServices,
86+
void * aContext);
87+
#endif
8188
// ===== Members for internal use by the following friends.
8289

8390
friend ThreadStackManager & ::chip::DeviceLayer::ThreadStackMgr(void);
@@ -87,6 +94,9 @@ class ThreadStackManagerImpl final : public ThreadStackManager,
8794
static ThreadStackManagerImpl sInstance;
8895

8996
static bool IsInitialized();
97+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
98+
TaskHandle_t srpRemoveRequester = nullptr;
99+
#endif
90100

91101
// ===== Private members for use by this class only.
92102

‎src/platform/silabs/efr32/ConfigurationManagerImpl.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,11 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
277277
}
278278

279279
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
280-
280+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
281+
ThreadStackMgrImpl().RemoveAllSrpServices();
282+
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
281283
ChipLogProgress(DeviceLayer, "Clearing Thread provision");
282284
ThreadStackMgr().ErasePersistentInfo();
283-
284285
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
285286

286287
PersistedStorage::KeyValueStoreMgrImpl().ErasePartition();

‎src/platform/silabs/efr32/ThreadStackManagerImpl.cpp

+52
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,58 @@ bool ThreadStackManagerImpl::IsInitialized()
6666
return sInstance.mThreadStackLock != NULL;
6767
}
6868

69+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
70+
/*
71+
* @brief Notifies `RemoveAllSrpServices` that the Srp Client removal has completed
72+
* and unblock the calling task.
73+
*
74+
* No data is processed.
75+
*/
76+
void ThreadStackManagerImpl::OnSrpClientRemoveCallback(otError aError, const otSrpClientHostInfo * aHostInfo,
77+
const otSrpClientService * aServices,
78+
const otSrpClientService * aRemovedServices, void * aContext)
79+
{
80+
if (ThreadStackMgrImpl().srpRemoveRequester)
81+
{
82+
xTaskNotifyGive(ThreadStackMgrImpl().srpRemoveRequester);
83+
}
84+
}
85+
86+
/*
87+
* @brief This is a utility function to remove all Thread client Srp services
88+
* established between the device and the srp server (in most cases the OTBR).
89+
* The calling task is blocked until OnSrpClientRemoveCallback.
90+
*
91+
* Note: This function is meant to be used during the factory reset sequence.
92+
* It overrides the generic SrpClient callback `OnSrpClientNotification` with
93+
* OnSrpClientRemoveCallback which doesn't process any of the callback data.
94+
*
95+
* If there is a usecase where this function would be needed in a non-Factory reset context,
96+
* OnSrpClientRemoveCallback should be extended and tied back with the GenericThreadStackManagerImpl_OpenThread
97+
* management of the srp clients.
98+
*/
99+
void ThreadStackManagerImpl::RemoveAllSrpServices()
100+
{
101+
// This check ensure that only one srp services removal is running
102+
if (ThreadStackMgrImpl().srpRemoveRequester == nullptr)
103+
{
104+
srpRemoveRequester = xTaskGetCurrentTaskHandle();
105+
otSrpClientSetCallback(OTInstance(), &OnSrpClientRemoveCallback, nullptr);
106+
InvalidateAllSrpServices();
107+
if (RemoveInvalidSrpServices() == CHIP_NO_ERROR)
108+
{
109+
// Wait for the OnSrpClientRemoveCallback.
110+
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(2000));
111+
}
112+
else
113+
{
114+
ChipLogError(DeviceLayer, "Failed to remove srp services");
115+
}
116+
ThreadStackMgrImpl().srpRemoveRequester = nullptr;
117+
}
118+
}
119+
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
120+
69121
} // namespace DeviceLayer
70122
} // namespace chip
71123

0 commit comments

Comments
 (0)
Please sign in to comment.