Skip to content

Commit

Permalink
adding docs and supportedClientDataClasses
Browse files Browse the repository at this point in the history
  • Loading branch information
woody-apple committed Dec 11, 2023
1 parent 17ad635 commit dff23eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/darwin/Framework/CHIP/MTRDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,20 @@ typedef NS_ENUM(NSUInteger, MTRDeviceState) {
/**
*
* This set of functions allows clients to store metadata for either an entire device or for a specific endpoint.
* Values must conform to NSSecureCoding
*
* Notes:
* • Client data will be removed automatically when devices are deleted from the fabric
* • Supported client data object types are currently only:
* NSData, NSString, NSArray, NSDictionary, NSNumber
*/

/**
*
* List of all client data types supported
*
*/
- (NSArray *)supportedClientDataClasses MTR_NEWLY_AVAILABLE;

/**
*
* List of all client data keys stored
Expand Down
6 changes: 6 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,10 @@ - (MTRBaseDevice *)newBaseDevice

// Client Metadata Storage

- (NSArray *)supportedClientDataClasses {
return @[[NSData class], [NSString class], [NSNumber class], [NSDictionary class], [NSArray class]];
}

- (NSArray * _Nullable)clientDataKeys {
return [self.temporaryMetaDataCache allKeys];
}
Expand All @@ -1736,6 +1740,8 @@ - (NSArray * _Nullable)clientDataKeys {

- (void)setClientDataForKey:(NSString *)key value:(id<NSSecureCoding>)value
{
// TODO: Check supported data types, and also if they conform to NSSecureCoding, when we store these

if ( key == nil || value == nil ) return;

if (self.temporaryMetaDataCache == nil) {
Expand Down

0 comments on commit dff23eb

Please sign in to comment.