diff --git a/src/darwin/Framework/CHIP/MTRDevice.h b/src/darwin/Framework/CHIP/MTRDevice.h index 8673e18e2c5507..2858ae56924af9 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.h +++ b/src/darwin/Framework/CHIP/MTRDevice.h @@ -288,90 +288,6 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) completion:(MTRDeviceOpenCommissioningWindowHandler)completion MTR_AVAILABLE(ios(17.0), macos(14.0), watchos(10.0), tvos(17.0)); -/** - * - * This set of functions allows clients to store metadata for either an entire device or for a specific endpoint. - * - * 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_UNSTABLE_API; - -/** - * - * List of all client data keys stored - * - */ -- (NSArray * _Nullable)clientDataKeys MTR_UNSTABLE_API; - -/** - * - * Retrieve client metadata for a key, returns nil if no value is set - * - * @param key NSString * for the key to store the value as - */ -- (id _Nullable)clientDataForKey:(NSString *)key MTR_UNSTABLE_API; - -/** - * - * Set client metadata for a key. The value must conform to NSSecureCoding - * - * @param key NSString * for the key to store the value as - * @param value id for the value to store - */ -- (void)setClientDataForKey:(NSString *)key value:(id)value MTR_UNSTABLE_API; - -/** - * - * Remove client metadata for a key. - * - * @param key NSString * for the key to store the value as - */ -- (void)removeClientDataForKey:(NSString *)key MTR_UNSTABLE_API; - -/** - * - * List of all client data keys stored - * - */ -- (NSArray * _Nullable)clientDataKeysForEndpointID:(NSNumber *)endpointID MTR_UNSTABLE_API; - -/** - * - * Retrieve client metadata for a key, returns nil if no value is set - * - * @param key NSString * for the key to store the value as - * @param endpointID NSNumber * for the endpoint to associate the metadata with - */ -- (id _Nullable)clientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID MTR_UNSTABLE_API; - -/** - * - * Set client metadata for a key. The value must conform to NSSecureCoding. - * - * @param key NSString * for the key to store the value as. - * @param endpointID NSNumber * for the endpoint to associate the metadata with - * @param value id for the value to store - */ -- (void)setClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID value:(id)value MTR_UNSTABLE_API; - -/** - * - * Remove client metadata for a key. - * - * @param key NSString * for the key to store the value as - * @param endpointID NSNumber * for the endpoint to associate the metadata with - */ -- (void)removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID MTR_UNSTABLE_API; - /** * Download log of the desired type from the device. * diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index a668e02bbfa1ff..ddc47965f9c8b1 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -1569,86 +1569,6 @@ - (MTRBaseDevice *)newBaseDevice return [MTRBaseDevice deviceWithNodeID:self.nodeID controller:self.deviceController]; } -// Client Metadata Storage - -- (NSArray *)supportedClientDataClasses -{ - return @[ [NSData class], [NSString class], [NSNumber class], [NSDictionary class], [NSArray class] ]; -} - -- (NSArray * _Nullable)clientDataKeys -{ - return [self.temporaryMetaDataCache allKeys]; -} - -- (id _Nullable)clientDataForKey:(NSString *)key -{ - if (key == nil) - return nil; - - return [self.temporaryMetaDataCache objectForKey:[NSString stringWithFormat:@"%@:-1", key]]; -} - -- (void)setClientDataForKey:(NSString *)key value:(id)value -{ - // TODO: Check supported data types, and also if they conform to NSSecureCoding, when we store these - // TODO: Need to add a delegate method, so when this value changes we call back to the client - - if (key == nil || value == nil) - return; - - if (self.temporaryMetaDataCache == nil) { - self.temporaryMetaDataCache = [NSMutableDictionary dictionary]; - } - - [self.temporaryMetaDataCache setObject:value forKey:[NSString stringWithFormat:@"%@:-1", key]]; -} - -- (void)removeClientDataForKey:(NSString *)key -{ - if (key == nil) - return; - - [self.temporaryMetaDataCache removeObjectForKey:[NSString stringWithFormat:@"%@:-1", key]]; -} - -- (NSArray * _Nullable)clientDataKeysForEndpointID:(NSNumber *)endpointID -{ - if (endpointID == nil) - return nil; - // TODO: When hooked up to storage, enumerate this better - - return [self.temporaryMetaDataCache allKeys]; -} - -- (id _Nullable)clientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID -{ - if (key == nil || endpointID == nil) - return nil; - - return [self.temporaryMetaDataCache objectForKey:[NSString stringWithFormat:@"%@:%@", key, endpointID]]; -} - -- (void)setClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID value:(id)value -{ - if (key == nil || value == nil || endpointID == nil) - return; - - if (self.temporaryMetaDataCache == nil) { - self.temporaryMetaDataCache = [NSMutableDictionary dictionary]; - } - - [self.temporaryMetaDataCache setObject:value forKey:[NSString stringWithFormat:@"%@:%@", key, endpointID]]; -} - -- (void)removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID -{ - if (key == nil || endpointID == nil) - return; - - [self.temporaryMetaDataCache removeObjectForKey:[NSString stringWithFormat:@"%@:%@", key, endpointID]]; -} - #pragma mark Log Help - (nullable NSNumber *)_informationalNumberAtAttributePath:(MTRAttributePath *)attributePath diff --git a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm index 6e3ca4bf32b299..7d94c7585abcb0 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm +++ b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm @@ -3812,86 +3812,6 @@ - (MTRBaseDevice *)newBaseDevice return [MTRBaseDevice deviceWithNodeID:self.nodeID controller:self.deviceController]; } -// Client Metadata Storage - -- (NSArray *)supportedClientDataClasses -{ - return @[ [NSData class], [NSString class], [NSNumber class], [NSDictionary class], [NSArray class] ]; -} - -- (NSArray * _Nullable)clientDataKeys -{ - return [self.temporaryMetaDataCache allKeys]; -} - -- (id _Nullable)clientDataForKey:(NSString *)key -{ - if (key == nil) - return nil; - - return [self.temporaryMetaDataCache objectForKey:[NSString stringWithFormat:@"%@:-1", key]]; -} - -- (void)setClientDataForKey:(NSString *)key value:(id)value -{ - // TODO: Check supported data types, and also if they conform to NSSecureCoding, when we store these - // TODO: Need to add a delegate method, so when this value changes we call back to the client - - if (key == nil || value == nil) - return; - - if (self.temporaryMetaDataCache == nil) { - self.temporaryMetaDataCache = [NSMutableDictionary dictionary]; - } - - [self.temporaryMetaDataCache setObject:value forKey:[NSString stringWithFormat:@"%@:-1", key]]; -} - -- (void)removeClientDataForKey:(NSString *)key -{ - if (key == nil) - return; - - [self.temporaryMetaDataCache removeObjectForKey:[NSString stringWithFormat:@"%@:-1", key]]; -} - -- (NSArray * _Nullable)clientDataKeysForEndpointID:(NSNumber *)endpointID -{ - if (endpointID == nil) - return nil; - // TODO: When hooked up to storage, enumerate this better - - return [self.temporaryMetaDataCache allKeys]; -} - -- (id _Nullable)clientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID -{ - if (key == nil || endpointID == nil) - return nil; - - return [self.temporaryMetaDataCache objectForKey:[NSString stringWithFormat:@"%@:%@", key, endpointID]]; -} - -- (void)setClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID value:(id)value -{ - if (key == nil || value == nil || endpointID == nil) - return; - - if (self.temporaryMetaDataCache == nil) { - self.temporaryMetaDataCache = [NSMutableDictionary dictionary]; - } - - [self.temporaryMetaDataCache setObject:value forKey:[NSString stringWithFormat:@"%@:%@", key, endpointID]]; -} - -- (void)removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID -{ - if (key == nil || endpointID == nil) - return; - - [self.temporaryMetaDataCache removeObjectForKey:[NSString stringWithFormat:@"%@:%@", key, endpointID]]; -} - #pragma mark Log Help - (nullable NSNumber *)_informationalNumberAtAttributePath:(MTRAttributePath *)attributePath diff --git a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm index 5279933104a11c..46f143e4bc189e 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm +++ b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm @@ -263,43 +263,6 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID // Not Supported via XPC //- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode discriminator:(NSNumber *)discriminator duration:(NSNumber *)duration completion:(MTRDeviceOpenCommissioningWindowHandler)completion; -MTR_DEVICE_SIMPLE_REMOTE_XPC_GETTER(clientDataKeys, NSArray * _Nullable, nil, getClientDataKeysWithReply) -MTR_DEVICE_COMPLEX_REMOTE_XPC_GETTER(clientDataForKey - : (NSString *) key, id _Nullable, nil, clientDataForKey - : key withReply) - -MTR_DEVICE_SIMPLE_REMOTE_XPC_COMMAND(setClientDataForKey - : (NSString *) key value - : (id) value, setClientDataForKey - : key value - : value) -MTR_DEVICE_SIMPLE_REMOTE_XPC_COMMAND(removeClientDataForKey - : (NSString *) key, removeClientDataForKey - : key) - -MTR_DEVICE_COMPLEX_REMOTE_XPC_GETTER(clientDataKeysForEndpointID - : (NSNumber *) endpointID, NSArray * _Nullable, nil, clientDataKeysForEndpointID - : (NSNumber *) endpointID withReply) -MTR_DEVICE_COMPLEX_REMOTE_XPC_GETTER(clientDataForKey - : (NSString *) key endpointID - : (NSNumber *) endpointID, id _Nullable, nil, clientDataForKey - : key endpointID - : endpointID withReply) - -MTR_DEVICE_SIMPLE_REMOTE_XPC_COMMAND(setClientDataForKey - : (NSString *) key endpointID - : (NSNumber *) endpointID value - : (id) value, setClientDataForKey - : key endpointID - : endpointID value - : value) -MTR_DEVICE_SIMPLE_REMOTE_XPC_COMMAND(removeClientDataForKey - : (NSString *) key endpointID - : (NSNumber *) endpointID value - : (id) value, removeClientDataForKey - : key endpointID - : endpointID) - // Not Supported via XPC // - (oneway void)downloadLogOfType:(MTRDiagnosticLogType)type nodeID:(NSNumber *)nodeID timeout:(NSTimeInterval)timeout completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion; diff --git a/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCServerProtocol.h b/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCServerProtocol.h index 52a5d2228fa524..eaaa4b655e18e9 100644 --- a/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCServerProtocol.h +++ b/src/darwin/Framework/CHIP/XPC Protocol/MTRXPCServerProtocol.h @@ -27,25 +27,14 @@ MTR_NEWLY_AVAILABLE - (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID getEstimatedSubscriptionLatencyWithReply:(void (^)(NSNumber * _Nullable estimatedSubscriptionLatency))reply; - (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID readAttributeWithEndpointID:(NSNumber *)endpointID clusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID params:(MTRReadParams * _Nullable)params withReply:(void (^)(NSDictionary * _Nullable))reply; -- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID writeAttributeWithEndpointID:(NSNumber *)endpointID clusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID value:(id _Nullable)value expectedValueInterval:(NSNumber * _Nullable)expectedValueInterval timedWriteTimeout:(NSNumber * _Nullable)timeout; +- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID writeAttributeWithEndpointID:(NSNumber *)endpointID clusterID:(NSNumber *)clusterID attributeID:(NSNumber *)attributeID value:(id)value expectedValueInterval:(NSNumber * _Nullable)expectedValueInterval timedWriteTimeout:(NSNumber * _Nullable)timeout; - (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID invokeCommandWithEndpointID:(NSNumber *)endpointID clusterID:(NSNumber *)clusterID commandID:(NSNumber *)commandID commandFields:(id)commandFields expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueInterval timedInvokeTimeout:(NSNumber * _Nullable)timeout serverSideProcessingTimeout:(NSNumber * _Nullable)serverSideProcessingTimeout completion:(MTRDeviceResponseHandler)completion; -// Not Supported via XPC -//- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode discriminator:(NSNumber *)discriminator duration:(NSNumber *)duration completion:(MTRDeviceOpenCommissioningWindowHandler)completion; +- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode discriminator:(NSNumber *)discriminator duration:(NSNumber *)duration completion:(MTRDeviceOpenCommissioningWindowHandler)completion; -- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID getClientDataKeysWithReply:(void (^)(NSArray * _Nullable))reply; -- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID clientDataForKey:(NSString *)key withReply:(void (^)(id _Nullable))reply; -- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID setClientDataForKey:(NSString *)key value:(id)value; -- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID removeClientDataForKey:(NSString *)key; -- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID clientDataKeysForEndpointID:(NSNumber *)endpointID withReply:(void (^)(NSArray * _Nullable))reply; -- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID clientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID withReply:(void (^)(id _Nullable))reply; -- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID setClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID value:(id _Nullable)value; -- (oneway void)deviceController:(NSUUID *)controller nodeID:(NSNumber *)nodeID removeClientDataForKey:(NSString *)key endpointID:(NSNumber *)endpointID; - -// Not Supported via XPC -// - (oneway void)downloadLogOfType:(MTRDiagnosticLogType)type nodeID:(NSNumber *)nodeID timeout:(NSTimeInterval)timeout completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion; +- (oneway void)downloadLogOfType:(MTRDiagnosticLogType)type nodeID:(NSNumber *)nodeID timeout:(NSTimeInterval)timeout completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion; @end MTR_NEWLY_AVAILABLE @@ -55,19 +44,18 @@ MTR_NEWLY_AVAILABLE - (oneway void)deviceController:(NSUUID *)controller getUniqueIdentifierWithReply:(void (^)(NSUUID *))reply; - (oneway void)deviceController:(NSUUID *)controller controllerNodeIDWithReply:(void (^)(NSNumber * nodeID))reply; -// Not Supported via XPC -// - (oneway void)deviceController:(NSUUID *)controller setupCommissioningSessionWithPayload:(MTRSetupPayload *)payload newNodeID:(NSNumber *)newNodeID withReply:(void(^)(BOOL success, NSError * _Nullable error))reply; -// - (oneway void)deviceController:(NSUUID *)controller setupCommissioningSessionWithDiscoveredDevice:(MTRCommissionableBrowserResult *)discoveredDevice payload:(MTRSetupPayload *)payload newNodeID:(NSNumber *)newNodeID withReply:(void(^)(BOOL success, NSError * _Nullable error))reply; -// - (oneway void)deviceController:(NSUUID *)controller commissionNodeWithID:(NSNumber *)nodeID commissioningParams:(MTRCommissioningParameters *)commissioningParams withReply:(void(^)(BOOL success, NSError * _Nullable error))reply; -// - (oneway void)deviceController:(NSUUID *)controller continueCommissioningDevice:(void *)opaqueDeviceHandle ignoreAttestationFailure:(BOOL)ignoreAttestationFailure withReply:(void(^)(BOOL success, NSError * _Nullable error))reply; -// - (oneway void)deviceController:(NSUUID *)controller cancelCommissioningForNodeID:(NSNumber *)nodeID withReply:(void(^)(BOOL success, NSError * _Nullable error))reply; +// - (oneway void)deviceController:(NSUUID *)controller setupCommissioningSessionWithPayload:(MTRSetupPayload *)payload newNodeID:(NSNumber *)newNodeID withReply:(void (^)(BOOL success, NSError * _Nullable error))reply; +// - (oneway void)deviceController:(NSUUID *)controller setupCommissioningSessionWithDiscoveredDevice:(MTRCommissionableBrowserResult *)discoveredDevice payload:(MTRSetupPayload *)payload newNodeID:(NSNumber *)newNodeID withReply:(void (^)(BOOL success, NSError * _Nullable error))reply; +// - (oneway void)deviceController:(NSUUID *)controller commissionNodeWithID:(NSNumber *)nodeID commissioningParams:(MTRCommissioningParameters *)commissioningParams withReply:(void (^)(BOOL success, NSError * _Nullable error))reply; +// - (oneway void)deviceController:(NSUUID *)controller continueCommissioningDevice:(void *)opaqueDeviceHandle ignoreAttestationFailure:(BOOL)ignoreAttestationFailure withReply:(void (^)(BOOL success, NSError * _Nullable error))reply; +// - (oneway void)deviceController:(NSUUID *)controller cancelCommissioningForNodeID:(NSNumber *)nodeID withReply:(void (^)(BOOL success, NSError * _Nullable error))reply; // - (nullable MTRBaseDevice *)deviceController:(NSUUID *)controller deviceBeingCommissionedWithNodeID:(NSNumber *)nodeID error:(NSError * __autoreleasing *)error; -// - (oneway void)deviceController:(NSUUID *)controller startBrowseForCommissionables:(id)delegate withReply:(void(^)(BOOL success))reply; -// - (oneway void)deviceController:(NSUUID *)controller stopBrowseForCommissionablesWithReply:(void(^)(BOOL success))reply; -// - (oneway void)deviceController:(NSUUID *)controller attestationChallengeForDeviceID:(NSNumber *)deviceID withReply:(void(^)(NSData * _Nullable))reply; +// - (oneway void)deviceController:(NSUUID *)controller startBrowseForCommissionables:(id)delegate withReply:(void (^)(BOOL success))reply; +// - (oneway void)deviceController:(NSUUID *)controller stopBrowseForCommissionablesWithReply:(void (^)(BOOL success))reply; +// - (oneway void)deviceController:(NSUUID *)controller attestationChallengeForDeviceID:(NSNumber *)deviceID withReply:(void (^)(NSData * _Nullable))reply; -//- (oneway void)deviceController:(NSUUID *)controller addServerEndpoint:(MTRServerEndpoint *)endpoint withReply:(void(^)(BOOL success))reply; -//- (oneway void)deviceController:(NSUUID *)controller removeServerEndpoint:(MTRServerEndpoint *)endpoint; +// - (oneway void)deviceController:(NSUUID *)controller addServerEndpoint:(MTRServerEndpoint *)endpoint withReply:(void (^)(BOOL success))reply; +// - (oneway void)deviceController:(NSUUID *)controller removeServerEndpoint:(MTRServerEndpoint *)endpoint; - (oneway void)deviceController:(NSUUID *)controller shutdownDeviceController:(NSUUID *)controller; - (oneway void)deviceController:(NSUUID *)controller registerNodeID:(NSNumber *)nodeID;