Skip to content

Commit

Permalink
Add a way for a client to know if the device cache is primed in Darwin (
Browse files Browse the repository at this point in the history
project-chip#32556)

* Initial commit

* Restyled by whitespace

* Restyled by clang-format

* Update src/darwin/Framework/CHIP/MTRDevice.mm

Co-authored-by: Anush Nadathur <[email protected]>

* Update src/darwin/Framework/CHIP/MTRDevice.h

Co-authored-by: Karsten Sperling <[email protected]>

* Adding header

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Anush Nadathur <[email protected]>
Co-authored-by: Karsten Sperling <[email protected]>
  • Loading branch information
4 people authored Mar 13, 2024
1 parent c9dc927 commit 1160f97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
*/
@property (nonatomic, readonly) MTRDeviceState state;

/**
* Is the state cache primed for this device?
*
* This verifies that both the MTRDeviceController has a storage delegate, and a subscription has been set up and the resulting state has been cached. If this is true this means most state is ready to cache and will not require a round trip to the accessory.
*
*/
@property (readonly) BOOL deviceCachePrimed;

/**
* The estimated device system start time.
*
Expand Down
7 changes: 7 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#import "MTRError_Internal.h"
#import "MTREventTLVValueDecoder_Internal.h"
#import "MTRLogging_Internal.h"
#import "MTRUnfairLock.h"
#import "zap-generated/MTRCommandPayloads_Internal.h"

#include "lib/core/CHIPError.h"
Expand Down Expand Up @@ -2017,6 +2018,12 @@ - (void)setAttributeValues:(NSArray<NSDictionary *> *)attributeValues reportChan
os_unfair_lock_unlock(&self->_lock);
}

- (BOOL)deviceCachePrimed
{
std::lock_guard lock(_lock);
return [self _isCachePrimedWithInitialConfigurationData];
}

// If value is non-nil, associate with expectedValueID
// If value is nil, remove only if expectedValueID matches
// previousValue is an out parameter
Expand Down

0 comments on commit 1160f97

Please sign in to comment.