diff --git a/Podfile b/Podfile index 559c56ff..e9de649a 100644 --- a/Podfile +++ b/Podfile @@ -16,7 +16,7 @@ def shared_pods pod 'MZTimerLabel', '~> 0.5.4' pod 'PureLayout', '~> 3.1.4' pod 'SVProgressHUD', '~> 2.2.5' - pod 'UICircularProgressRing', '~> 4.1.0' + pod 'UICircularProgressRing' pod 'WYPopoverController', :git => 'https://github.com/sammcewan/WYPopoverController.git' pod 'XMLDictionary', '~> 1.4.1' pod 'Realm', '~> 4.3.2' diff --git a/Podfile.lock b/Podfile.lock index d472747d..87da6e8d 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,6 +1,6 @@ PODS: - ActionSheetPicker-3.0 (2.3.1) - - AEXML (4.6.1) + - AEXML (4.7.0) - ChameleonFramework (2.1.0): - ChameleonFramework/Default (= 2.1.0) - ChameleonFramework/Default (2.1.0) @@ -17,7 +17,7 @@ PODS: - MockingbirdFramework (0.20.0) - MZTimerLabel (0.5.4) - Nimble (10.0.0) - - OCMock (3.9.1) + - OCMock (3.9.3) - PureLayout (3.1.9) - Quick (5.0.1) - Realm (4.3.2): @@ -33,7 +33,7 @@ PODS: - RxSwift (6.2.0) - SVProgressHUD (2.2.5) - SwiftAlgorithms (1.0.0) - - UICircularProgressRing (4.1.0) + - UICircularProgressRing (8.0.0) - WYPopoverController (0.3.9) - XMLDictionary (1.4.1) @@ -58,7 +58,7 @@ DEPENDENCIES: - RxCocoa (~> 6.2.0) - RxSwift (~> 6.2.0) - SVProgressHUD (~> 2.2.5) - - UICircularProgressRing (~> 4.1.0) + - UICircularProgressRing - WYPopoverController (from `https://github.com/sammcewan/WYPopoverController.git`) - XMLDictionary (~> 1.4.1) @@ -100,7 +100,7 @@ CHECKOUT OPTIONS: SPEC CHECKSUMS: ActionSheetPicker-3.0: 2f5e3fde6b3205a7318f9338e4ec0f373ce7e75c - AEXML: 1e255ecc6597212f97a7454a69ebd3ede64ac1cf + AEXML: 5ff2a4695529348cda96b8b872cf73212ad050d7 ChameleonFramework: d21a3cc247abfe5e37609a283a8238b03575cf64 Charts: ce0768268078eee0336f122c3c4ca248e4e204c5 Crashlytics: a33af323773f73904037dc2e684cd2f0d29f4fe2 @@ -111,7 +111,7 @@ SPEC CHECKSUMS: MockingbirdFramework: 54e35fbbb47b806c1a1fae2cf3ef99f6eceb55e5 MZTimerLabel: cd9bfb9304540ef2a9e163384fca9c978f0dbf83 Nimble: 5316ef81a170ce87baf72dd961f22f89a602ff84 - OCMock: 9491e4bec59e0b267d52a9184ff5605995e74be8 + OCMock: 300b1b1b9155cb6378660b981c2557448830bdc6 PureLayout: 5fb5e5429519627d60d079ccb1eaa7265ce7cf88 Quick: 749aa754fd1e7d984f2000fe051e18a3a9809179 Realm: 5e92902e2875dff4bb0fd02f67bb737c3d5db2bc @@ -121,10 +121,10 @@ SPEC CHECKSUMS: RxSwift: d356ab7bee873611322f134c5f9ef379fa183d8f SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6 SwiftAlgorithms: 38dda4731d19027fdeee1125f973111bf3386b53 - UICircularProgressRing: 5a32c01f54474571b1e66e8fa050c0f83d6d981b + UICircularProgressRing: 19927375b2b21b5fa5fd9582f15ccdef9659da16 WYPopoverController: a9db25ac2841a686acdc0f3a99bdb21545db32f4 XMLDictionary: fa07b6ff422b3a91d47a5de9bc82e3fc04fbd167 -PODFILE CHECKSUM: ccf13e60e9ab41471864f78e72f744756afc259a +PODFILE CHECKSUM: 71204225fb042ea391e08f6d4636edc71735cda5 COCOAPODS: 1.12.1 diff --git a/SiliconLabsApp.xcodeproj/project.pbxproj b/SiliconLabsApp.xcodeproj/project.pbxproj index 2ed356f6..5f64cad6 100644 --- a/SiliconLabsApp.xcodeproj/project.pbxproj +++ b/SiliconLabsApp.xcodeproj/project.pbxproj @@ -5645,7 +5645,8 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Fabric/run\" d4644999f9acaab70a6af52eebed37881b8dc107 3ac40070001448c72125e7becb3d822cc0a1f74a30c6327231b6eb046bdd7e4e\n"; + shellScript = " +"; }; 0C2FCBD31F9A542300F4F259 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; @@ -6909,7 +6910,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_RESOURCE_RULES_PATH = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 11; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 52444FG85C; DISPLAY_NAME = "EFR Connect"; @@ -6922,12 +6923,12 @@ "GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/SiliconLabsApp/SupportingFiles/BlueGecko/Info.plist"; INFOPLIST_KEY_UIStatusBarStyle = UIStatusBarStyleLightContent; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.8.0; + MARKETING_VERSION = 2.8.1; PRODUCT_BUNDLE_IDENTIFIER = com.silabs.BlueGeckoDemoApp; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -6947,11 +6948,11 @@ CLANG_ENABLE_MODULES = YES; CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = NO; CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/SiliconLabsApp/SupportingFiles/BlueGecko/Entitlements.entitlements"; - CODE_SIGN_IDENTITY = "iPhone Distribution: Silicon Laboratories Inc (52444FG85C)"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Silicon Laboratories Inc (52444FG85C)"; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_RESOURCE_RULES_PATH = ""; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 11; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 52444FG85C; @@ -6964,16 +6965,16 @@ GCC_PREFIX_HEADER = "$(SRCROOT)/SiliconLabsApp/SupportingFiles/BlueGecko/BlueGecko.pch"; INFOPLIST_FILE = "$(SRCROOT)/SiliconLabsApp/SupportingFiles/BlueGecko/Info.plist"; INFOPLIST_KEY_UIStatusBarStyle = UIStatusBarStyleLightContent; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.8.0; + MARKETING_VERSION = 2.8.1; PRODUCT_BUNDLE_IDENTIFIER = com.silabs.BlueGeckoDemoApp; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "BlueGeckoDemoApp Distribution"; - "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "BlueGeckoDemoApp Distribution"; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = BlueGeckoSimplicityDemoApp_Distribution; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OBJC_BRIDGING_HEADER = "SiliconLabsApp-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-O"; diff --git a/SiliconLabsApp/Models/AttributeTableModels/SILCharacteristicTableModel.m b/SiliconLabsApp/Models/AttributeTableModels/SILCharacteristicTableModel.m index aed994a5..ee863ff9 100644 --- a/SiliconLabsApp/Models/AttributeTableModels/SILCharacteristicTableModel.m +++ b/SiliconLabsApp/Models/AttributeTableModels/SILCharacteristicTableModel.m @@ -177,7 +177,7 @@ - (BOOL)writeIfAllowedToPeripheral:(CBPeripheral *)peripheral withWriteType:(CBC } return NO; } - + NSLog(@" == Success flow Step-5 == write 1'st and last data to peripheral %@ data == ", dataToWrite); writeType = [self checkIfCharacteristicSupportsChosenWriteType:writeType]; [peripheral writeValue:dataToWrite forCharacteristic:self.characteristic type:writeType]; [self postRegisterLogNotification: [SILLogDataModel prepareLogDescriptionForWriteValueOfCharacteristic:self.characteristic andPeripheral:peripheral andError:*error andData:dataToWrite]]; diff --git a/SiliconLabsApp/Models/SILOTAFirmwareUpdateManager.m b/SiliconLabsApp/Models/SILOTAFirmwareUpdateManager.m index 76a64ed7..c4f8cfa8 100644 --- a/SiliconLabsApp/Models/SILOTAFirmwareUpdateManager.m +++ b/SiliconLabsApp/Models/SILOTAFirmwareUpdateManager.m @@ -18,7 +18,7 @@ #import "SILHomeKitManager.h" #endif -static NSTimeInterval const kSILDurationBeforeUpdatingDFUStatusToWaiting = 2.0; +static NSTimeInterval const kSILDurationBeforeUpdatingDFUStatusToWaiting = 10.0; static NSInteger const kSILOTAByteAlignment = 4; static unsigned char kSILOTAByteAlignmentPadding[] = {0xFF, 0xFF, 0xFF, 0xFF}; static char const kSILInitiateDFUData = 0x00; @@ -128,8 +128,12 @@ - (void)cycleDeviceWithInitiationByteSequence:(BOOL)initiatingByteSequence self.fileCompletion = completion; if (initiatingByteSequence && ![self.peripheral hasOTADataCharacteristic]) { - [self writeSingleByteValue:kSILInitiateDFUData toCharacteristic:[self.peripheral otaControlCharacteristic]]; + NSLog(@" ===== Success flow Step-3 == write initial single byte value 0x00 ====== "); + + const char kSILInitiateDFUDataTemp = 0x00; + [self writeSingleByteValue:kSILInitiateDFUDataTemp toCharacteristic:[self.peripheral otaControlCharacteristic]]; } else { + NSLog(@" ==== fail flow Step-2 == write single byte value ====== "); [self disconnectConnectedPeripheral]; } @@ -142,6 +146,7 @@ - (void)cycleDeviceWithInitiationByteSequence:(BOOL)initiatingByteSequence } - (void)endCycleDevice { + NSLog(@" ===== Step-4 == Remove Peripherals Observer from scan list ====== "); [self.centralManager removeScanForPeripheralsObserver:self]; } @@ -156,6 +161,7 @@ - (void)uploadFile:(SILOTAFirmwareFile *)file self.fileCompletion = completion; self.fileProgress = progress; self.firmwareUpdateMode = SILFirmwareModeUpdateFile; + [self uploadFile:file]; } @@ -235,7 +241,8 @@ - (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CB - (void)uploadFile:(SILOTAFirmwareFile *)file { self.expectingToDisconnectFromPeripheral = NO; - [self writeSingleByteValue:kSILInitiateDFUData toCharacteristic:[self.peripheral otaControlCharacteristic]]; + const char kSILInitiateDFUDataTemp = 0x00; + [self writeSingleByteValue:kSILInitiateDFUDataTemp toCharacteristic:[self.peripheral otaControlCharacteristic]]; self.otaControlWriteMode = SILOTAControlWriteModeInitiating; // TODO: Move something executing here to a background queue. There is too much happening on the main queue at this @@ -248,6 +255,8 @@ - (void)uploadFile:(SILOTAFirmwareFile *)file { // WriteWithoutResponse. self.length = [SILOTAFirmwareUpdateManager maximumByteAlignedWriteValueLengthForPeripheral:self.peripheral forType:CBCharacteristicWriteWithoutResponse]; if (self.location < self.fileData.length) { + + // steps to upload data [self writeFileDataToCharacteristic:[self.peripheral otaDataCharacteristic]]; } } else { @@ -268,6 +277,7 @@ - (void)writeFileDataToCharacteristic:(CBCharacteristic *)characteristic { NSInteger requiredAdditionalLength = kSILOTAByteAlignment - lengthPastByteAlignmentBoundary; [mutableData appendBytes:kSILOTAByteAlignmentPadding length:requiredAdditionalLength]; } + data = [[NSData alloc] initWithData:mutableData]; self.location = self.location + currentLength; } else { @@ -279,6 +289,7 @@ - (void)writeFileDataToCharacteristic:(CBCharacteristic *)characteristic { self.currentWriteCharacteristic = characteristic; } + NSLog(@" == Success flow Step-8 == write FW data to peripheral- %@ data == ", data); [self.peripheral writeValue:data forCharacteristic:characteristic type:self.delegate.characteristicWriteType]; }); } @@ -314,6 +325,7 @@ - (void)writeSingleByteValue:(char)value toCharacteristic:(CBCharacteristic *)ch SILCharacteristicTableModel *characteristicTableModel = [[SILCharacteristicTableModel alloc] initWithCharacteristic:characteristic]; NSData *data = [NSData dataWithBytes:&value length:1]; [characteristicTableModel setIfAllowedFullWriteValue:data]; + NSLog(@" == Success flow Step-4 == write type %ld == ", (long)writeType); [characteristicTableModel writeIfAllowedToPeripheral:self.peripheral withWriteType:writeType error:&error]; }); } diff --git a/SiliconLabsApp/Storyboards/DemoApps/SILAppTypeWifiCommissioning.storyboard b/SiliconLabsApp/Storyboards/DemoApps/SILAppTypeWifiCommissioning.storyboard index 8935cb4e..7e4d748f 100644 --- a/SiliconLabsApp/Storyboards/DemoApps/SILAppTypeWifiCommissioning.storyboard +++ b/SiliconLabsApp/Storyboards/DemoApps/SILAppTypeWifiCommissioning.storyboard @@ -1,9 +1,9 @@ - + - + @@ -42,27 +42,19 @@ - - - - - - - - - - - - + diff --git a/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILOTASetupViewController.m b/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILOTASetupViewController.m index 8af742e8..03df77a4 100644 --- a/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILOTASetupViewController.m +++ b/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILOTASetupViewController.m @@ -132,6 +132,7 @@ - (IBAction)didTapCancelButton:(id)sender { } - (IBAction)didTapStartOTAButton:(id)sender { + NSLog(@" == Success flow Step-1 == Click upload start button == "); [self.delegate otaSetupViewControllerEnterDFUModeForFirmwareUpdate:self.firmwareUpdateViewModel.otaFirmwareUpdate]; } diff --git a/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILOTAUICoordinator.m b/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILOTAUICoordinator.m index 611c0d3e..50eb7e38 100644 --- a/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILOTAUICoordinator.m +++ b/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILOTAUICoordinator.m @@ -160,6 +160,7 @@ - (NSString *)stringForDFUStatus:(SILDFUStatus)status { - (void)presentAlertControllerWithError:(NSError *)error animated:(BOOL)animated { NSError *underlyingError = error.userInfo[NSUnderlyingErrorKey]; + NSLog(@" Error flow == Step-2 == show GATT error popup == "); if (underlyingError.domain == CBATTErrorDomain) { SILErrorDetailsViewController* errorDetailsViewController = [[SILErrorDetailsViewController alloc] initWithError:underlyingError delegate:self]; @@ -180,6 +181,7 @@ - (void)handleNonATTError:(NSError*)error { UIAlertAction *action = [self alertActionForError:error]; [alert addAction:action]; + NSLog(@" Error flow == Step-3 == show GATT error popup == "); [self.presentingViewController presentViewController:alert animated:YES completion:^{ [self.otaTTL invalidate]; @@ -204,30 +206,36 @@ - (UIAlertAction *)alertActionForError:(NSError *)error { - (void)otaSetupViewControllerEnterDFUModeForFirmwareUpdate:(SILOTAFirmwareUpdate *)firmwareUpdate { [SVProgressHUD show]; - + NSLog(@" == Success flow Step-2 == show progress bar == "); self.otaMode = firmwareUpdate.updateMode; __weak SILOTAUICoordinator *weakSelf = self; - [self scheduleOtaTTLWithInitiationByteSequence:YES]; +// [self scheduleOtaTTLWithInitiationByteSequence:YES]; + + [self.otaFirmwareUpdateManager cycleDeviceWithInitiationByteSequence:YES progress:^(SILDFUStatus status) { [SVProgressHUD setStatus:[weakSelf stringForDFUStatus:status]]; } completion:^(CBPeripheral *peripheral, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - [SVProgressHUD dismiss]; - [self.otaTTL invalidate]; - if (error == nil) { - weakSelf.peripheral = peripheral; - [weakSelf otaSetupViewControllerDidInitiateFirmwareUpdate:firmwareUpdate]; - } else { - [weakSelf dismissPopoverWithCompletion:^{ - [weakSelf presentAlertControllerWithError:error animated:YES]; - }]; - } - }); + NSTimeInterval delayInSeconds = 1.0; + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); + dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ + [SVProgressHUD dismiss]; +// [self.otaTTL invalidate]; + if (error == nil) { + weakSelf.peripheral = peripheral; + NSLog(@" == Success flow Step-6 == Start uploadding data flow == "); + [weakSelf otaSetupViewControllerDidInitiateFirmwareUpdate:firmwareUpdate]; + } else { + [weakSelf dismissPopoverWithCompletion:^{ + [weakSelf presentAlertControllerWithError:error animated:YES]; + }]; + } + }); }]; } - (void)scheduleOtaTTLWithInitiationByteSequence:(BOOL)withInitiationByteSequence { + NSLog(@" == Step-3 == setup popup message text == "); const NSUInteger TimeToFindApploader = 10; const NSUInteger TimeToSearchAdvertising = 5; NSTimeInterval otaTTL = withInitiationByteSequence ? TimeToFindApploader : TimeToSearchAdvertising; @@ -235,6 +243,8 @@ - (void)scheduleOtaTTLWithInitiationByteSequence:(BOOL)withInitiationByteSequenc self.otaTTL = [NSTimer scheduledTimerWithTimeInterval:otaTTL repeats:NO block:^(NSTimer * _Nonnull timer) { [self.otaFirmwareUpdateManager endCycleDevice]; [SVProgressHUD dismiss]; + NSLog(@" == Step-5 == dismiss popup and go back to previous screen == "); + [self.presentingViewController dismissViewControllerAnimated:NO completion:nil]; [self.presentingViewController.navigationController popViewControllerAnimated:YES]; UIAlertAction *action = [UIAlertAction actionWithTitle:kSILOKButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { @@ -243,7 +253,7 @@ - (void)scheduleOtaTTLWithInitiationByteSequence:(BOOL)withInitiationByteSequenc UIAlertController *alertController = [UIAlertController alertControllerWithTitle:kSILFirmwareUpdateUnknownErrorTitle message:errorMessage preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:action]; [self.presentingViewController presentViewController:alertController animated:TRUE completion:^{ - + NSLog(@" == Step-6 == present alert == "); }]; }]; } @@ -274,10 +284,10 @@ - (void)otaSetupViewControllerDidInitiateFirmwareUpdate:(SILOTAFirmwareUpdate *) [weakSelf handleAppFileUploadCompletionForPeripheral:peripheral error:error]; } }; - + NSLog(@" == Success flow Step-7 == start show OTA circular Progress For Firmware File == "); [self showOTAProgressForFirmwareFile:firmwareFile ofType:firmwareFileType outOf:numberOfFilesToUpload withCompletion:^{ [weakSelf.otaFirmwareUpdateManager uploadFile:firmwareFile - progress:^(NSInteger bytes, double fraction) { + progress:^(NSInteger bytes, double fraction) { [weakSelf handleFileUploadProgress:fraction uploadedBytes:bytes]; } completion:uploadFileCompletion]; diff --git a/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILPopoverViewController.m b/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILPopoverViewController.m index 54679630..4c177f0c 100644 --- a/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILPopoverViewController.m +++ b/SiliconLabsApp/ViewControllers/BluetoothBrowser/Details/OTA/SILPopoverViewController.m @@ -63,6 +63,7 @@ - (NSTimeInterval)transitionDuration:(id)t return kSILPopoverTransitionDuration; } +// popup animate Transition - (void)animateTransition:(id)transitionContext { UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; diff --git a/SiliconLabsApp/ViewControllers/BluetoothBrowser/SILBrowserTableDataSource.swift b/SiliconLabsApp/ViewControllers/BluetoothBrowser/SILBrowserTableDataSource.swift index d0660b8b..d8a39dae 100644 --- a/SiliconLabsApp/ViewControllers/BluetoothBrowser/SILBrowserTableDataSource.swift +++ b/SiliconLabsApp/ViewControllers/BluetoothBrowser/SILBrowserTableDataSource.swift @@ -20,7 +20,10 @@ import Foundation func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { guard let sectionViewModel = self.browserViewModel.peripheralViewModel(at: section) else { return 0 } - return sectionViewModel.isExpanded ? sectionViewModel.advertisementDataViewModels.count : 1 +// return sectionViewModel.isExpanded ? sectionViewModel.advertisementDataViewModels.count : 1 + // Add one cell count to show Manufacturer data, because cell count start from 1. + return sectionViewModel.isExpanded ? sectionViewModel.advertisementDataViewModels.count + 1 : 1 + } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { diff --git a/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/ClusterControllers/Cluster.storyboard b/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/ClusterControllers/Cluster.storyboard index 551d3265..a780a046 100644 --- a/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/ClusterControllers/Cluster.storyboard +++ b/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/ClusterControllers/Cluster.storyboard @@ -1,9 +1,9 @@ - + - + @@ -935,14 +935,14 @@ - + - + - + @@ -989,7 +989,7 @@ @@ -1087,23 +1220,38 @@ + + + + + + + + + + + + + + + @@ -1132,7 +1280,7 @@ - + diff --git a/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/QRCode/QRCodeViewController.h b/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/QRCode/QRCodeViewController.h index e493c217..26a06704 100644 --- a/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/QRCode/QRCodeViewController.h +++ b/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/QRCode/QRCodeViewController.h @@ -11,14 +11,28 @@ @end @interface QRCodeViewController: UIViewController -@property (nonatomic, retain) id delegate; -@property (weak, nonatomic) IBOutlet UIView * qrView; -@property (weak, nonatomic) IBOutlet UITextField * manualQrCodeTextField; -@property (weak, nonatomic) IBOutlet UIButton * pairButton; -@property (weak, nonatomic) IBOutlet UILabel *hintLbl; -@property (weak, nonatomic) IBOutlet UIView *addDeviceNameView; -@property (weak, nonatomic) IBOutlet UIView *addDeviceNamePopupView; -@property (weak, nonatomic) IBOutlet UITextField *nameInputTextField; -@property (weak, nonatomic) IBOutlet UIButton *addDeviceButton; +@property (nonatomic, retain) id _Nullable delegate; +@property (weak, nonatomic) IBOutlet UIView * _Nullable qrView; +@property (weak, nonatomic) IBOutlet UITextField * _Nullable manualQrCodeTextField; +@property (weak, nonatomic) IBOutlet UIButton * _Nullable pairButton; +@property (weak, nonatomic) IBOutlet UILabel * _Nullable hintLbl; +@property (weak, nonatomic) IBOutlet UIView * _Nullable addDeviceNameView; +@property (weak, nonatomic) IBOutlet UIView * _Nullable addDeviceNamePopupView; +@property (weak, nonatomic) IBOutlet UITextField * _Nullable nameInputTextField; +@property (weak, nonatomic) IBOutlet UIButton * _Nullable addDeviceButton; + +@property (weak, nonatomic) IBOutlet UIView * _Nullable qrCodeInfoView; +@property (weak, nonatomic) IBOutlet UILabel * _Nullable qrCodeInfoLabel; +@property (weak, nonatomic) IBOutlet UIButton * _Nullable qrCodeInfoButton; +@property (weak, nonatomic) IBOutlet UIView * _Nullable qrCodeInfoBGView; + +@property (weak, nonatomic) IBOutlet UILabel * _Nullable versionLabel; +@property (weak, nonatomic) IBOutlet UILabel * _Nullable vendorIdLabel; +@property (weak, nonatomic) IBOutlet UILabel * _Nullable productIdLabel; +@property (weak, nonatomic) IBOutlet UILabel * _Nullable discriminatorLabel; +@property (weak, nonatomic) IBOutlet UILabel * _Nullable setupPinCodeLabel; +@property (weak, nonatomic) IBOutlet UILabel * _Nullable discoveryCapabilitiesLabel; +@property (weak, nonatomic) IBOutlet UILabel * _Nullable commissioningFlow; +@property (weak, nonatomic) IBOutlet UIButton *cancelButton; @end diff --git a/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/QRCode/QRCodeViewController.m b/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/QRCode/QRCodeViewController.m index 3caaed7b..91536814 100644 --- a/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/QRCode/QRCodeViewController.m +++ b/SiliconLabsApp/ViewControllers/MatterDemo/MatterToolchipUtils/ViewController/QRCode/QRCodeViewController.m @@ -25,8 +25,6 @@ #define NETWORK_CHIP_PREFIX @"CHIP-" -#define NOT_APPLICABLE_STRING @"N/A" - @interface QRCodeViewController () @property (nonatomic, strong) AVCaptureSession * captureSession; @@ -71,6 +69,8 @@ @implementation QRCodeViewController { NSString *passwordStr; NSNumber * nodeIdAfterCommision; NSNumber * deviceTypeAfterCommission; +NSString * savedStrQrCode; +NSError * savedError; // MARK: UI Setup @@ -81,6 +81,9 @@ - (void)setupUI { self.pairButton.layer.cornerRadius = 8; self.hintLbl.text = @"Please position the camera to point at the QR Code. \n\nManual QR code payload ID:"; + _qrCodeInfoView.hidden = TRUE; + _qrCodeInfoBGView.layer.cornerRadius = 10; + _qrCodeInfoButton.layer.cornerRadius = 5; _addDeviceNameView.hidden = TRUE; _addDeviceNamePopupView.layer.cornerRadius = 5; _addDeviceButton.layer.cornerRadius = 5; @@ -108,6 +111,8 @@ - (void)viewDidLoad { [super viewDidLoad]; [self setupUI]; + savedStrQrCode = @""; + savedError = nil; dispatch_queue_t callbackQueue = dispatch_queue_create("com.csa.matter.qrcodevc.callback", DISPATCH_QUEUE_SERIAL); self.chipController = InitializeMTR(); [self.chipController setDeviceControllerDelegate:self queue:callbackQueue]; @@ -165,19 +170,7 @@ - (void)saveDevice:(NSNumber *)nodeId { return; } self->_descriptorClusterDeviceTypeStruct = value[0]; - //NSLog(@" deviceType:= %@",_descriptorClusterDeviceTypeStruct.deviceType); - - //Commented for flow change -// NSMutableDictionary * deviceDic = [[NSMutableDictionary alloc] init]; -// [deviceDic setObject:self->_descriptorClusterDeviceTypeStruct.deviceType forKey:@"deviceType"]; -// [deviceDic setObject:nodeId forKey:@"nodeId"]; -// [deviceDic setObject:@1 forKey:@"endPoint"]; -// [deviceDic setObject:@"1" forKey:@"isConnected"]; -// [MKdeviceListTemp addObject:deviceDic]; -// NSLog(@"deviceListTemp:- %@",MKdeviceListTemp); -// [[NSUserDefaults standardUserDefaults] setObject:MKdeviceListTemp forKey:@"saved_list"]; -// [[NSUserDefaults standardUserDefaults] synchronize]; - + nodeIdAfterCommision = nodeId; deviceTypeAfterCommission = self->_descriptorClusterDeviceTypeStruct.deviceType; @@ -268,8 +261,46 @@ - (void)controller:(MTRDeviceController *)controller commissioningSessionEstabli } } +- (NSString *)discoveryCapabilities:(MTRSetupPayload *)payload { + if (payload.rendezvousInformation == nil) { + return @"Unknown"; + } + switch ([payload.rendezvousInformation unsignedLongValue]) { + case MTRDiscoveryCapabilitiesNone: + return @"Unknown"; + case MTRDiscoveryCapabilitiesOnNetwork: + case MTRDiscoveryCapabilitiesBLE: + return @"BLE"; + case MTRDiscoveryCapabilitiesAllMask: + return @"Default"; + case MTRDiscoveryCapabilitiesSoftAP: + return @"Wi-Fi"; + default: return @"Default"; + } +} + // MARK: UI Helper methods +- (void) showQRCodeInfo:(MTRSetupPayload *) payload strQrCode:(NSString *)strQrCode error:(NSError *)error { + _qrCodeInfoView.hidden = FALSE; + + savedStrQrCode = strQrCode; + savedError = error; + + _versionLabel.text = [NSString stringWithFormat: @" Version: %@", payload.version]; + _vendorIdLabel.text = [NSString stringWithFormat: @" Vendor ID: %@", payload.vendorID]; + _productIdLabel.text = [NSString stringWithFormat: @" Product ID: %@", payload.productID]; + _discriminatorLabel.text = [NSString stringWithFormat: @" Discriminator: %@", payload.discriminator]; + if (@available(iOS 16.1, *)) { + _setupPinCodeLabel.text = [NSString stringWithFormat: @" Set up PIN Code: %@", payload.setUpPINCode]; + } else { + _setupPinCodeLabel.text = @"N/A"; + } + NSString * discoveryCapabilities = [self discoveryCapabilities: payload]; + _discoveryCapabilitiesLabel.text = [NSString stringWithFormat: @" Discovery Capabilities: %@", discoveryCapabilities]; + _commissioningFlow.text = [NSString stringWithFormat: @" Commissioning Flow: %lu", payload.commissioningFlow]; +} + - (void)manualCodeInitialState { _activityIndicator.hidden = YES; [SVProgressHUD dismiss]; @@ -784,15 +815,9 @@ - (void)scannedQRCode:(NSString *)qrCode { NSError * error; _setupPayload = [parser populatePayload: &error]; NSLog(@" _setupPayload:- %@", _setupPayload); - //ALERT... + // Show QR code info in popup with delay dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - //Commented for flow change... - // [self postScanningQRCodeState]; - // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, INDICATOR_DELAY), dispatch_get_main_queue(), ^{ - // [self displayQRCodeInSetupPayloadView:self->_setupPayload rawPayload:qrCode error:error]; - // }); - [self commissioningOption:qrCode error:error]; - + [self showQRCodeInfo:self.setupPayload strQrCode:qrCode error:error]; }); } @@ -819,6 +844,17 @@ - (void)displayManualCodeInSetupPayloadView:(MTRSetupPayload *)payload decimalSt } // MARK: IBActions + +- (IBAction)cancelQRInfoPopup:(id)sender { + _qrCodeInfoView.hidden = TRUE; + [self refresh]; +} + +- (IBAction)qrCodeInfoOkAction:(id)sender { + _qrCodeInfoView.hidden = TRUE; + [self commissioningOption:savedStrQrCode error:savedError]; +} + - (IBAction)addDeviceNameAction:(id)sender { // add device name NSString *trimmedTextFieldText = [self.nameInputTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; @@ -917,10 +953,7 @@ - (void)commissioningOption:(NSString *)strQrCode error:(NSError *)error { style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { - // CHANGE... // [self postScanningQRCodeState]; - NSLog(@"you pressed No, thanks button"); - // call method whatever u need isThread = @"WIFI"; // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, INDICATOR_DELAY), dispatch_get_main_queue(), ^{ // [self displayQRCodeInSetupPayloadView:self->_setupPayload rawPayload:strQrCode error:error]; diff --git a/SiliconLabsApp/ViewModels/WifiCommissioning/SILWifiCommissioningViewModel.swift b/SiliconLabsApp/ViewModels/WifiCommissioning/SILWifiCommissioningViewModel.swift index 00d1b1e8..d7684481 100644 --- a/SiliconLabsApp/ViewModels/WifiCommissioning/SILWifiCommissioningViewModel.swift +++ b/SiliconLabsApp/ViewModels/WifiCommissioning/SILWifiCommissioningViewModel.swift @@ -232,6 +232,7 @@ class SILWifiCommissioningViewModel { self.peripheralDelegate.notifyCharacteristic(characteristic: notifyCharacteristic) } + // handle Read Characteristic Value private func handleReadCharacteristicValue(_ value: Data) { let stringValue = String(data: value, encoding: .utf8) let bytes = value.bytes @@ -252,14 +253,30 @@ class SILWifiCommissioningViewModel { } let firmwareVersion = stringValue![2..<2 + firmwareVersionLength] debugPrint("Firmware version", firmwareVersion) - self.wifiCommissioningState.value = .firmwareVersionRead(version: firmwareVersion) + //self.wifiCommissioningState.value = .firmwareVersionRead(version: firmwareVersion) + + // Adding code for Firmware version + var firmareVersionString = "" + for (index, val) in bytes[2..<11].enumerated() { + if index < 2 { + let str = String(format:"%02X", val) + firmareVersionString = firmareVersionString + str + } else { + if index != 7 { + firmareVersionString = firmareVersionString + ".\(val)" + } + } + } + self.wifiCommissioningState.value = .firmwareVersionRead(version: firmareVersionString) + //End + self.checkConnectionStatus() case .scan: self.givenAccessPointsNumber = secondByte self.writeCommandState = .scan debugPrint("Given access points number:", secondByte) - + case .connectionStatus: guard self.writeCommandState == .connectionStatus else { return @@ -277,7 +294,7 @@ class SILWifiCommissioningViewModel { self.wifiCommissioningState.value = .checkingStatusFinished(false) } } - + case .join: guard wifiCommissioningState.value == .connectingStarted else { return