From b098175df049fa59b71e50155946c9ba9d2b7a50 Mon Sep 17 00:00:00 2001 From: Sagar Dhawan Date: Wed, 2 Mar 2022 11:15:25 -0800 Subject: [PATCH] Make the iOS CHIPTool reboot the Matter stack prior to each pairing (#15729) --- .../View Controllers/QRCode/QRCodeViewController.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m index baaafe1c157e14..57977c63e2a622 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m @@ -788,11 +788,22 @@ - (NSString *)getNetworkName:(NSNumber *)discriminator return peripheralFullName; } +- (void)_restartMatterStack +{ + NSLog(@"Shutting down the stack"); + [self.chipController shutdown]; + NSLog(@"Starting up the stack"); + [self.chipController startup:nil vendorId:0 nocSigner:nil]; +} + - (void)handleRendezVousDefault:(NSString *)payload { NSError * error; uint64_t deviceID = CHIPGetNextAvailableDeviceID(); + // restart the Matter Stack before pairing (for reliability + testing restarts) + [self _restartMatterStack]; + if ([self.chipController pairDevice:deviceID onboardingPayload:payload error:&error]) { deviceID++; CHIPSetNextAvailableDeviceID(deviceID);