From c3a4fc0044286b8072cdd630f57c39f4152207e6 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 1 Jul 2022 15:36:28 -0700 Subject: [PATCH] Fix more restyled issues --- .../QRCode/QRCodeViewController.m | 2 +- .../TemperatureSensorViewController.m | 50 +++++++++---------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m index 6b2994a90adf93..4ea1b7404b4cfa 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m @@ -497,7 +497,7 @@ - (void)onPairingComplete:(NSError * _Nullable)error } else { MTRDeviceController * controller = InitializeCHIP(); uint64_t deviceId = CHIPGetLastPairedDeviceId(); - if ([controller respondsToSelector:@selector(deviceBeingCommissionedOverBLE:) + if ([controller respondsToSelector:@selector(deviceBeingCommissionedOverBLE:) && [controller deviceBeingCommissionedOverBLE:deviceId]) { dispatch_async(dispatch_get_main_queue(), ^{ [self->_deviceList refreshDeviceList]; 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 29748052f34253..1a0384d3fc8841 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/Temperature Sensor/TemperatureSensorViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/Temperature Sensor/TemperatureSensorViewController.m @@ -219,49 +219,47 @@ - (void)reportFromUserEnteredSettings @"Sending temp reporting values: min %@ max %@ value %@", @(minIntervalSeconds), @(maxIntervalSeconds), @(deltaInCelsius)); if (CHIPGetConnectedDevice(^(MTRDevice * _Nullable chipDevice, NSError * _Nullable error) { - if (chipDevice) { - // Use a wildcard subscription + if (chipDevice) { + // Use a wildcard subscription [chipDevice subscribeWithQueue:dispatch_get_main_queue() minInterval:minIntervalSeconds maxInterval:maxIntervalSeconds params:nil cacheContainer:nil attributeReportHandler:^(NSArray * _Nullable reports) { - if ( !reports ) - return; - for (MTRAttributeReport * report in reports) { - // These should be exposed by the SDK - if ([report.path.cluster isEqualToNumber:@(MTRClusterTemperatureMeasurementID)] && - [report.path.attribute - isEqualToNumber:@(MTRClusterTemperatureMeasurementAttributeMeasuredValueID)]) { - if (report.error != nil) { - NSLog(@"Error reading temperature: %@", report.error); - } else { - __auto_type controller = [TemperatureSensorViewController currentController]; - if (controller != nil) { - [controller updateTempInUI:((NSNumber *) report.value).shortValue]; - } - } - } - } + if (!reports) + return; + for (MTRAttributeReport * report in reports) { + // These should be exposed by the SDK + if ([report.path.cluster isEqualToNumber:@(MTRClusterTemperatureMeasurementID)] && + [report.path.attribute isEqualToNumber:@(MTRClusterTemperatureMeasurementAttributeMeasuredValueID)]) { + if (report.error != nil) { + NSLog(@"Error reading temperature: %@", report.error); + } else { + __auto_type controller = [TemperatureSensorViewController currentController]; + if (controller != nil) { + [controller updateTempInUI:((NSNumber *) report.value).shortValue]; + } + } + } + } } eventReportHandler:nil errorHandler:^(NSError * error) { - NSLog(@"Status: update reportAttributeMeasuredValue completed with error %@", - [error description]); + NSLog(@"Status: update reportAttributeMeasuredValue completed with error %@", [error description]); } - subscriptionEstablished:(nullable void (^)(void))subscriptionEstablishedHandler { if (error) { - NSLog(@"Status: update reportAttributeMeasuredValue completed"); - } + subscriptionEstablished:(nullable void (^)(void))subscriptionEstablishedHandler { + if (error) { + NSLog(@"Status: update reportAttributeMeasuredValue completed"); + } ]; } else { NSLog(@"Status: Failed to establish a connection with the device"); } })) { NSLog(@"Status: Waiting for connection with the device"); - } else { - NSLog(@"Status: Failed to trigger the connection with the device"); } + else { NSLog(@"Status: Failed to trigger the connection with the device"); } } @end