From 8d84f81fba95489efc1ec73f6f8b0e8d0ccb9fdf Mon Sep 17 00:00:00 2001 From: Justin Wood <woody@apple.com> Date: Fri, 1 Jul 2022 23:16:47 -0700 Subject: [PATCH] Hopefully final rename --- .../common/CHIPCommandStorageDelegate.mm | 14 ++-- .../commands/common/MTRError.mm | 22 +++--- .../commands/common/MTRLogging.h | 12 ++-- .../Framework Helpers/DefaultsUtils.h | 28 ++++---- .../Framework Helpers/DefaultsUtils.m | 62 ++++++++-------- .../Bindings/BindingsViewController.m | 6 +- .../View Controllers/DeviceSelector.m | 4 +- .../Enumeration/EnumerateViewController.m | 2 +- .../Fabric/FabricUIViewController.m | 14 ++-- .../MultiAdmin/MultiAdminViewController.m | 4 +- .../OnOffCluster/OnOffViewController.m | 12 ++-- .../QRCode/QRCodeViewController.m | 30 ++++---- .../TemperatureSensorViewController.m | 4 +- .../UnpairDevicesViewController.m | 2 +- .../WiFi/WiFiViewController.m | 12 ++-- .../CHIP/MTRAttributeCacheContainer.mm | 12 ++-- .../Framework/CHIP/MTRControllerFactory.mm | 52 +++++++------- src/darwin/Framework/CHIP/MTRDevice.mm | 72 +++++++++---------- .../Framework/CHIP/MTRDeviceController.mm | 36 +++++----- .../CHIP/MTRDeviceControllerOverXPC.m | 24 +++---- .../CHIP/MTRDeviceControllerStartupParams.mm | 38 +++++----- .../CHIP/MTRDeviceControllerXPCConnection.m | 10 +-- src/darwin/Framework/CHIP/MTRDeviceOverXPC.m | 38 +++++----- src/darwin/Framework/CHIP/MTRLogging.h | 17 ++--- .../CHIP/MTROperationalCredentialsDelegate.mm | 2 +- .../Framework/CHIP/MTRP256KeypairBridge.mm | 18 ++--- .../CHIP/MTRThreadOperationalDataset.mm | 12 ++-- .../CHIPTests/MTRXPCListenerSampleTests.m | 2 +- 28 files changed, 278 insertions(+), 283 deletions(-) diff --git a/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.mm b/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.mm index 03361e587f949d..7712eab13cd29f 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.mm +++ b/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.mm @@ -4,7 +4,7 @@ NSString * const kCHIPToolDefaultsDomain = @"com.apple.chiptool"; -id CHIPGetDomainValueForKey(NSString * domain, NSString * key) +id MTRGetDomainValueForKey(NSString * domain, NSString * key) { id value = (id) CFBridgingRelease(CFPreferencesCopyAppValue((CFStringRef) key, (CFStringRef) domain)); if (value) { @@ -13,13 +13,13 @@ id CHIPGetDomainValueForKey(NSString * domain, NSString * key) return nil; } -BOOL CHIPSetDomainValueForKey(NSString * domain, NSString * key, id value) +BOOL MTRSetDomainValueForKey(NSString * domain, NSString * key, id value) { CFPreferencesSetAppValue((CFStringRef) key, (__bridge CFPropertyListRef _Nullable)(value), (CFStringRef) domain); return CFPreferencesAppSynchronize((CFStringRef) domain) == true; } -BOOL CHIPRemoveDomainValueForKey(NSString * domain, NSString * key) +BOOL MTRRemoveDomainValueForKey(NSString * domain, NSString * key) { CFPreferencesSetAppValue((CFStringRef) key, nullptr, (CFStringRef) domain); return CFPreferencesAppSynchronize((CFStringRef) domain) == true; @@ -42,7 +42,7 @@ BOOL CHIPClearAllDomain(NSString * domain) NSLog(@"Removing keys: %@ %@", allKeys, domain); for (id key in allKeys) { NSLog(@"Removing key: %@", key); - if (!CHIPRemoveDomainValueForKey(domain, (NSString *) key)) { + if (!MTRRemoveDomainValueForKey(domain, (NSString *) key)) { return NO; } } @@ -60,7 +60,7 @@ - (BOOL)deleteAllStorage - (nullable NSData *)storageDataForKey:(NSString *)key { - NSData * value = CHIPGetDomainValueForKey(kCHIPToolDefaultsDomain, key); + NSData * value = MTRGetDomainValueForKey(kCHIPToolDefaultsDomain, key); NSLog(@"CHIPPersistentStorageDelegate Get Value for Key: %@, value %@", key, value); return value; } @@ -72,10 +72,10 @@ - (BOOL)setStorageData:(NSData *)value forKey:(NSString *)key - (BOOL)removeStorageDataForKey:(NSString *)key { - if (CHIPGetDomainValueForKey(kCHIPToolDefaultsDomain, key) == nil) { + if (MTRGetDomainValueForKey(kCHIPToolDefaultsDomain, key) == nil) { return NO; } - return CHIPRemoveDomainValueForKey(kCHIPToolDefaultsDomain, key); + return MTRRemoveDomainValueForKey(kCHIPToolDefaultsDomain, key); } @end diff --git a/examples/darwin-framework-tool/commands/common/MTRError.mm b/examples/darwin-framework-tool/commands/common/MTRError.mm index 97a9d07ce2990a..5d0abd4b0137e8 100644 --- a/examples/darwin-framework-tool/commands/common/MTRError.mm +++ b/examples/darwin-framework-tool/commands/common/MTRError.mm @@ -102,7 +102,7 @@ id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) int64_t val; CHIP_ERROR err = data->Get(val); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV signed integer decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV signed integer decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:MTRSignedIntegerValueType, MTRTypeKey, [NSNumber numberWithLongLong:val], @@ -112,7 +112,7 @@ id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) uint64_t val; CHIP_ERROR err = data->Get(val); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV unsigned integer decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV unsigned integer decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:MTRUnsignedIntegerValueType, MTRTypeKey, @@ -122,7 +122,7 @@ id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) bool val; CHIP_ERROR err = data->Get(val); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV boolean decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV boolean decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary @@ -138,7 +138,7 @@ id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) double val; err = data->Get(val); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV floating point decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV floating point decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary @@ -149,7 +149,7 @@ id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) const uint8_t * ptr; CHIP_ERROR err = data->GetDataPtr(ptr); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV UTF8String decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV UTF8String decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:MTRUTF8StringValueType, MTRTypeKey, @@ -160,7 +160,7 @@ id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) const uint8_t * ptr; CHIP_ERROR err = data->GetDataPtr(ptr); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV ByteString decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV ByteString decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:MTROctetStringValueType, MTRTypeKey, @@ -186,7 +186,7 @@ id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) chip::TLV::TLVType tlvType; CHIP_ERROR err = data->EnterContainer(tlvType); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV container entering failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV container entering failed", chip::ErrorStr(err)); return nil; } NSMutableArray * array = [[NSMutableArray alloc] init]; @@ -194,7 +194,7 @@ id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) chip::TLV::Tag tag = data->GetTag(); id value = NSObjectFromCHIPTLV(data); if (value == nullptr) { - CHIP_LOG_ERROR("Error when decoding TLV container"); + MTR_LOG_ERROR("Error when decoding TLV container"); return nil; } NSMutableDictionary * arrayElement = [NSMutableDictionary dictionary]; @@ -205,18 +205,18 @@ id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) [array addObject:arrayElement]; } if (err != CHIP_END_OF_TLV) { - CHIP_LOG_ERROR("Error(%s): TLV container decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV container decoding failed", chip::ErrorStr(err)); return nil; } err = data->ExitContainer(tlvType); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV container exiting failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV container exiting failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:typeName, MTRTypeKey, array, MTRValueKey, nil]; } default: - CHIP_LOG_ERROR("Error: Unsupported TLV type for conversion: %u", (unsigned) data->GetType()); + MTR_LOG_ERROR("Error: Unsupported TLV type for conversion: %u", (unsigned) data->GetType()); return nil; } } diff --git a/examples/darwin-framework-tool/commands/common/MTRLogging.h b/examples/darwin-framework-tool/commands/common/MTRLogging.h index 2d76a657e85745..4835e4f159d447 100644 --- a/examples/darwin-framework-tool/commands/common/MTRLogging.h +++ b/examples/darwin-framework-tool/commands/common/MTRLogging.h @@ -22,15 +22,15 @@ #import <os/log.h> #if DEBUG -#define CHIP_LOG_DEBUG(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) -#define CHIP_LOG_ERROR(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) -#define CHIP_LOG_METHOD_ENTRY() \ +#define MTR_LOG_DEBUG(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) +#define MTR_LOG_ERROR(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) +#define MTR_LOG_METHOD_ENTRY() \ ({ os_log(OS_LOG_DEFAULT, "[<%@: %p> %@]", NSStringFromClass([self class]), self, NSStringFromSelector(_cmd)); }) #else -#define CHIP_LOG_DEBUG(...) -#define CHIP_LOG_ERROR(...) -#define CHIP_LOG_METHOD_ENTRY() ({}) +#define MTR_LOG_DEBUG(...) +#define MTR_LOG_ERROR(...) +#define MTR_LOG_METHOD_ENTRY() ({}) #endif diff --git a/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.h b/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.h index 45b717d4943928..8b3320ec2992b5 100644 --- a/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.h +++ b/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.h @@ -25,21 +25,21 @@ extern NSString * const kNetworkSSIDDefaultsKey; extern NSString * const kNetworkPasswordDefaultsKey; extern NSString * const kFabricIdKey; -MTRDeviceController * _Nullable InitializeCHIP(void); -MTRDeviceController * _Nullable CHIPRestartController(MTRDeviceController * controller); -id _Nullable CHIPGetDomainValueForKey(NSString * domain, NSString * key); -BOOL CHIPSetDomainValueForKey(NSString * domain, NSString * key, id _Nullable value); -void CHIPRemoveDomainValueForKey(NSString * domain, NSString * key); -uint64_t CHIPGetNextAvailableDeviceID(void); +MTRDeviceController * _Nullable InitializeMTR(void); +MTRDeviceController * _Nullable MTRRestartController(MTRDeviceController * controller); +id _Nullable MTRGetDomainValueForKey(NSString * domain, NSString * key); +BOOL MTRSetDomainValueForKey(NSString * domain, NSString * key, id _Nullable value); +void MTRRemoveDomainValueForKey(NSString * domain, NSString * key); +uint64_t MTRGetNextAvailableDeviceID(void); NSString * KeyForPairedDevice(uint64_t id); -uint64_t CHIPGetLastPairedDeviceId(void); -void CHIPSetNextAvailableDeviceID(uint64_t id); -void CHIPSetDevicePaired(uint64_t id, BOOL paired); -BOOL CHIPIsDevicePaired(uint64_t id); -BOOL CHIPGetConnectedDevice(MTRDeviceConnectionCallback completionHandler); -BOOL CHIPGetConnectedDeviceWithID(uint64_t deviceId, MTRDeviceConnectionCallback completionHandler); -void CHIPUnpairDeviceWithID(uint64_t deviceId); -MTRDevice * _Nullable CHIPGetDeviceBeingCommissioned(void); +uint64_t MTRGetLastPairedDeviceId(void); +void MTRSetNextAvailableDeviceID(uint64_t id); +void MTRSetDevicePaired(uint64_t id, BOOL paired); +BOOL MTRIsDevicePaired(uint64_t id); +BOOL MTRGetConnectedDevice(MTRDeviceConnectionCallback completionHandler); +BOOL MTRGetConnectedDeviceWithID(uint64_t deviceId, MTRDeviceConnectionCallback completionHandler); +void MTRUnpairDeviceWithID(uint64_t deviceId); +MTRDevice * _Nullable MTRGetDeviceBeingCommissioned(void); @interface CHIPToolPersistentStorageDelegate : NSObject <MTRPersistentStorageDelegate> - (nullable NSData *)storageDataForKey:(NSString *)key; diff --git a/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.m b/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.m index bdaca09d32b0a5..8ea446ca62180b 100644 --- a/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.m +++ b/src/darwin/CHIPTool/CHIPTool/Framework Helpers/DefaultsUtils.m @@ -25,7 +25,7 @@ NSString * const kFabricIdKey = @"fabricId"; NSString * const kDevicePairedKey = @"Paired"; -id CHIPGetDomainValueForKey(NSString * domain, NSString * key) +id MTRGetDomainValueForKey(NSString * domain, NSString * key) { id value = (id) CFBridgingRelease(CFPreferencesCopyAppValue((CFStringRef) key, (CFStringRef) domain)); if (value) { @@ -34,24 +34,24 @@ id CHIPGetDomainValueForKey(NSString * domain, NSString * key) return nil; } -BOOL CHIPSetDomainValueForKey(NSString * domain, NSString * key, id value) +BOOL MTRSetDomainValueForKey(NSString * domain, NSString * key, id value) { CFPreferencesSetAppValue((CFStringRef) key, (__bridge CFPropertyListRef _Nullable)(value), (CFStringRef) domain); return CFPreferencesAppSynchronize((CFStringRef) domain) == true; } -void CHIPRemoveDomainValueForKey(NSString * domain, NSString * key) +void MTRRemoveDomainValueForKey(NSString * domain, NSString * key) { CFPreferencesSetAppValue((CFStringRef) key, NULL, (CFStringRef) domain); CFPreferencesAppSynchronize((CFStringRef) domain); } -uint64_t CHIPGetNextAvailableDeviceID(void) +uint64_t MTRGetNextAvailableDeviceID(void) { uint64_t nextAvailableDeviceIdentifier = 1; - NSNumber * value = CHIPGetDomainValueForKey(MTRToolDefaultsDomain, MTRNextAvailableDeviceIDKey); + NSNumber * value = MTRGetDomainValueForKey(MTRToolDefaultsDomain, MTRNextAvailableDeviceIDKey); if (!value) { - CHIPSetDomainValueForKey(MTRToolDefaultsDomain, MTRNextAvailableDeviceIDKey, + MTRSetDomainValueForKey(MTRToolDefaultsDomain, MTRNextAvailableDeviceIDKey, [NSNumber numberWithUnsignedLongLong:nextAvailableDeviceIdentifier]); } else { nextAvailableDeviceIdentifier = [value unsignedLongLongValue]; @@ -60,9 +60,9 @@ uint64_t CHIPGetNextAvailableDeviceID(void) return nextAvailableDeviceIdentifier; } -void CHIPSetNextAvailableDeviceID(uint64_t id) +void MTRSetNextAvailableDeviceID(uint64_t id) { - CHIPSetDomainValueForKey(MTRToolDefaultsDomain, MTRNextAvailableDeviceIDKey, [NSNumber numberWithUnsignedLongLong:id]); + MTRSetDomainValueForKey(MTRToolDefaultsDomain, MTRNextAvailableDeviceIDKey, [NSNumber numberWithUnsignedLongLong:id]); } static CHIPToolPersistentStorageDelegate * storage = nil; @@ -71,7 +71,7 @@ void CHIPSetNextAvailableDeviceID(uint64_t id) static MTRDeviceController * sController = nil; -MTRDeviceController * InitializeCHIP(void) +MTRDeviceController * InitializeMTR(void) { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -120,60 +120,60 @@ void CHIPSetNextAvailableDeviceID(uint64_t id) return sController; } -uint64_t CHIPGetLastPairedDeviceId(void) +uint64_t MTRGetLastPairedDeviceId(void) { - uint64_t deviceId = CHIPGetNextAvailableDeviceID(); + uint64_t deviceId = MTRGetNextAvailableDeviceID(); if (deviceId > 1) { deviceId--; } return deviceId; } -BOOL CHIPGetConnectedDevice(MTRDeviceConnectionCallback completionHandler) +BOOL MTRGetConnectedDevice(MTRDeviceConnectionCallback completionHandler) { - MTRDeviceController * controller = InitializeCHIP(); + MTRDeviceController * controller = InitializeMTR(); // Let's use the last device that was paired - uint64_t deviceId = CHIPGetLastPairedDeviceId(); + uint64_t deviceId = MTRGetLastPairedDeviceId(); return [controller getDevice:deviceId queue:dispatch_get_main_queue() completionHandler:completionHandler]; } -MTRDevice * CHIPGetDeviceBeingCommissioned(void) +MTRDevice * MTRGetDeviceBeingCommissioned(void) { NSError * error; - MTRDeviceController * controller = InitializeCHIP(); - MTRDevice * device = [controller getDeviceBeingCommissioned:CHIPGetLastPairedDeviceId() error:&error]; + MTRDeviceController * controller = InitializeMTR(); + MTRDevice * device = [controller getDeviceBeingCommissioned:MTRGetLastPairedDeviceId() error:&error]; if (error) { - NSLog(@"Error retrieving device being commissioned for deviceId %llu", CHIPGetLastPairedDeviceId()); + NSLog(@"Error retrieving device being commissioned for deviceId %llu", MTRGetLastPairedDeviceId()); return nil; } return device; } -BOOL CHIPGetConnectedDeviceWithID(uint64_t deviceId, MTRDeviceConnectionCallback completionHandler) +BOOL MTRGetConnectedDeviceWithID(uint64_t deviceId, MTRDeviceConnectionCallback completionHandler) { - MTRDeviceController * controller = InitializeCHIP(); + MTRDeviceController * controller = InitializeMTR(); return [controller getDevice:deviceId queue:dispatch_get_main_queue() completionHandler:completionHandler]; } -BOOL CHIPIsDevicePaired(uint64_t deviceId) +BOOL MTRIsDevicePaired(uint64_t deviceId) { - NSString * PairedString = CHIPGetDomainValueForKey(MTRToolDefaultsDomain, KeyForPairedDevice(deviceId)); + NSString * PairedString = MTRGetDomainValueForKey(MTRToolDefaultsDomain, KeyForPairedDevice(deviceId)); return [PairedString boolValue]; } -void CHIPSetDevicePaired(uint64_t deviceId, BOOL paired) +void MTRSetDevicePaired(uint64_t deviceId, BOOL paired) { - CHIPSetDomainValueForKey(MTRToolDefaultsDomain, KeyForPairedDevice(deviceId), paired ? @"YES" : @"NO"); + MTRSetDomainValueForKey(MTRToolDefaultsDomain, KeyForPairedDevice(deviceId), paired ? @"YES" : @"NO"); } NSString * KeyForPairedDevice(uint64_t deviceId) { return [NSString stringWithFormat:@"%@%llu", kDevicePairedKey, deviceId]; } -void CHIPUnpairDeviceWithID(uint64_t deviceId) +void MTRUnpairDeviceWithID(uint64_t deviceId) { - CHIPSetDevicePaired(deviceId, NO); - CHIPGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable device, NSError * _Nullable error) { + MTRSetDevicePaired(deviceId, NO); + MTRGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable device, NSError * _Nullable error) { if (error) { NSLog(@"Failed to unpair device %llu still removing from CHIPTool. %@", deviceId, error); return; @@ -211,22 +211,22 @@ @implementation CHIPToolPersistentStorageDelegate - (nullable NSData *)storageDataForKey:(NSString *)key { - NSData * value = CHIPGetDomainValueForKey(MTRToolDefaultsDomain, key); + NSData * value = MTRGetDomainValueForKey(MTRToolDefaultsDomain, key); NSLog(@"MTRPersistentStorageDelegate Get Value for Key: %@, value %@", key, value); return value; } - (BOOL)setStorageData:(NSData *)value forKey:(NSString *)key { - return CHIPSetDomainValueForKey(MTRToolDefaultsDomain, key, value); + return MTRSetDomainValueForKey(MTRToolDefaultsDomain, key, value); } - (BOOL)removeStorageDataForKey:(NSString *)key { - if (CHIPGetDomainValueForKey(MTRToolDefaultsDomain, key) == nil) { + if (MTRGetDomainValueForKey(MTRToolDefaultsDomain, key) == nil) { return NO; } - CHIPRemoveDomainValueForKey(MTRToolDefaultsDomain, key); + MTRRemoveDomainValueForKey(MTRToolDefaultsDomain, key); return YES; } diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/Bindings/BindingsViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/Bindings/BindingsViewController.m index 42041ec34fc0b5..4e31fc87ca32e5 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/Bindings/BindingsViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/Bindings/BindingsViewController.m @@ -118,7 +118,7 @@ - (void)setupUI - (void)_clearTextFields { - MTRDeviceController * chipController = InitializeCHIP(); + MTRDeviceController * chipController = InitializeMTR(); _nodeIDTextField.text = [NSString stringWithFormat:@"%@", chipController.controllerNodeId]; _endpointIDTextField.text = @"1"; _groupIDTextField.text = @"0"; @@ -134,7 +134,7 @@ - (IBAction)bind:(id)sender [scanner scanUnsignedLongLong:&nodeId]; // TODO Binding Support was removed from ObjC Clusters.h - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { NSString * resultString = [NSString stringWithFormat:@"Not Supported"]; NSLog(resultString, nil); @@ -150,7 +150,7 @@ - (IBAction)bind:(id)sender - (IBAction)unbind:(id)sender { - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { NSString * resultString = [NSString stringWithFormat:@"Not Supported"]; NSLog(resultString, nil); diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/DeviceSelector.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/DeviceSelector.m index e9958e23b96b03..426fdb95eb50d6 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/DeviceSelector.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/DeviceSelector.m @@ -41,10 +41,10 @@ - (id)init - (void)refreshDeviceList { - uint64_t nextDeviceID = CHIPGetNextAvailableDeviceID(); + uint64_t nextDeviceID = MTRGetNextAvailableDeviceID(); _deviceList = [NSMutableArray new]; for (uint64_t i = 0; i < nextDeviceID; i++) { - if (CHIPIsDevicePaired(i)) { + if (MTRIsDevicePaired(i)) { [_deviceList addObject:[@(i) stringValue]]; } } diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/Enumeration/EnumerateViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/Enumeration/EnumerateViewController.m index 7e0255f9bb6684..e8f9d37e6cb4dc 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/Enumeration/EnumerateViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/Enumeration/EnumerateViewController.m @@ -108,7 +108,7 @@ - (IBAction)sendMessage:(id)sender // 4. Success? - (void)enumerate { - CHIPGetConnectedDevice(^(MTRDevice * _Nullable device, NSError * _Nullable error) { + MTRGetConnectedDevice(^(MTRDevice * _Nullable device, NSError * _Nullable error) { if (error) { NSString * resultLog = [[NSString alloc] initWithFormat:@"Unable to get connected device: Error: %@", error]; [self updateResult:resultLog]; diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/Fabric/FabricUIViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/Fabric/FabricUIViewController.m index bb5e7bd9c4d965..6d281c0312d80f 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/Fabric/FabricUIViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/Fabric/FabricUIViewController.m @@ -217,7 +217,7 @@ - (void)updateFabricsListUIWithFabrics:(NSArray<MTROperationalCredentialsCluster - (void)fetchCommissionedFabricsNumber { NSLog(@"Fetching the commissioned fabrics attribute"); - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { MTROperationalCredentials * cluster = [[MTROperationalCredentials alloc] initWithDevice:chipDevice endpoint:0 @@ -265,7 +265,7 @@ - (void)fetchCommissionedFabricsNumber - (void)fetchFabricsList { NSLog(@"Request to fetchFabricsList"); - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { MTROperationalCredentials * cluster = [[MTROperationalCredentials alloc] initWithDevice:chipDevice endpoint:0 @@ -320,7 +320,7 @@ - (IBAction)removeAllFabricsButtonPressed:(id)sender actionWithTitle:@"Remove" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (!chipDevice) { [self updateResult:[NSString @@ -365,7 +365,7 @@ - (IBAction)removeAllFabricsButtonPressed:(id)sender completionHandler:^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, NSError * _Nullable error) { if (!error) { - CHIPSetDevicePaired(CHIPGetLastPairedDeviceId(), NO); + MTRSetDevicePaired(MTRGetLastPairedDeviceId(), NO); } [self updateResult:[NSString stringWithFormat:@"Removed own Fabric Index %@ with Error %@", @@ -398,7 +398,7 @@ - (IBAction)updateFabricLabelButtonPressed:(id)sender NSLog(@"Request to updateFabricLabel %@", label); [self.updateFabricLabelTextField resignFirstResponder]; - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { MTROperationalCredentials * cluster = [[MTROperationalCredentials alloc] initWithDevice:chipDevice endpoint:0 @@ -451,7 +451,7 @@ - (IBAction)removeFabricButtonPressed:(id)sender { NSNumber * fabricIndex = @([_removeFabricTextField.text intValue]); NSLog(@"Request to fabric at index %@", fabricIndex); - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { [self updateResult:[NSString stringWithFormat:@"removeFabric command sent for fabricIndex %@.", fabricIndex] isError:NO]; @@ -466,7 +466,7 @@ - (IBAction)removeFabricButtonPressed:(id)sender MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, NSError * _Nullable error) { if (!error) { if (fabricIndex == self.currentFabricIndex) { - CHIPSetDevicePaired(CHIPGetLastPairedDeviceId(), NO); + MTRSetDevicePaired(MTRGetLastPairedDeviceId(), NO); } } [self updateResult:[NSString stringWithFormat:@"Finished removing fabric Index %@ with Error :%@", diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/MultiAdmin/MultiAdminViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/MultiAdmin/MultiAdminViewController.m index 3fa8e600e0a2fb..4cea3ca7770208 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/MultiAdmin/MultiAdminViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/MultiAdmin/MultiAdminViewController.m @@ -201,7 +201,7 @@ - (IBAction)openPairingWindow:(id)sender { uint32_t setupPIN = arc4random(); [_deviceSelector forSelectedDevices:^(uint64_t deviceId) { - if (CHIPGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { NSString * timeoutStr = [self.timeoutField text]; if (timeoutStr.length == 0) { @@ -211,7 +211,7 @@ - (IBAction)openPairingWindow:(id)sender NSString * output; NSError * error; - MTRDeviceController * controller = InitializeCHIP(); + MTRDeviceController * controller = InitializeMTR(); if ([self.useOnboardingTokenSwitch isOn]) { NSString * discriminatorStr = [self.discriminatorField text]; if (discriminatorStr.length == 0) { diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/OnOffCluster/OnOffViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/OnOffCluster/OnOffViewController.m index 1286cf50a6a22a..c3f19f26056750 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/OnOffCluster/OnOffViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/OnOffCluster/OnOffViewController.m @@ -102,7 +102,7 @@ - (void)setupStackView _numLightsTextField = [UITextField new]; _numLightsOptions = @[ @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10" ]; _numLightsTextField.text - = CHIPGetDomainValueForKey(MTRToolDefaultsDomain, MTRNumLightOnOffCluster) ?: [_numLightsOptions objectAtIndex:0]; + = MTRGetDomainValueForKey(MTRToolDefaultsDomain, MTRNumLightOnOffCluster) ?: [_numLightsOptions objectAtIndex:0]; UIPickerView * numLightsPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 100, 0, 0)]; _numLightsTextField.inputView = numLightsPicker; [numLightsPicker setDataSource:self]; @@ -210,7 +210,7 @@ - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)co - (IBAction)pickerDoneClicked:(id)sender { - CHIPSetDomainValueForKey(MTRToolDefaultsDomain, MTRNumLightOnOffCluster, _numLightsTextField.text); + MTRSetDomainValueForKey(MTRToolDefaultsDomain, MTRNumLightOnOffCluster, _numLightsTextField.text); [_numLightsTextField resignFirstResponder]; [self setupStackView]; } @@ -219,7 +219,7 @@ - (IBAction)pickerDoneClicked:(id)sender - (int)numLightClustersToShow { - NSString * numClusters = CHIPGetDomainValueForKey(MTRToolDefaultsDomain, MTRNumLightOnOffCluster); + NSString * numClusters = MTRGetDomainValueForKey(MTRToolDefaultsDomain, MTRNumLightOnOffCluster); int numberOfLights = 1; if (numClusters) { @@ -237,7 +237,7 @@ - (IBAction)onButtonTapped:(id)sender [self updateResult:[NSString stringWithFormat:@"On command sent on endpoint %@", @(endpoint)]]; [_deviceSelector forSelectedDevices:^(uint64_t deviceId) { - if (CHIPGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { MTROnOff * onOff = [[MTROnOff alloc] initWithDevice:chipDevice endpoint:endpoint @@ -266,7 +266,7 @@ - (IBAction)offButtonTapped:(id)sender [self updateResult:[NSString stringWithFormat:@"Off command sent on endpoint %@", @(endpoint)]]; [_deviceSelector forSelectedDevices:^(uint64_t deviceId) { - if (CHIPGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { MTROnOff * onOff = [[MTROnOff alloc] initWithDevice:chipDevice endpoint:endpoint @@ -295,7 +295,7 @@ - (IBAction)toggleButtonTapped:(id)sender [self updateResult:[NSString stringWithFormat:@"Toggle command sent on endpoint %@", @(endpoint)]]; [_deviceSelector forSelectedDevices:^(uint64_t deviceId) { - if (CHIPGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDeviceWithID(deviceId, ^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { MTROnOff * onOff = [[MTROnOff alloc] initWithDevice:chipDevice endpoint:endpoint diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m index 4ea1b7404b4cfa..e8fef557ab823f 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m @@ -418,7 +418,7 @@ - (void)viewDidLoad [self setupUI]; dispatch_queue_t callbackQueue = dispatch_queue_create("com.csa.matter.qrcodevc.callback", DISPATCH_QUEUE_SERIAL); - self.chipController = InitializeCHIP(); + self.chipController = InitializeMTR(); [self.chipController setPairingDelegate:self queue:callbackQueue]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)]; @@ -478,7 +478,7 @@ - (void)readerSession:(nonnull NFCNDEFReaderSession *)session didInvalidateWithE - (void)setVendorIDOnAccessory { NSLog(@"Call to setVendorIDOnAccessory"); - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable device, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable device, NSError * _Nullable error) { if (!device) { NSLog(@"Status: Failed to establish a connection with the device"); } @@ -495,8 +495,8 @@ - (void)onPairingComplete:(NSError * _Nullable)error if (error != nil) { NSLog(@"Got pairing error back %@", error); } else { - MTRDeviceController * controller = InitializeCHIP(); - uint64_t deviceId = CHIPGetLastPairedDeviceId(); + MTRDeviceController * controller = InitializeMTR(); + uint64_t deviceId = MTRGetLastPairedDeviceId(); if ([controller respondsToSelector:@selector(deviceBeingCommissionedOverBLE:) && [controller deviceBeingCommissionedOverBLE:deviceId]) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -614,7 +614,7 @@ - (void)retrieveAndSendWiFiCredentials textField.clearButtonMode = UITextFieldViewModeWhileEditing; textField.borderStyle = UITextBorderStyleRoundedRect; - NSString * networkSSID = CHIPGetDomainValueForKey(MTRToolDefaultsDomain, kNetworkSSIDDefaultsKey); + NSString * networkSSID = MTRGetDomainValueForKey(MTRToolDefaultsDomain, kNetworkSSIDDefaultsKey); if ([networkSSID length] > 0) { textField.text = networkSSID; } @@ -626,7 +626,7 @@ - (void)retrieveAndSendWiFiCredentials textField.borderStyle = UITextBorderStyleRoundedRect; textField.secureTextEntry = YES; - NSString * networkPassword = CHIPGetDomainValueForKey(MTRToolDefaultsDomain, kNetworkPasswordDefaultsKey); + NSString * networkPassword = MTRGetDomainValueForKey(MTRToolDefaultsDomain, kNetworkPasswordDefaultsKey); if ([networkPassword length] > 0) { textField.text = networkPassword; } @@ -647,12 +647,12 @@ - (void)retrieveAndSendWiFiCredentials UITextField * networkSSID = textfields[0]; UITextField * networkPassword = textfields[1]; if ([networkSSID.text length] > 0) { - CHIPSetDomainValueForKey( + MTRSetDomainValueForKey( MTRToolDefaultsDomain, kNetworkSSIDDefaultsKey, networkSSID.text); } if ([networkPassword.text length] > 0) { - CHIPSetDomainValueForKey( + MTRSetDomainValueForKey( MTRToolDefaultsDomain, kNetworkPasswordDefaultsKey, networkPassword.text); } NSLog(@"New SSID: %@ Password: %@", networkSSID.text, networkPassword.text); @@ -667,7 +667,7 @@ - (void)commissionWithSSID:(NSString *)ssid password:(NSString *)password { NSError * error; - MTRDeviceController * controller = InitializeCHIP(); + MTRDeviceController * controller = InitializeMTR(); // create commissioning params in ObjC. Pass those in here with network credentials. // maybe this just becomes the new norm MTRCommissioningParameters * params = [[MTRCommissioningParameters alloc] init]; @@ -676,7 +676,7 @@ - (void)commissionWithSSID:(NSString *)ssid password:(NSString *)password params.deviceAttestationDelegate = [[CHIPToolDeviceAttestationDelegate alloc] initWithViewController:self]; params.failSafeExpiryTimeoutSecs = @600; - uint64_t deviceId = CHIPGetNextAvailableDeviceID() - 1; + uint64_t deviceId = MTRGetNextAvailableDeviceID() - 1; if (![controller commissionDevice:deviceId commissioningParams:params error:&error]) { NSLog(@"Failed to commission Device %llu, with error %@", deviceId, error); @@ -690,8 +690,8 @@ - (void)onCommissioningComplete:(NSError * _Nullable)error return; } // track this device - uint64_t deviceId = CHIPGetNextAvailableDeviceID() - 1; - CHIPSetDevicePaired(deviceId, YES); + uint64_t deviceId = MTRGetNextAvailableDeviceID() - 1; + MTRSetDevicePaired(deviceId, YES); [self setVendorIDOnAccessory]; } @@ -787,7 +787,7 @@ - (NSString *)getNetworkName:(NSNumber *)discriminator - (void)_restartMatterStack { - self.chipController = CHIPRestartController(self.chipController); + self.chipController = MTRRestartController(self.chipController); dispatch_queue_t callbackQueue = dispatch_queue_create("com.csa.matter.qrcodevc.callback", DISPATCH_QUEUE_SERIAL); [self.chipController setPairingDelegate:self queue:callbackQueue]; } @@ -795,14 +795,14 @@ - (void)_restartMatterStack - (void)handleRendezVousDefault:(NSString *)payload { NSError * error; - uint64_t deviceID = CHIPGetNextAvailableDeviceID(); + uint64_t deviceID = MTRGetNextAvailableDeviceID(); // restart the Matter Stack before pairing (for reliability + testing restarts) [self _restartMatterStack]; if ([self.chipController pairDevice:deviceID onboardingPayload:payload error:&error]) { deviceID++; - CHIPSetNextAvailableDeviceID(deviceID); + MTRSetNextAvailableDeviceID(deviceID); } } diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/Temperature Sensor/TemperatureSensorViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/Temperature Sensor/TemperatureSensorViewController.m index 1a0384d3fc8841..c545a61cc5d297 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/Temperature Sensor/TemperatureSensorViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/Temperature Sensor/TemperatureSensorViewController.m @@ -188,7 +188,7 @@ - (void)updateTempInUI:(int)newTemp - (void)readCurrentTemperature { - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { MTRTemperatureMeasurement * cluster = [[MTRTemperatureMeasurement alloc] initWithDevice:chipDevice endpoint:1 @@ -218,7 +218,7 @@ - (void)reportFromUserEnteredSettings NSLog( @"Sending temp reporting values: min %@ max %@ value %@", @(minIntervalSeconds), @(maxIntervalSeconds), @(deltaInCelsius)); - if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { + if (MTRGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { if (chipDevice) { // Use a wildcard subscription [chipDevice subscribeWithQueue:dispatch_get_main_queue() diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/UnpairDevices/UnpairDevicesViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/UnpairDevices/UnpairDevicesViewController.m index f7b668f1848dc2..8cfad927136bf0 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/UnpairDevices/UnpairDevicesViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/UnpairDevices/UnpairDevicesViewController.m @@ -129,7 +129,7 @@ - (IBAction)unpairAllDevicesButton:(id)sender - (IBAction)unpairSelectedDevices:(id)sender { [_deviceSelector forSelectedDevices:^(uint64_t deviceId) { - CHIPUnpairDeviceWithID(deviceId); + MTRUnpairDeviceWithID(deviceId); }]; [_deviceSelector refreshDeviceList]; diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/WiFi/WiFiViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/WiFi/WiFiViewController.m index 6133725162fb88..e1b2a53bbf51b1 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/WiFi/WiFiViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/WiFi/WiFiViewController.m @@ -113,12 +113,12 @@ - (void)setupUI - (void)fillNetworkConfigWithDefaults { - NSString * networkSSID = CHIPGetDomainValueForKey(MTRToolDefaultsDomain, kNetworkSSIDDefaultsKey); + NSString * networkSSID = MTRGetDomainValueForKey(MTRToolDefaultsDomain, kNetworkSSIDDefaultsKey); if ([networkSSID length] > 0) { self.networkSSID.text = networkSSID; } - NSString * networkPassword = CHIPGetDomainValueForKey(MTRToolDefaultsDomain, kNetworkPasswordDefaultsKey); + NSString * networkPassword = MTRGetDomainValueForKey(MTRToolDefaultsDomain, kNetworkPasswordDefaultsKey); if ([networkPassword length] > 0) { self.networkPassword.text = networkPassword; } @@ -129,11 +129,11 @@ - (void)fillNetworkConfigWithDefaults - (IBAction)saveCredientials:(id)sender { if ([self.networkSSID.text length] > 0) { - CHIPSetDomainValueForKey(MTRToolDefaultsDomain, kNetworkSSIDDefaultsKey, self.networkSSID.text); + MTRSetDomainValueForKey(MTRToolDefaultsDomain, kNetworkSSIDDefaultsKey, self.networkSSID.text); } if ([self.networkPassword.text length] > 0) { - CHIPSetDomainValueForKey(MTRToolDefaultsDomain, kNetworkPasswordDefaultsKey, self.networkPassword.text); + MTRSetDomainValueForKey(MTRToolDefaultsDomain, kNetworkPasswordDefaultsKey, self.networkPassword.text); } [self.navigationController popViewControllerAnimated:YES]; @@ -142,11 +142,11 @@ - (IBAction)saveCredientials:(id)sender - (IBAction)clearCredientials:(id)sender { if ([self.networkSSID.text length] > 0) { - CHIPSetDomainValueForKey(MTRToolDefaultsDomain, kNetworkSSIDDefaultsKey, nil); + MTRSetDomainValueForKey(MTRToolDefaultsDomain, kNetworkSSIDDefaultsKey, nil); } if ([self.networkPassword.text length] > 0) { - CHIPSetDomainValueForKey(MTRToolDefaultsDomain, kNetworkPasswordDefaultsKey, nil); + MTRSetDomainValueForKey(MTRToolDefaultsDomain, kNetworkPasswordDefaultsKey, nil); } self.networkSSID.text = @""; diff --git a/src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm b/src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm index f5d0ed412ea130..eccdb418e19cf0 100644 --- a/src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm +++ b/src/darwin/Framework/CHIP/MTRAttributeCacheContainer.mm @@ -63,14 +63,14 @@ static CHIP_ERROR AppendAttibuteValueToArray( [array addObject:@ { MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:path], MTRDataKey : obj }]; return CHIP_NO_ERROR; } - CHIP_LOG_ERROR("Error: Cached value could not be converted to generic NSObject"); + MTR_LOG_ERROR("Error: Cached value could not be converted to generic NSObject"); [array addObject:@ { MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:path], MTRErrorKey : [MTRError errorForCHIPErrorCode:CHIP_ERROR_DECODE_FAILED] }]; return CHIP_ERROR_DECODE_FAILED; } - CHIP_LOG_ERROR("Error: Failed to read from attribute cache: %s", err.AsString()); + MTR_LOG_ERROR("Error: Failed to read from attribute cache: %s", err.AsString()); [array addObject:@ { MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:path], MTRErrorKey : [MTRError errorForCHIPErrorCode:err] @@ -94,7 +94,7 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId if (self.shouldUseXPC) { MTRDeviceControllerXPCConnection * xpcConnection = self.xpcConnection; if (!xpcConnection) { - CHIP_LOG_ERROR("Attribute cache read failed: MTRDeviceController was already disposed"); + MTR_LOG_ERROR("Attribute cache read failed: MTRDeviceController was already disposed"); completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]); return; } @@ -114,7 +114,7 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId (void) handleRetainer; }]; } else { - CHIP_LOG_ERROR("Attribute cache read failed due to XPC connection failure"); + MTR_LOG_ERROR("Attribute cache read failed due to XPC connection failure"); completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]); } }]; @@ -123,13 +123,13 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId dispatch_async(DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{ if (endpointId == nil && clusterId == nil) { - CHIP_LOG_ERROR("Error: currently read from attribute cache does not support wildcards for both endpoint and cluster"); + MTR_LOG_ERROR("Error: currently read from attribute cache does not support wildcards for both endpoint and cluster"); completionHandler(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeInvalidArgument userInfo:nil]); return; } if (!self.cppAttributeCache) { - CHIP_LOG_ERROR("Error: No attribute cache available to read from"); + MTR_LOG_ERROR("Error: No attribute cache available to read from"); completionHandler(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]); return; } diff --git a/src/darwin/Framework/CHIP/MTRControllerFactory.mm b/src/darwin/Framework/CHIP/MTRControllerFactory.mm index b169ce9649125a..676455d5916a74 100644 --- a/src/darwin/Framework/CHIP/MTRControllerFactory.mm +++ b/src/darwin/Framework/CHIP/MTRControllerFactory.mm @@ -136,7 +136,7 @@ - (BOOL)checkForInitError:(BOOL)condition logMsg:(NSString *)logMsg return NO; } - CHIP_LOG_ERROR("Error: %@", logMsg); + MTR_LOG_ERROR("Error: %@", logMsg); [self cleanupInitObjects]; @@ -192,7 +192,7 @@ - (void)cleanupStartupObjects - (BOOL)startup:(MTRControllerFactoryParams *)startupParams { if ([self isRunning]) { - CHIP_LOG_DEBUG("Ignoring duplicate call to startup, Matter controller factory already started..."); + MTR_LOG_DEBUG("Ignoring duplicate call to startup, Matter controller factory already started..."); return YES; } @@ -207,33 +207,33 @@ - (BOOL)startup:(MTRControllerFactoryParams *)startupParams _persistentStorageDelegateBridge = new MTRPersistentStorageDelegateBridge(startupParams.storageDelegate); if (_persistentStorageDelegateBridge == nil) { - CHIP_LOG_ERROR("Error: %@", kErrorPersistentStorageInit); + MTR_LOG_ERROR("Error: %@", kErrorPersistentStorageInit); return; } // TODO: Allow passing a different keystore implementation via startupParams. _keystore = new PersistentStorageOperationalKeystore(); if (_keystore == nullptr) { - CHIP_LOG_ERROR("Error: %@", kErrorKeystoreInit); + MTR_LOG_ERROR("Error: %@", kErrorKeystoreInit); return; } CHIP_ERROR errorCode = _keystore->Init(_persistentStorageDelegateBridge); if (errorCode != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error: %@", kErrorKeystoreInit); + MTR_LOG_ERROR("Error: %@", kErrorKeystoreInit); return; } // TODO Allow passing a different opcert store implementation via startupParams. _opCertStore = new Credentials::PersistentStorageOpCertStore(); if (_opCertStore == nullptr) { - CHIP_LOG_ERROR("Error: %@", kErrorCertStoreInit); + MTR_LOG_ERROR("Error: %@", kErrorCertStoreInit); return; } errorCode = _opCertStore->Init(_persistentStorageDelegateBridge); if (errorCode != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error: %@", kErrorCertStoreInit); + MTR_LOG_ERROR("Error: %@", kErrorCertStoreInit); return; } @@ -242,7 +242,7 @@ - (BOOL)startup:(MTRControllerFactoryParams *)startupParams if (startupParams.paaCerts) { _attestationTrustStoreBridge = new MTRAttestationTrustStoreBridge(startupParams.paaCerts); if (_attestationTrustStoreBridge == nullptr) { - CHIP_LOG_ERROR("Error: %@", kErrorAttestationTrustStoreInit); + MTR_LOG_ERROR("Error: %@", kErrorAttestationTrustStoreInit); return; } trustStore = _attestationTrustStoreBridge; @@ -252,7 +252,7 @@ - (BOOL)startup:(MTRControllerFactoryParams *)startupParams } _deviceAttestationVerifier = new Credentials::DefaultDACVerifier(trustStore); if (_deviceAttestationVerifier == nullptr) { - CHIP_LOG_ERROR("Error: %@", kErrorDACVerifierInit); + MTR_LOG_ERROR("Error: %@", kErrorDACVerifierInit); return; } @@ -270,7 +270,7 @@ - (BOOL)startup:(MTRControllerFactoryParams *)startupParams params.opCertStore = _opCertStore; errorCode = _controllerFactory->Init(params); if (errorCode != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error: %@", kErrorControllerFactoryInit); + MTR_LOG_ERROR("Error: %@", kErrorControllerFactoryInit); return; } @@ -297,7 +297,7 @@ - (void)shutdown [_controllers[0] shutdown]; } - CHIP_LOG_DEBUG("%@", kInfoFactoryShutdown); + MTR_LOG_DEBUG("%@", kInfoFactoryShutdown); _controllerFactory->Shutdown(); [self cleanupStartupObjects]; @@ -312,7 +312,7 @@ - (void)shutdown - (MTRDeviceController * _Nullable)startControllerOnExistingFabric:(MTRDeviceControllerStartupParams *)startupParams { if (![self isRunning]) { - CHIP_LOG_ERROR("Trying to start controller while Matter controller factory is not running"); + MTR_LOG_ERROR("Trying to start controller while Matter controller factory is not running"); return nil; } @@ -332,12 +332,12 @@ - (MTRDeviceController * _Nullable)startControllerOnExistingFabric:(MTRDeviceCon const FabricInfo * fabric = nullptr; BOOL ok = [self findMatchingFabric:*fabricTable params:startupParams fabric:&fabric]; if (!ok) { - CHIP_LOG_ERROR("Can't start on existing fabric: fabric matching failed"); + MTR_LOG_ERROR("Can't start on existing fabric: fabric matching failed"); return; } if (fabric == nullptr) { - CHIP_LOG_ERROR("Can't start on existing fabric: fabric not found"); + MTR_LOG_ERROR("Can't start on existing fabric: fabric not found"); return; } @@ -345,12 +345,12 @@ - (MTRDeviceController * _Nullable)startControllerOnExistingFabric:(MTRDeviceCon BOOL isRunning = YES; // assume the worst if ([existing isRunningOnFabric:fabricTable fabricIndex:fabric->GetFabricIndex() isRunning:&isRunning] != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Can't tell what fabric a controller is running on. Not safe to start."); + MTR_LOG_ERROR("Can't tell what fabric a controller is running on. Not safe to start."); return; } if (isRunning) { - CHIP_LOG_ERROR("Can't start on existing fabric: another controller is running on it"); + MTR_LOG_ERROR("Can't start on existing fabric: another controller is running on it"); return; } } @@ -377,17 +377,17 @@ - (MTRDeviceController * _Nullable)startControllerOnExistingFabric:(MTRDeviceCon - (MTRDeviceController * _Nullable)startControllerOnNewFabric:(MTRDeviceControllerStartupParams *)startupParams { if (![self isRunning]) { - CHIP_LOG_ERROR("Trying to start controller while Matter controller factory is not running"); + MTR_LOG_ERROR("Trying to start controller while Matter controller factory is not running"); return nil; } if (startupParams.vendorId == nil) { - CHIP_LOG_ERROR("Must provide vendor id when starting controller on new fabric"); + MTR_LOG_ERROR("Must provide vendor id when starting controller on new fabric"); return nil; } if (startupParams.intermediateCertificate != nil && startupParams.rootCertificate == nil) { - CHIP_LOG_ERROR("Must provide a root certificate when using an intermediate certificate"); + MTR_LOG_ERROR("Must provide a root certificate when using an intermediate certificate"); return nil; } @@ -407,12 +407,12 @@ - (MTRDeviceController * _Nullable)startControllerOnNewFabric:(MTRDeviceControll const FabricInfo * fabric = nullptr; BOOL ok = [self findMatchingFabric:*fabricTable params:startupParams fabric:&fabric]; if (!ok) { - CHIP_LOG_ERROR("Can't start on new fabric: fabric matching failed"); + MTR_LOG_ERROR("Can't start on new fabric: fabric matching failed"); return; } if (fabric != nullptr) { - CHIP_LOG_ERROR("Can't start on new fabric that matches existing fabric"); + MTR_LOG_ERROR("Can't start on new fabric that matches existing fabric"); return; } @@ -438,7 +438,7 @@ - (MTRDeviceController * _Nullable)createController { MTRDeviceController * controller = [[MTRDeviceController alloc] initWithFactory:self queue:_chipWorkQueue]; if (controller == nil) { - CHIP_LOG_ERROR("Failed to init controller"); + MTR_LOG_ERROR("Failed to init controller"); return nil; } @@ -470,7 +470,7 @@ - (BOOL)findMatchingFabric:(FabricTable &)fabricTable CHIP_ERROR err = fabricTable.Init( { .storage = _persistentStorageDelegateBridge, .operationalKeystore = _keystore, .opCertStore = _opCertStore }); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Can't initialize fabric table: %s", ErrorStr(err)); + MTR_LOG_ERROR("Can't initialize fabric table: %s", ErrorStr(err)); return NO; } @@ -478,7 +478,7 @@ - (BOOL)findMatchingFabric:(FabricTable &)fabricTable if (params.rootCertificate != nil) { err = ExtractPubkeyFromX509Cert(AsByteSpan(params.rootCertificate), pubKey); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Can't extract public key from root certificate: %s", ErrorStr(err)); + MTR_LOG_ERROR("Can't extract public key from root certificate: %s", ErrorStr(err)); return NO; } } else { @@ -486,7 +486,7 @@ - (BOOL)findMatchingFabric:(FabricTable &)fabricTable // consumers must provide a root certificate whenever an ICA is used. err = MTRP256KeypairBridge::MatterPubKeyFromSecKeyRef(params.nocSigner.publicKey, &pubKey); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Can't extract public key from MTRKeypair: %s", ErrorStr(err)); + MTR_LOG_ERROR("Can't extract public key from MTRKeypair: %s", ErrorStr(err)); return NO; } } @@ -502,7 +502,7 @@ @implementation MTRControllerFactory (InternalMethods) - (void)controllerShuttingDown:(MTRDeviceController *)controller { if (![_controllers containsObject:controller]) { - CHIP_LOG_ERROR("Controller we don't know about shutting down"); + MTR_LOG_ERROR("Controller we don't know about shutting down"); return; } diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 581ab5abb36773..9cc39ad8aa581a 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -439,7 +439,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) int64_t val; CHIP_ERROR err = data->Get(val); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV signed integer decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV signed integer decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:MTRSignedIntegerValueType, MTRTypeKey, [NSNumber numberWithLongLong:val], @@ -449,7 +449,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) uint64_t val; CHIP_ERROR err = data->Get(val); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV unsigned integer decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV unsigned integer decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:MTRUnsignedIntegerValueType, MTRTypeKey, @@ -459,7 +459,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) bool val; CHIP_ERROR err = data->Get(val); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV boolean decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV boolean decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary @@ -475,7 +475,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) double val; err = data->Get(val); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV floating point decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV floating point decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary @@ -486,7 +486,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) const uint8_t * ptr; CHIP_ERROR err = data->GetDataPtr(ptr); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV UTF8String decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV UTF8String decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:MTRUTF8StringValueType, MTRTypeKey, @@ -497,7 +497,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) const uint8_t * ptr; CHIP_ERROR err = data->GetDataPtr(ptr); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV ByteString decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV ByteString decoding failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:MTROctetStringValueType, MTRTypeKey, @@ -523,7 +523,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) chip::TLV::TLVType tlvType; CHIP_ERROR err = data->EnterContainer(tlvType); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV container entering failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV container entering failed", chip::ErrorStr(err)); return nil; } NSMutableArray * array = [[NSMutableArray alloc] init]; @@ -531,7 +531,7 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) chip::TLV::Tag tag = data->GetTag(); id value = NSObjectFromCHIPTLV(data); if (value == nullptr) { - CHIP_LOG_ERROR("Error when decoding TLV container"); + MTR_LOG_ERROR("Error when decoding TLV container"); return nil; } NSMutableDictionary * arrayElement = [NSMutableDictionary dictionary]; @@ -542,18 +542,18 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) [array addObject:arrayElement]; } if (err != CHIP_END_OF_TLV) { - CHIP_LOG_ERROR("Error(%s): TLV container decoding failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV container decoding failed", chip::ErrorStr(err)); return nil; } err = data->ExitContainer(tlvType); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): TLV container exiting failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): TLV container exiting failed", chip::ErrorStr(err)); return nil; } return [NSDictionary dictionaryWithObjectsAndKeys:typeName, MTRTypeKey, array, MTRValueKey, nil]; } default: - CHIP_LOG_ERROR("Error: Unsupported TLV type for conversion: %u", (unsigned) data->GetType()); + MTR_LOG_ERROR("Error: Unsupported TLV type for conversion: %u", (unsigned) data->GetType()); return nil; } } @@ -561,46 +561,46 @@ id _Nullable NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) static CHIP_ERROR EncodeTLVFromObject(id object, chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) { if (![object isKindOfClass:[NSDictionary class]]) { - CHIP_LOG_ERROR("Error: Unsupported object to encode: %@", [object class]); + MTR_LOG_ERROR("Error: Unsupported object to encode: %@", [object class]); return CHIP_ERROR_INVALID_ARGUMENT; } NSString * typeName = ((NSDictionary *) object)[MTRTypeKey]; id value = ((NSDictionary *) object)[MTRValueKey]; if (!typeName) { - CHIP_LOG_ERROR("Error: Object to encode is corrupt"); + MTR_LOG_ERROR("Error: Object to encode is corrupt"); return CHIP_ERROR_INVALID_ARGUMENT; } if ([typeName isEqualToString:MTRSignedIntegerValueType]) { if (![value isKindOfClass:[NSNumber class]]) { - CHIP_LOG_ERROR("Error: Object to encode has corrupt signed integer type: %@", [value class]); + MTR_LOG_ERROR("Error: Object to encode has corrupt signed integer type: %@", [value class]); return CHIP_ERROR_INVALID_ARGUMENT; } return writer.Put(tag, [value longLongValue]); } if ([typeName isEqualToString:MTRUnsignedIntegerValueType]) { if (![value isKindOfClass:[NSNumber class]]) { - CHIP_LOG_ERROR("Error: Object to encode has corrupt unsigned integer type: %@", [value class]); + MTR_LOG_ERROR("Error: Object to encode has corrupt unsigned integer type: %@", [value class]); return CHIP_ERROR_INVALID_ARGUMENT; } return writer.Put(tag, [value unsignedLongLongValue]); } if ([typeName isEqualToString:MTRBooleanValueType]) { if (![value isKindOfClass:[NSNumber class]]) { - CHIP_LOG_ERROR("Error: Object to encode has corrupt boolean type: %@", [value class]); + MTR_LOG_ERROR("Error: Object to encode has corrupt boolean type: %@", [value class]); return CHIP_ERROR_INVALID_ARGUMENT; } return writer.Put(tag, static_cast<bool>([value boolValue])); } if ([typeName isEqualToString:MTRFloatValueType]) { if (![value isKindOfClass:[NSNumber class]]) { - CHIP_LOG_ERROR("Error: Object to encode has corrupt float type: %@", [value class]); + MTR_LOG_ERROR("Error: Object to encode has corrupt float type: %@", [value class]); return CHIP_ERROR_INVALID_ARGUMENT; } return writer.Put(tag, [value floatValue]); } if ([typeName isEqualToString:MTRDoubleValueType]) { if (![value isKindOfClass:[NSNumber class]]) { - CHIP_LOG_ERROR("Error: Object to encode has corrupt double type: %@", [value class]); + MTR_LOG_ERROR("Error: Object to encode has corrupt double type: %@", [value class]); return CHIP_ERROR_INVALID_ARGUMENT; } return writer.Put(tag, [value doubleValue]); @@ -610,34 +610,34 @@ static CHIP_ERROR EncodeTLVFromObject(id object, chip::TLV::TLVWriter & writer, } if ([typeName isEqualToString:MTRUTF8StringValueType]) { if (![value isKindOfClass:[NSString class]]) { - CHIP_LOG_ERROR("Error: Object to encode has corrupt UTF8 string type: %@", [value class]); + MTR_LOG_ERROR("Error: Object to encode has corrupt UTF8 string type: %@", [value class]); return CHIP_ERROR_INVALID_ARGUMENT; } return writer.PutString(tag, [value cStringUsingEncoding:NSUTF8StringEncoding]); } if ([typeName isEqualToString:MTROctetStringValueType]) { if (![value isKindOfClass:[NSData class]]) { - CHIP_LOG_ERROR("Error: Object to encode has corrupt octet string type: %@", [value class]); + MTR_LOG_ERROR("Error: Object to encode has corrupt octet string type: %@", [value class]); return CHIP_ERROR_INVALID_ARGUMENT; } return writer.Put(tag, chip::ByteSpan(static_cast<const uint8_t *>([value bytes]), [value length])); } if ([typeName isEqualToString:MTRStructureValueType]) { if (![value isKindOfClass:[NSArray class]]) { - CHIP_LOG_ERROR("Error: Object to encode has corrupt structure type: %@", [value class]); + MTR_LOG_ERROR("Error: Object to encode has corrupt structure type: %@", [value class]); return CHIP_ERROR_INVALID_ARGUMENT; } TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Structure, outer)); for (id element in value) { if (![element isKindOfClass:[NSDictionary class]]) { - CHIP_LOG_ERROR("Error: Structure element to encode has corrupt type: %@", [element class]); + MTR_LOG_ERROR("Error: Structure element to encode has corrupt type: %@", [element class]); return CHIP_ERROR_INVALID_ARGUMENT; } NSNumber * elementTag = element[MTRContextTagKey]; id elementValue = element[MTRDataKey]; if (!elementTag || !elementValue) { - CHIP_LOG_ERROR("Error: Structure element to encode has corrupt value: %@", element); + MTR_LOG_ERROR("Error: Structure element to encode has corrupt value: %@", element); return CHIP_ERROR_INVALID_ARGUMENT; } ReturnErrorOnFailure(EncodeTLVFromObject(elementValue, writer, chip::TLV::ContextTag([elementTag unsignedCharValue]))); @@ -647,19 +647,19 @@ static CHIP_ERROR EncodeTLVFromObject(id object, chip::TLV::TLVWriter & writer, } if ([typeName isEqualToString:MTRArrayValueType]) { if (![value isKindOfClass:[NSArray class]]) { - CHIP_LOG_ERROR("Error: Object to encode has corrupt array type: %@", [value class]); + MTR_LOG_ERROR("Error: Object to encode has corrupt array type: %@", [value class]); return CHIP_ERROR_INVALID_ARGUMENT; } TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, chip::TLV::kTLVType_Array, outer)); for (id element in value) { if (![element isKindOfClass:[NSDictionary class]]) { - CHIP_LOG_ERROR("Error: Array element to encode has corrupt type: %@", [element class]); + MTR_LOG_ERROR("Error: Array element to encode has corrupt type: %@", [element class]); return CHIP_ERROR_INVALID_ARGUMENT; } id elementValue = element[MTRDataKey]; if (!elementValue) { - CHIP_LOG_ERROR("Error: Array element to encode has corrupt value: %@", element); + MTR_LOG_ERROR("Error: Array element to encode has corrupt value: %@", element); return CHIP_ERROR_INVALID_ARGUMENT; } ReturnErrorOnFailure(EncodeTLVFromObject(elementValue, writer, chip::TLV::AnonymousTag())); @@ -667,7 +667,7 @@ static CHIP_ERROR EncodeTLVFromObject(id object, chip::TLV::TLVWriter & writer, ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } - CHIP_LOG_ERROR("Error: Unsupported type to encode: %@", typeName); + MTR_LOG_ERROR("Error: Unsupported type to encode: %@", typeName); return CHIP_ERROR_INVALID_ARGUMENT; } @@ -691,7 +691,7 @@ CHIP_ERROR Decode(chip::TLV::TLVReader & data) { decodedObj = NSObjectFromCHIPTLV(&data); if (decodedObj == nil) { - CHIP_LOG_ERROR("Error: Failed to get value from TLV data for attribute reading response"); + MTR_LOG_ERROR("Error: Failed to get value from TLV data for attribute reading response"); } return (decodedObj) ? CHIP_NO_ERROR : CHIP_ERROR_DECODE_FAILED; } @@ -1223,8 +1223,8 @@ - (void)subscribeAttributeWithEndpointId:(NSNumber * _Nullable)endpointId - (void)deregisterReportHandlersWithClientQueue:(dispatch_queue_t)clientQueue completion:(void (^)(void))completion { - // This method must only be used for CHIPDeviceOverXPC. However, for unit testing purpose, the method purges all read clients. - CHIP_LOG_DEBUG("Unexpected call to deregister report handlers"); + // This method must only be used for MTRDeviceOverXPC. However, for unit testing purpose, the method purges all read clients. + MTR_LOG_DEBUG("Unexpected call to deregister report handlers"); PurgeReadClientContainers(self.cppDevice->GetDeviceId(), clientQueue, completion); } @@ -1232,7 +1232,7 @@ - (void)deregisterReportHandlersWithClientQueue:(dispatch_queue_t)clientQueue co // This method is for unit testing only - (void)failSubscribers:(dispatch_queue_t)clientQueue completion:(void (^)(void))completion { - CHIP_LOG_DEBUG("Causing failure in subscribers on purpose"); + MTR_LOG_DEBUG("Causing failure in subscribers on purpose"); CauseReadClientFailure(self.cppDevice->GetDeviceId(), clientQueue, completion); } #endif @@ -1247,31 +1247,31 @@ + (id)CHIPEncodeAndDecodeNSObject:(id)object CHIP_ERROR error = originalData.Encode(writer, chip::TLV::Tag(1)); if (error != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error: Data encoding failed: %s", error.AsString()); + MTR_LOG_ERROR("Error: Data encoding failed: %s", error.AsString()); return nil; } error = writer.Finalize(); if (error != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error: TLV writer finalizing failed: %s", error.AsString()); + MTR_LOG_ERROR("Error: TLV writer finalizing failed: %s", error.AsString()); return nil; } chip::TLV::TLVReader reader; reader.Init(buffer, writer.GetLengthWritten()); error = reader.Next(); if (error != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error: TLV reader failed to fetch next element: %s", error.AsString()); + MTR_LOG_ERROR("Error: TLV reader failed to fetch next element: %s", error.AsString()); return nil; } __auto_type tag = reader.GetTag(); if (tag != chip::TLV::Tag(1)) { - CHIP_LOG_ERROR("Error: TLV reader did not read the tag correctly: %llu", tag.mVal); + MTR_LOG_ERROR("Error: TLV reader did not read the tag correctly: %llu", tag.mVal); return nil; } NSObjectData decodedData; error = decodedData.Decode(reader); if (error != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error: Data decoding failed: %s", error.AsString()); + MTR_LOG_ERROR("Error: Data decoding failed: %s", error.AsString()); return nil; } return decodedData.GetDecodedObject(); diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 90c56d5f3b9af5..f573c87fcabc28 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -61,7 +61,7 @@ static NSString * const kErrorStopPairing = @"Failure while trying to stop the pairing process"; static NSString * const kErrorGetPairedDevice = @"Failure while trying to retrieve a paired device"; static NSString * const kErrorNotRunning = @"Controller is not running. Call startup first."; -static NSString * const kInfoStackShutdown = @"Shutting down the CHIP Stack"; +static NSString * const kInfoStackShutdown = @"Shutting down the Matter Stack"; static NSString * const kErrorSetupCodeGen = @"Generating Manual Pairing Code failed"; static NSString * const kErrorGenerateNOC = @"Generating operational certificate failed"; static NSString * const kErrorKeyAllocation = @"Generating new operational key failed"; @@ -158,7 +158,7 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams { __block BOOL commissionerInitialized = NO; if ([self isRunning]) { - CHIP_LOG_ERROR("Unexpected duplicate call to startup"); + MTR_LOG_ERROR("Unexpected duplicate call to startup"); return NO; } @@ -169,24 +169,24 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams if (startupParams.vendorId == nil || [startupParams.vendorId unsignedShortValue] == chip::VendorId::Common) { // Shouldn't be using the "standard" vendor ID for actual devices. - CHIP_LOG_ERROR("%@ is not a valid vendorId to initialize a device controller with", startupParams.vendorId); + MTR_LOG_ERROR("%@ is not a valid vendorId to initialize a device controller with", startupParams.vendorId); return; } if (startupParams.operationalCertificate == nil && startupParams.nodeId == nil) { - CHIP_LOG_ERROR("Can't start a controller if we don't know what node id it is"); + MTR_LOG_ERROR("Can't start a controller if we don't know what node id it is"); return; } if ([startupParams keypairsMatchCertificates] == NO) { - CHIP_LOG_ERROR("Provided keypairs do not match certificates"); + MTR_LOG_ERROR("Provided keypairs do not match certificates"); return; } if (startupParams.operationalCertificate != nil && startupParams.operationalKeypair == nil && (!startupParams.fabricIndex.HasValue() || !startupParams.keystore->HasOpKeypairForFabric(startupParams.fabricIndex.Value()))) { - CHIP_LOG_ERROR("Have no operational keypair for our operational certificate"); + MTR_LOG_ERROR("Have no operational keypair for our operational certificate"); return; } @@ -310,13 +310,13 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams - (NSNumber *)controllerNodeId { if (![self isRunning]) { - CHIP_LOG_ERROR("A controller has no node id if it has not been started"); + MTR_LOG_ERROR("A controller has no node id if it has not been started"); return nil; } __block NSNumber * nodeID; dispatch_sync(_chipWorkQueue, ^{ if (![self isRunning]) { - CHIP_LOG_ERROR("A controller has no node id if it has not been started"); + MTR_LOG_ERROR("A controller has no node id if it has not been started"); nodeID = nil; } else { nodeID = @(_cppCommissioner->GetNodeId()); @@ -553,7 +553,7 @@ - (BOOL)openPairingWindow:(uint64_t)deviceID duration:(NSUInteger)duration error CHIP_ERROR err = CHIP_NO_ERROR; if (duration > UINT16_MAX) { - CHIP_LOG_ERROR("Error: Duration %tu is too large. Max value %d", duration, UINT16_MAX); + MTR_LOG_ERROR("Error: Duration %tu is too large. Max value %d", duration, UINT16_MAX); if (error) { *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]; } @@ -564,7 +564,7 @@ - (BOOL)openPairingWindow:(uint64_t)deviceID duration:(NSUInteger)duration error self.cppCommissioner, deviceID, chip::System::Clock::Seconds16(static_cast<uint16_t>(duration))); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): Open Pairing Window failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): Open Pairing Window failed", chip::ErrorStr(err)); if (error) { *error = [MTRError errorForCHIPErrorCode:err]; } @@ -583,7 +583,7 @@ - (NSString *)openPairingWindowWithPIN:(uint64_t)deviceID CHIP_ERROR err = CHIP_NO_ERROR; if (duration > UINT16_MAX) { - CHIP_LOG_ERROR("Error: Duration %tu is too large. Max value %d", duration, UINT16_MAX); + MTR_LOG_ERROR("Error: Duration %tu is too large. Max value %d", duration, UINT16_MAX); if (error) { *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]; } @@ -591,7 +591,7 @@ - (NSString *)openPairingWindowWithPIN:(uint64_t)deviceID } if (discriminator > 0xfff) { - CHIP_LOG_ERROR("Error: Discriminator %tu is too large. Max value %d", discriminator, 0xfff); + MTR_LOG_ERROR("Error: Discriminator %tu is too large. Max value %d", discriminator, 0xfff); if (error) { *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]; } @@ -607,7 +607,7 @@ - (NSString *)openPairingWindowWithPIN:(uint64_t)deviceID setupPayload); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Error(%s): Open Pairing Window failed", chip::ErrorStr(err)); + MTR_LOG_ERROR("Error(%s): Open Pairing Window failed", chip::ErrorStr(err)); if (error) { *error = [MTRError errorForCHIPErrorCode:err]; } @@ -618,9 +618,9 @@ - (NSString *)openPairingWindowWithPIN:(uint64_t)deviceID std::string outCode; if (generator.payloadDecimalStringRepresentation(outCode) == CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Setup code is %s", outCode.c_str()); + MTR_LOG_ERROR("Setup code is %s", outCode.c_str()); } else { - CHIP_LOG_ERROR("Failed to get decimal setup code"); + MTR_LOG_ERROR("Failed to get decimal setup code"); return nil; } @@ -640,7 +640,7 @@ - (BOOL)checkForInitError:(BOOL)condition logMsg:(NSString *)logMsg return NO; } - CHIP_LOG_ERROR("Error: %@", logMsg); + MTR_LOG_ERROR("Error: %@", logMsg); [self cleanup]; @@ -661,7 +661,7 @@ - (BOOL)checkForStartError:(BOOL)condition logMsg:(NSString *)logMsg return NO; } - CHIP_LOG_ERROR("Error: %@", logMsg); + MTR_LOG_ERROR("Error: %@", logMsg); return YES; } @@ -672,7 +672,7 @@ - (BOOL)checkForError:(CHIP_ERROR)errorCode logMsg:(NSString *)logMsg error:(NSE return NO; } - CHIP_LOG_ERROR("Error(%s): %s", chip::ErrorStr(errorCode), [logMsg UTF8String]); + MTR_LOG_ERROR("Error(%s): %s", chip::ErrorStr(errorCode), [logMsg UTF8String]); if (error) { *error = [MTRError errorForCHIPErrorCode:errorCode]; } diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerOverXPC.m b/src/darwin/Framework/CHIP/MTRDeviceControllerOverXPC.m index 9bf71c2c7f62a6..74cca0b5c5f17c 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerOverXPC.m +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerOverXPC.m @@ -51,7 +51,7 @@ - (BOOL)pairDevice:(uint64_t)deviceID setupPINCode:(uint32_t)setupPINCode error:(NSError * __autoreleasing *)error { - CHIP_LOG_ERROR("MTRDevice doesn't support pairDevice over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support pairDevice over XPC"); return NO; } @@ -62,13 +62,13 @@ - (BOOL)pairDevice:(uint64_t)deviceID setupPINCode:(uint32_t)setupPINCode error:(NSError * __autoreleasing *)error { - CHIP_LOG_ERROR("MTRDevice doesn't support pairDevice over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support pairDevice over XPC"); return NO; } - (BOOL)pairDevice:(uint64_t)deviceID onboardingPayload:(NSString *)onboardingPayload error:(NSError * __autoreleasing *)error { - CHIP_LOG_ERROR("MTRDevice doesn't support pairDevice over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support pairDevice over XPC"); return NO; } @@ -76,30 +76,30 @@ - (BOOL)commissionDevice:(uint64_t)deviceId commissioningParams:(MTRCommissioningParameters *)commissioningParams error:(NSError * __autoreleasing *)error { - CHIP_LOG_ERROR("MTRDevice doesn't support pairDevice over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support pairDevice over XPC"); return NO; } - (void)setListenPort:(uint16_t)port { - CHIP_LOG_ERROR("MTRDevice doesn't support setListenPort over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support setListenPort over XPC"); } - (BOOL)stopDevicePairing:(uint64_t)deviceID error:(NSError * __autoreleasing *)error { - CHIP_LOG_ERROR("MTRDevice doesn't support stopDevicePairing over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support stopDevicePairing over XPC"); return NO; } - (nullable MTRDevice *)getDeviceBeingCommissioned:(uint64_t)deviceId error:(NSError * __autoreleasing *)error { - CHIP_LOG_ERROR("MTRDevice doesn't support getDeviceBeingCommissioned over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support getDeviceBeingCommissioned over XPC"); return nil; } - (BOOL)deviceBeingCommissionedOverBLE:(uint64_t)deviceId { - CHIP_LOG_ERROR("MTRDevice doesn't support deviceBeingCommissionedOverBLE over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support deviceBeingCommissionedOverBLE over XPC"); return NO; } @@ -114,7 +114,7 @@ - (BOOL)getDevice:(uint64_t)deviceID queue:(dispatch_queue_t)queue completionHan if (handle) { [handle.proxy getAnyDeviceControllerWithCompletion:^(id _Nullable controller, NSError * _Nullable error) { if (error) { - CHIP_LOG_ERROR("Failed to fetch any shared remote controller"); + MTR_LOG_ERROR("Failed to fetch any shared remote controller"); } else { self.controllerId = controller; } @@ -123,7 +123,7 @@ - (BOOL)getDevice:(uint64_t)deviceID queue:(dispatch_queue_t)queue completionHan (void) handleRetainer; }]; } else { - CHIP_LOG_ERROR("XPC disconnected while retrieving any shared remote controller"); + MTR_LOG_ERROR("XPC disconnected while retrieving any shared remote controller"); dispatch_group_leave(group); } }]; @@ -144,7 +144,7 @@ - (BOOL)getDevice:(uint64_t)deviceID queue:(dispatch_queue_t)queue completionHan - (BOOL)openPairingWindow:(uint64_t)deviceID duration:(NSUInteger)duration error:(NSError * __autoreleasing *)error { - CHIP_LOG_ERROR("MTRDevice doesn't support openPairingWindow over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support openPairingWindow over XPC"); return NO; } @@ -154,7 +154,7 @@ - (nullable NSString *)openPairingWindowWithPIN:(uint64_t)deviceID setupPIN:(NSUInteger)setupPIN error:(NSError * __autoreleasing *)error { - CHIP_LOG_ERROR("MTRDevice doesn't support openPairingWindow over XPC"); + MTR_LOG_ERROR("MTRDevice doesn't support openPairingWindow over XPC"); return nil; } diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm index 280d51e1f0e149..181295364063ef 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm @@ -37,7 +37,7 @@ - (instancetype)initWithSigningKeypair:(id<MTRKeypair>)nocSigner fabricId:(uint6 } if (!IsValidFabricId(fabricId)) { - CHIP_LOG_ERROR("%llu is not a valid fabric id to initialize a device controller with", fabricId); + MTR_LOG_ERROR("%llu is not a valid fabric id to initialize a device controller with", fabricId); return nil; } @@ -64,7 +64,7 @@ - (instancetype)initWithOperationalKeypair:(id<MTRKeypair>)operationalKeypair MutableByteSpan tlvOpCert(tlvOpCertBuf); CHIP_ERROR err = Credentials::ConvertX509CertToChipCert(AsByteSpan(operationalCertificate), tlvOpCert); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Unable to convert operational certificate to TLV: %s", ErrorStr(err)); + MTR_LOG_ERROR("Unable to convert operational certificate to TLV: %s", ErrorStr(err)); return nil; } @@ -72,7 +72,7 @@ - (instancetype)initWithOperationalKeypair:(id<MTRKeypair>)operationalKeypair NodeId unused = kUndefinedNodeId; err = Credentials::ExtractNodeIdFabricIdFromOpCert(tlvOpCert, &unused, &fabricId); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Unable to extract fabric id from operational certificate: %s", ErrorStr(err)); + MTR_LOG_ERROR("Unable to extract fabric id from operational certificate: %s", ErrorStr(err)); return nil; } _fabricId = fabricId; @@ -116,7 +116,7 @@ - (instancetype)initWithParams:(MTRDeviceControllerStartupParams *)params MutableByteSpan derCert(buf); CHIP_ERROR err = Credentials::ConvertChipCertToX509Cert(cert, derCert); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Failed do convert Matter certificate to X.509 DER: %s", ErrorStr(err)); + MTR_LOG_ERROR("Failed do convert Matter certificate to X.509 DER: %s", ErrorStr(err)); return nil; } @@ -132,23 +132,23 @@ - (instancetype)initWithParams:(MTRDeviceControllerStartupParams *)params } if (self.nocSigner == nil && self.rootCertificate == nil) { - CHIP_LOG_ERROR("nocSigner and rootCertificate are both nil; no public key available to identify the fabric"); + MTR_LOG_ERROR("nocSigner and rootCertificate are both nil; no public key available to identify the fabric"); return nil; } if (self.operationalCertificate != nil && self.nodeId != nil) { - CHIP_LOG_ERROR("nodeId must be nil if operationalCertificate is not nil"); + MTR_LOG_ERROR("nodeId must be nil if operationalCertificate is not nil"); return nil; } if (self.operationalCertificate != nil) { if (self.operationalKeypair == nil) { - CHIP_LOG_ERROR("Must have an operational keypair if an operational certificate is provided"); + MTR_LOG_ERROR("Must have an operational keypair if an operational certificate is provided"); return nil; } if (![MTRCertificates keypair:self.operationalKeypair matchesCertificate:self.operationalCertificate]) { - CHIP_LOG_ERROR("operationalKeypair public key does not match operationalCertificate"); + MTR_LOG_ERROR("operationalKeypair public key does not match operationalCertificate"); return nil; } } @@ -165,7 +165,7 @@ - (instancetype)initForNewFabric:(chip::FabricTable *)fabricTable } if (self.nocSigner == nil && self.operationalCertificate == nil) { - CHIP_LOG_ERROR("No way to get an operational certificate: nocSigner and operationalCertificate are both nil"); + MTR_LOG_ERROR("No way to get an operational certificate: nocSigner and operationalCertificate are both nil"); return nil; } @@ -184,7 +184,7 @@ - (instancetype)initForNewFabric:(chip::FabricTable *)fabricTable fabricId:@(self.fabricId) error:&error]; if (error != nil || self.rootCertificate == nil) { - CHIP_LOG_ERROR("Failed to generate root certificate: %@", error); + MTR_LOG_ERROR("Failed to generate root certificate: %@", error); return nil; } } @@ -219,16 +219,16 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable MutableByteSpan noc(nocBuf); CHIP_ERROR err = fabricTable->FetchNOCCert(fabric->GetFabricIndex(), noc); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Failed to get existing NOC: %s", ErrorStr(err)); + MTR_LOG_ERROR("Failed to get existing NOC: %s", ErrorStr(err)); return nil; } self.operationalCertificate = MatterCertToX509Data(noc); if (self.operationalCertificate == nil) { - CHIP_LOG_ERROR("Failed to convert TLV NOC to DER X.509: %s", ErrorStr(err)); + MTR_LOG_ERROR("Failed to convert TLV NOC to DER X.509: %s", ErrorStr(err)); return nil; } if (!keystore->HasOpKeypairForFabric(fabric->GetFabricIndex())) { - CHIP_LOG_ERROR("No existing operational key for fabric"); + MTR_LOG_ERROR("No existing operational key for fabric"); return nil; } } @@ -242,7 +242,7 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable MutableByteSpan icaCert(icaBuf); CHIP_ERROR err = fabricTable->FetchICACert(fabric->GetFabricIndex(), icaCert); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Failed to get existing intermediate certificate: %s", ErrorStr(err)); + MTR_LOG_ERROR("Failed to get existing intermediate certificate: %s", ErrorStr(err)); return nil; } // There might not be an ICA cert for this fabric. @@ -284,7 +284,7 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable MutableByteSpan rootCert(rootBuf); CHIP_ERROR err = fabricTable->FetchRootCert(fabric->GetFabricIndex(), rootCert); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Failed to get existing root certificate: %s", ErrorStr(err)); + MTR_LOG_ERROR("Failed to get existing root certificate: %s", ErrorStr(err)); return nil; } oldRootCert = MatterCertToX509Data(rootCert); @@ -296,7 +296,7 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable if (self.rootCertificate == nil) { self.rootCertificate = oldRootCert; } else if ([MTRCertificates isCertificate:oldRootCert equalTo:self.rootCertificate] == NO) { - CHIP_LOG_ERROR("Root certificate identity does not match existing root certificate"); + MTR_LOG_ERROR("Root certificate identity does not match existing root certificate"); return nil; } @@ -314,20 +314,20 @@ - (BOOL)keypairsMatchCertificates if (signingCert == nil) { signingCert = self.rootCertificate; if (signingCert == nil) { - CHIP_LOG_ERROR("No certificate to match nocSigner"); + MTR_LOG_ERROR("No certificate to match nocSigner"); return NO; } } if ([MTRCertificates keypair:self.nocSigner matchesCertificate:signingCert] == NO) { - CHIP_LOG_ERROR("Provided nocSigner does not match certificates"); + MTR_LOG_ERROR("Provided nocSigner does not match certificates"); return NO; } } if (self.operationalCertificate != nil && self.operationalKeypair != nil) { if ([MTRCertificates keypair:self.operationalKeypair matchesCertificate:self.operationalCertificate] == NO) { - CHIP_LOG_ERROR("Provided operationalKeypair does not match operationalCertificate"); + MTR_LOG_ERROR("Provided operationalKeypair does not match operationalCertificate"); return NO; } } diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerXPCConnection.m b/src/darwin/Framework/CHIP/MTRDeviceControllerXPCConnection.m index f36724ee5faae8..f3354907d7a626 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerXPCConnection.m +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerXPCConnection.m @@ -91,7 +91,7 @@ - (void)getProxyHandleWithCompletion:(void (^)( if (!container) { NSXPCConnection * xpcConnection = self.connectBlock(); if (!xpcConnection) { - CHIP_LOG_ERROR("Cannot connect to XPC server for remote controller"); + MTR_LOG_ERROR("Cannot connect to XPC server for remote controller"); completion(self.workQueue, nil); return; } @@ -109,11 +109,11 @@ - (void)getProxyHandleWithCompletion:(void (^)( strongSelf.proxyHandle = nil; strongSelf.proxyRetainerForReports = nil; [strongSelf.reportRegistry removeAllObjects]; - CHIP_LOG_DEBUG("CHIP XPC connection disconnected"); + MTR_LOG_DEBUG("CHIP XPC connection disconnected"); }); } }; - CHIP_LOG_DEBUG("CHIP XPC connection established"); + MTR_LOG_DEBUG("CHIP XPC connection established"); } completion(self.workQueue, container); }); @@ -170,7 +170,7 @@ - (void)deregisterReportHandlersWithController:(id<NSCopying>)controller [self getProxyHandleWithCompletion:^(dispatch_queue_t _Nonnull queue, MTRDeviceControllerXPCProxyHandle * _Nullable handle) { if (handle) { - CHIP_LOG_DEBUG("CHIP XPC connection requests to stop reports"); + MTR_LOG_DEBUG("CHIP XPC connection requests to stop reports"); [handle.proxy stopReportsWithController:controller nodeId:nodeId completion:^{ @@ -179,7 +179,7 @@ - (void)deregisterReportHandlersWithController:(id<NSCopying>)controller clearRegistry(); }]; } else { - CHIP_LOG_ERROR("CHIP XPC connection failed to stop reporting"); + MTR_LOG_ERROR("CHIP XPC connection failed to stop reporting"); clearRegistry(); } }]; diff --git a/src/darwin/Framework/CHIP/MTRDeviceOverXPC.m b/src/darwin/Framework/CHIP/MTRDeviceOverXPC.m index 0bbefcdeab8655..d6008fdf603799 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceOverXPC.m +++ b/src/darwin/Framework/CHIP/MTRDeviceOverXPC.m @@ -56,7 +56,7 @@ - (void)subscribeWithQueue:(dispatch_queue_t)queue errorHandler:(void (^)(NSError * error))errorHandler subscriptionEstablished:(nullable void (^)(void))subscriptionEstablishedHandler; { - CHIP_LOG_DEBUG("Subscribing all attributes... Note that reportHandler is not supported."); + MTR_LOG_DEBUG("Subscribing all attributes... Note that reportHandler is not supported."); if (attributeCacheContainer) { [attributeCacheContainer setXPCConnection:_xpcConnection controllerId:self.controller deviceId:self.nodeId]; } @@ -81,7 +81,7 @@ - (void)subscribeWithQueue:(dispatch_queue_t)queue (void) handleRetainer; }]; } else { - CHIP_LOG_ERROR("Failed to obtain XPC connection to write attribute"); + MTR_LOG_ERROR("Failed to obtain XPC connection to write attribute"); dispatch_async(queue, ^{ errorHandler([NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]); }); @@ -96,7 +96,7 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId clientQueue:(dispatch_queue_t)clientQueue completion:(MTRDeviceResponseHandler)completion { - CHIP_LOG_DEBUG("Reading attribute ..."); + MTR_LOG_DEBUG("Reading attribute ..."); [_xpcConnection getProxyHandleWithCompletion:^(dispatch_queue_t _Nonnull queue, MTRDeviceControllerXPCProxyHandle * _Nullable handle) { if (handle) { @@ -108,7 +108,7 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId params:[MTRDeviceController encodeXPCReadParams:params] completion:^(id _Nullable values, NSError * _Nullable error) { dispatch_async(clientQueue, ^{ - CHIP_LOG_DEBUG("Attribute read"); + MTR_LOG_DEBUG("Attribute read"); completion([MTRDeviceController decodeXPCResponseValues:values], error); // The following captures the proxy handle in the closure so that the // handle won't be released prior to block call. @@ -118,7 +118,7 @@ - (void)readAttributeWithEndpointId:(NSNumber * _Nullable)endpointId }]; } else { dispatch_async(clientQueue, ^{ - CHIP_LOG_ERROR("Failed to obtain XPC connection to read attribute"); + MTR_LOG_ERROR("Failed to obtain XPC connection to read attribute"); completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]); }); } @@ -133,7 +133,7 @@ - (void)writeAttributeWithEndpointId:(NSNumber *)endpointId clientQueue:(dispatch_queue_t)clientQueue completion:(MTRDeviceResponseHandler)completion { - CHIP_LOG_DEBUG("Writing attribute ..."); + MTR_LOG_DEBUG("Writing attribute ..."); [_xpcConnection getProxyHandleWithCompletion:^(dispatch_queue_t _Nonnull queue, MTRDeviceControllerXPCProxyHandle * _Nullable handle) { if (handle) { @@ -146,7 +146,7 @@ - (void)writeAttributeWithEndpointId:(NSNumber *)endpointId timedWriteTimeout:timeoutMs completion:^(id _Nullable values, NSError * _Nullable error) { dispatch_async(clientQueue, ^{ - CHIP_LOG_DEBUG("Attribute written"); + MTR_LOG_DEBUG("Attribute written"); completion([MTRDeviceController decodeXPCResponseValues:values], error); // The following captures the proxy handle in the closure so that the // handle won't be released prior to block call. @@ -156,7 +156,7 @@ - (void)writeAttributeWithEndpointId:(NSNumber *)endpointId }]; } else { dispatch_async(clientQueue, ^{ - CHIP_LOG_ERROR("Failed to obtain XPC connection to write attribute"); + MTR_LOG_ERROR("Failed to obtain XPC connection to write attribute"); completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]); }); } @@ -171,7 +171,7 @@ - (void)invokeCommandWithEndpointId:(NSNumber *)endpointId clientQueue:(dispatch_queue_t)clientQueue completion:(MTRDeviceResponseHandler)completion { - CHIP_LOG_DEBUG("Invoking command ..."); + MTR_LOG_DEBUG("Invoking command ..."); [_xpcConnection getProxyHandleWithCompletion:^(dispatch_queue_t _Nonnull queue, MTRDeviceControllerXPCProxyHandle * _Nullable handle) { if (handle) { @@ -184,7 +184,7 @@ - (void)invokeCommandWithEndpointId:(NSNumber *)endpointId timedInvokeTimeout:timeoutMs completion:^(id _Nullable values, NSError * _Nullable error) { dispatch_async(clientQueue, ^{ - CHIP_LOG_DEBUG("Command invoked"); + MTR_LOG_DEBUG("Command invoked"); completion([MTRDeviceController decodeXPCResponseValues:values], error); // The following captures the proxy handle in the closure so that the // handle won't be released prior to block call. @@ -194,7 +194,7 @@ - (void)invokeCommandWithEndpointId:(NSNumber *)endpointId }]; } else { dispatch_async(clientQueue, ^{ - CHIP_LOG_ERROR("Failed to obtain XPC connection to invoke command"); + MTR_LOG_ERROR("Failed to obtain XPC connection to invoke command"); completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]); }); } @@ -211,21 +211,21 @@ - (void)subscribeAttributeWithEndpointId:(NSNumber * _Nullable)endpointId reportHandler:(MTRDeviceResponseHandler)reportHandler subscriptionEstablished:(void (^_Nullable)(void))subscriptionEstablishedHandler { - CHIP_LOG_DEBUG("Subscribing attribute ..."); + MTR_LOG_DEBUG("Subscribing attribute ..."); [_xpcConnection getProxyHandleWithCompletion:^( dispatch_queue_t _Nonnull queue, MTRDeviceControllerXPCProxyHandle * _Nullable handle) { if (handle) { - CHIP_LOG_DEBUG("Setup report handler"); + MTR_LOG_DEBUG("Setup report handler"); [self.xpcConnection registerReportHandlerWithController:self.controller nodeId:self.nodeId handler:^(id _Nullable values, NSError * _Nullable error) { if (values && ![values isKindOfClass:[NSArray class]]) { - CHIP_LOG_ERROR("Unsupported report format"); + MTR_LOG_ERROR("Unsupported report format"); return; } if (!values) { - CHIP_LOG_DEBUG("Error report received"); + MTR_LOG_DEBUG("Error report received"); dispatch_async(clientQueue, ^{ reportHandler(values, error); }); @@ -244,7 +244,7 @@ - (void)subscribeAttributeWithEndpointId:(NSNumber * _Nullable)endpointId } } if ([filteredValues count] > 0) { - CHIP_LOG_DEBUG("Report received"); + MTR_LOG_DEBUG("Report received"); dispatch_async(clientQueue, ^{ reportHandler(filteredValues, error); }); @@ -260,7 +260,7 @@ - (void)subscribeAttributeWithEndpointId:(NSNumber * _Nullable)endpointId params:[MTRDeviceController encodeXPCSubscribeParams:params] establishedHandler:^{ dispatch_async(clientQueue, ^{ - CHIP_LOG_DEBUG("Subscription established"); + MTR_LOG_DEBUG("Subscription established"); subscriptionEstablishedHandler(); // The following captures the proxy handle in the closure so that the handle // won't be released prior to block call. @@ -270,7 +270,7 @@ - (void)subscribeAttributeWithEndpointId:(NSNumber * _Nullable)endpointId }]; } else { dispatch_async(clientQueue, ^{ - CHIP_LOG_ERROR("Failed to obtain XPC connection to subscribe to attribute"); + MTR_LOG_ERROR("Failed to obtain XPC connection to subscribe to attribute"); subscriptionEstablishedHandler(); reportHandler(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]); }); @@ -280,7 +280,7 @@ - (void)subscribeAttributeWithEndpointId:(NSNumber * _Nullable)endpointId - (void)deregisterReportHandlersWithClientQueue:(dispatch_queue_t)clientQueue completion:(void (^)(void))completion { - CHIP_LOG_DEBUG("Deregistering report handlers"); + MTR_LOG_DEBUG("Deregistering report handlers"); [_xpcConnection deregisterReportHandlersWithController:self.controller nodeId:self.nodeId completion:^{ diff --git a/src/darwin/Framework/CHIP/MTRLogging.h b/src/darwin/Framework/CHIP/MTRLogging.h index f0a42014898895..f2bcb33f12d555 100644 --- a/src/darwin/Framework/CHIP/MTRLogging.h +++ b/src/darwin/Framework/CHIP/MTRLogging.h @@ -18,15 +18,10 @@ #import <os/log.h> -#if DEBUG -#define CHIP_LOG_DEBUG(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) -#define CHIP_LOG_ERROR(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) -#define CHIP_LOG_METHOD_ENTRY() \ - ({ os_log(OS_LOG_DEFAULT, "[<%@: %p> %@]", NSStringFromClass([self class]), self, NSStringFromSelector(_cmd)); }) +#define MTR_LOG_FAULT(format, ...) os_log_fault(OS_LOG_DEFAULT, format, ##__VA_ARGS__) +#define MTR_LOG_ERROR(format, ...) os_log_error(OS_LOG_DEFAULT, format, ##__VA_ARGS__) +#define MTR_LOG_INFO(format, ...) os_log_info(OS_LOG_DEFAULT, format, ##__VA_ARGS__) +#define MTR_LOG_DEBUG(format, ...) os_log_debug(OS_LOG_DEFAULT, format, ##__VA_ARGS__) -#else -#define CHIP_LOG_DEBUG(...) -#define CHIP_LOG_ERROR(...) -#define CHIP_LOG_METHOD_ENTRY() ({}) - -#endif +#define MTR_LOG_METHOD_ENTRY() \ + ({ os_log_debug(OS_LOG_DEFAULT, "[<%@: %p> %@]", NSStringFromClass([self class]), self, NSStringFromSelector(_cmd)); }) diff --git a/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm b/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm index d9ab100268ea24..f8dcd67391362a 100644 --- a/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm +++ b/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm @@ -52,7 +52,7 @@ mIssuerKey = std::move(nocSigner); if ([ipk length] != mIPK.Length()) { - CHIP_LOG_ERROR("MTROperationalCredentialsDelegate::init provided IPK is wrong size"); + MTR_LOG_ERROR("MTROperationalCredentialsDelegate::init provided IPK is wrong size"); return CHIP_ERROR_INVALID_ARGUMENT; } memcpy(mIPK.Bytes(), [ipk bytes], [ipk length]); diff --git a/src/darwin/Framework/CHIP/MTRP256KeypairBridge.mm b/src/darwin/Framework/CHIP/MTRP256KeypairBridge.mm index fe8cedd04aa0e4..a48c2bccc736f7 100644 --- a/src/darwin/Framework/CHIP/MTRP256KeypairBridge.mm +++ b/src/darwin/Framework/CHIP/MTRP256KeypairBridge.mm @@ -79,7 +79,7 @@ CHIP_ERROR MTRP256KeypairBridge::ECDSA_sign_msg(const uint8_t * msg, size_t msg_length, P256ECDSASignature & out_signature) const { if (!HasKeypair()) { - CHIP_LOG_ERROR("ECDSA sign msg failure: no keypair to sign with."); + MTR_LOG_ERROR("ECDSA sign msg failure: no keypair to sign with."); return CHIP_ERROR_INCORRECT_STATE; } NSData * msgData = [NSData dataWithBytes:msg length:msg_length]; @@ -87,7 +87,7 @@ if ([mKeypair respondsToSelector:@selector(signMessageECDSA_DER:)]) { signature = [mKeypair signMessageECDSA_DER:msgData]; if (!signature) { - CHIP_LOG_ERROR("ECDSA sign msg failure: no signature returned"); + MTR_LOG_ERROR("ECDSA sign msg failure: no signature returned"); return CHIP_ERROR_INTERNAL; } @@ -96,24 +96,24 @@ CHIP_ERROR err = EcdsaAsn1SignatureToRaw(kP256_FE_Length, AsByteSpan(signature), rawSignature); if (err != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Converting ASN.1 DER signature to raw form failed: %s", chip::ErrorStr(err)); + MTR_LOG_ERROR("Converting ASN.1 DER signature to raw form failed: %s", chip::ErrorStr(err)); return err; } signature = AsData(rawSignature); if (!signature) { - CHIP_LOG_ERROR("Failed to create NSData for raw signature"); + MTR_LOG_ERROR("Failed to create NSData for raw signature"); return CHIP_ERROR_INTERNAL; } } else { signature = [mKeypair signMessageECDSA_RAW:msgData]; if (!signature) { - CHIP_LOG_ERROR("ECDSA sign msg failure: no signature returned"); + MTR_LOG_ERROR("ECDSA sign msg failure: no signature returned"); return CHIP_ERROR_INTERNAL; } } if (signature.length > out_signature.Capacity()) { - CHIP_LOG_ERROR("ECDSA sign msg failure: unexpected signature size %llu vs %llu", static_cast<uint64_t>(signature.length), + MTR_LOG_ERROR("ECDSA sign msg failure: unexpected signature size %llu vs %llu", static_cast<uint64_t>(signature.length), static_cast<uint64_t>(out_signature.Capacity())); return CHIP_ERROR_NO_MEMORY; } @@ -137,17 +137,17 @@ CHIP_ERROR MTRP256KeypairBridge::MatterPubKeyFromSecKeyRef(SecKeyRef pubkeyRef, P256PublicKey * matterPubKey) { if (!pubkeyRef) { - CHIP_LOG_ERROR("Unable to initialize Pubkey"); + MTR_LOG_ERROR("Unable to initialize Pubkey"); return CHIP_ERROR_INTERNAL; } NSData * pubkeyData = (__bridge_transfer NSData *) SecKeyCopyExternalRepresentation(pubkeyRef, nil); if (!pubkeyData) { - CHIP_LOG_ERROR("Unable to copy external representation for publicKey ref, cannot initialize publicKey"); + MTR_LOG_ERROR("Unable to copy external representation for publicKey ref, cannot initialize publicKey"); return CHIP_ERROR_INTERNAL; } if (pubkeyData.length != kP256_PublicKey_Length) { - CHIP_LOG_ERROR("Unexpected publicKey length, cannot initialize publicKey"); + MTR_LOG_ERROR("Unexpected publicKey length, cannot initialize publicKey"); return CHIP_ERROR_INTERNAL; } chip::FixedByteSpan<kP256_PublicKey_Length> pubkeyBytes((const uint8_t *) pubkeyData.bytes); diff --git a/src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm b/src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm index a83930f9d1c0eb..945551724ca798 100644 --- a/src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm +++ b/src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm @@ -62,7 +62,7 @@ - (BOOL)_populateCppOperationalDataset _cppThreadOperationalDataset.SetNetworkName([self.networkName cStringUsingEncoding:NSUTF8StringEncoding]); if (![self _checkDataLength:self.extendedPANID expectedLength:chip::Thread::kSizeExtendedPanId]) { - CHIP_LOG_ERROR("Invalid ExtendedPANID"); + MTR_LOG_ERROR("Invalid ExtendedPANID"); return NO; } uint8_t extendedPanId[chip::Thread::kSizeExtendedPanId]; @@ -70,7 +70,7 @@ - (BOOL)_populateCppOperationalDataset _cppThreadOperationalDataset.SetExtendedPanId(extendedPanId); if (![self _checkDataLength:self.masterKey expectedLength:chip::Thread::kSizeMasterKey]) { - CHIP_LOG_ERROR("Invalid MasterKey"); + MTR_LOG_ERROR("Invalid MasterKey"); return NO; } uint8_t masterKey[chip::Thread::kSizeMasterKey]; @@ -78,7 +78,7 @@ - (BOOL)_populateCppOperationalDataset _cppThreadOperationalDataset.SetMasterKey(masterKey); if (![self _checkDataLength:self.PSKc expectedLength:chip::Thread::kSizePSKc]) { - CHIP_LOG_ERROR("Invalid PKSc"); + MTR_LOG_ERROR("Invalid PKSc"); return NO; } uint8_t PSKc[chip::Thread::kSizePSKc]; @@ -89,7 +89,7 @@ - (BOOL)_populateCppOperationalDataset // Thread's PAN ID is 2 bytes if (![self _checkDataLength:self.panID expectedLength:2]) { - CHIP_LOG_ERROR("Invalid PAN ID"); + MTR_LOG_ERROR("Invalid PAN ID"); return NO; } uint16_t * valuePtr = (uint16_t *) [self.panID bytes]; @@ -105,7 +105,7 @@ - (BOOL)_populateCppOperationalDataset - (BOOL)_checkDataLength:(NSData *)data expectedLength:(size_t)expectedLength { if (data.length != expectedLength) { - CHIP_LOG_ERROR("Length Check Failed. Length:%tu is incorrect, must be %tu", data.length, expectedLength); + MTR_LOG_ERROR("Length Check Failed. Length:%tu is incorrect, must be %tu", data.length, expectedLength); return NO; } return YES; @@ -117,7 +117,7 @@ - (nullable instancetype)initWithData:(NSData *)data auto dataset = chip::Thread::OperationalDataset(); CHIP_ERROR error = dataset.Init(span); if (error != CHIP_NO_ERROR) { - CHIP_LOG_ERROR("Failed to parse data, cannot construct Operational Dataset. %s", chip::ErrorStr(error)); + MTR_LOG_ERROR("Failed to parse data, cannot construct Operational Dataset. %s", chip::ErrorStr(error)); return nil; } // len+1 for null termination diff --git a/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m b/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m index e4d20c29e32344..3b3b3bc26ac38a 100644 --- a/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m +++ b/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m @@ -131,7 +131,7 @@ @interface MTRDeviceControllerServerSample () @end // This sample does not have multiple controllers and hence controller Id shall be the same. -static NSString * const MTRDeviceControllerId = @"CHIPController"; +static NSString * const MTRDeviceControllerId = @"MTRController"; @implementation MTRDeviceControllerServerSample