diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index b76648f4..8998dd69 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -991,7 +991,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1100; - LastUpgradeCheck = 1100; + LastUpgradeCheck = 1030; TargetAttributes = { 9AF8AE8821E967844EEF26BBB341564D = { LastSwiftMigration = 1020; @@ -1327,7 +1327,6 @@ baseConfigurationReference = 2C723040DECD495E1AAC81F5AA497C97 /* Pods-macOSDFULibrary_Example.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; @@ -1362,7 +1361,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 6CCC32CD1F9DE588C70537578CFC9DB9 /* iOSDFULibrary-macOS.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; @@ -1429,7 +1427,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7D90563942E115795A1F5E9E6C7A0D26 /* ZIPFoundation-macOS.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; @@ -1464,7 +1461,6 @@ baseConfigurationReference = 890A09B61D0F51EA84B75D5E02FE58D2 /* Pods-macOSDFULibrary_Example.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; @@ -1499,7 +1495,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 6CCC32CD1F9DE588C70537578CFC9DB9 /* iOSDFULibrary-macOS.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; @@ -1752,7 +1747,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7D90563942E115795A1F5E9E6C7A0D26 /* ZIPFoundation-macOS.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Zip-iOS.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Zip-iOS.xcscheme index 351b6d73..5d4533be 100644 --- a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Zip-iOS.xcscheme +++ b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Zip-iOS.xcscheme @@ -1,6 +1,6 @@ @@ -45,7 +45,7 @@ diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/iOSDFULibrary-macOS.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/iOSDFULibrary-macOS.xcscheme index abdba8e5..add170f5 100644 --- a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/iOSDFULibrary-macOS.xcscheme +++ b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/iOSDFULibrary-macOS.xcscheme @@ -1,6 +1,6 @@ @@ -45,7 +45,7 @@ diff --git a/Example/Pods/Target Support Files/iOSDFULibrary-iOS/iOSDFULibrary-iOS-Info.plist b/Example/Pods/Target Support Files/iOSDFULibrary-iOS/iOSDFULibrary-iOS-Info.plist index 7be5c8c8..f4569cc5 100644 --- a/Example/Pods/Target Support Files/iOSDFULibrary-iOS/iOSDFULibrary-iOS-Info.plist +++ b/Example/Pods/Target Support Files/iOSDFULibrary-iOS/iOSDFULibrary-iOS-Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.5.0 + 4.5.1 CFBundleSignature ???? CFBundleVersion diff --git a/Example/Pods/Target Support Files/iOSDFULibrary-macOS/iOSDFULibrary-macOS-Info.plist b/Example/Pods/Target Support Files/iOSDFULibrary-macOS/iOSDFULibrary-macOS-Info.plist index 7be5c8c8..f4569cc5 100644 --- a/Example/Pods/Target Support Files/iOSDFULibrary-macOS/iOSDFULibrary-macOS-Info.plist +++ b/Example/Pods/Target Support Files/iOSDFULibrary-macOS/iOSDFULibrary-macOS-Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.5.0 + 4.5.1 CFBundleSignature ???? CFBundleVersion diff --git a/Example/iOSDFULibrary.xcodeproj/project.pbxproj b/Example/iOSDFULibrary.xcodeproj/project.pbxproj index cafc4d3c..60dad698 100644 --- a/Example/iOSDFULibrary.xcodeproj/project.pbxproj +++ b/Example/iOSDFULibrary.xcodeproj/project.pbxproj @@ -20,6 +20,8 @@ 52237250202B117700068EE4 /* CustomTestSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5223724F202B117700068EE4 /* CustomTestSet.swift */; }; 5223729B202B275F00068EE4 /* Firmwares in Resources */ = {isa = PBXBuildFile; fileRef = 5223729A202B275F00068EE4 /* Firmwares */; }; 5223729D2036DDFC00068EE4 /* nRF52840TestSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5223729C2036DDFC00068EE4 /* nRF52840TestSet.swift */; }; + 52A9C167230D633A0036792A /* changelog.md in Resources */ = {isa = PBXBuildFile; fileRef = 52A9C166230D633A0036792A /* changelog.md */; }; + 52A9C169230D63410036792A /* documentation.md in Resources */ = {isa = PBXBuildFile; fileRef = 52A9C168230D63410036792A /* documentation.md */; }; 52F6AD6222B2429300F0D7DF /* TestFirmwares in Resources */ = {isa = PBXBuildFile; fileRef = 52F6AD6122B2429300F0D7DF /* TestFirmwares */; }; 52FB0B022220168D00B1E575 /* PeripheralCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52FB0B012220168D00B1E575 /* PeripheralCell.swift */; }; 52FB0B04222019C700B1E575 /* MainNavigationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52FB0B03222019C700B1E575 /* MainNavigationViewController.swift */; }; @@ -62,6 +64,8 @@ 5223724F202B117700068EE4 /* CustomTestSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTestSet.swift; sourceTree = ""; }; 5223729A202B275F00068EE4 /* Firmwares */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Firmwares; sourceTree = ""; }; 5223729C2036DDFC00068EE4 /* nRF52840TestSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = nRF52840TestSet.swift; sourceTree = ""; }; + 52A9C166230D633A0036792A /* changelog.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = changelog.md; path = ../changelog.md; sourceTree = ""; }; + 52A9C168230D63410036792A /* documentation.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = documentation.md; path = ../documentation.md; sourceTree = ""; }; 52F6AD6122B2429300F0D7DF /* TestFirmwares */ = {isa = PBXFileReference; lastKnownFileType = folder; path = TestFirmwares; sourceTree = ""; }; 52FB0B012220168D00B1E575 /* PeripheralCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeripheralCell.swift; sourceTree = ""; }; 52FB0B03222019C700B1E575 /* MainNavigationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainNavigationViewController.swift; sourceTree = ""; }; @@ -229,6 +233,8 @@ children = ( 3B0557890E61EFF388A8734B /* iOSDFULibrary.podspec */, 8EE39CA79039E8FFBDA0C9D3 /* README.md */, + 52A9C166230D633A0036792A /* changelog.md */, + 52A9C168230D63410036792A /* documentation.md */, DAEFE092DC94AFC6C8316559 /* LICENSE */, ); name = "Podspec Metadata"; @@ -389,8 +395,10 @@ buildActionMask = 2147483647; files = ( 52F6AD6222B2429300F0D7DF /* TestFirmwares in Resources */, + 52A9C169230D63410036792A /* documentation.md in Resources */, 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, 52FB0B0622201A4A00B1E575 /* LaunchScreen.storyboard in Resources */, + 52A9C167230D633A0036792A /* changelog.md in Resources */, 5223729B202B275F00068EE4 /* Firmwares in Resources */, 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, ); diff --git a/Example/iOSDFULibrary.xcodeproj/xcshareddata/xcschemes/iOSDFULibrary-Example.xcscheme b/Example/iOSDFULibrary.xcodeproj/xcshareddata/xcschemes/iOSDFULibrary-Example.xcscheme index 7d3d8b6c..bf7ebfee 100644 --- a/Example/iOSDFULibrary.xcodeproj/xcshareddata/xcschemes/iOSDFULibrary-Example.xcscheme +++ b/Example/iOSDFULibrary.xcodeproj/xcshareddata/xcschemes/iOSDFULibrary-Example.xcscheme @@ -1,6 +1,6 @@ DFUServiceController? { // The firmware file must be specified before calling `start(...)`. - if file == nil { + guard let _ = file else { delegate?.dfuError(.fileNotSpecified, didOccurWithMessage: "Firmware not specified") return nil } - // As the given peripheral was obtained using a different central manager, - // its new instance must be obtained from the new manager. - guard let peripheral = self.centralManager.retrievePeripherals(withIdentifiers: [uuid]).first else { - delegate?.dfuError(.bluetoothDisabled, didOccurWithMessage: "Could not obtain peripheral instance") - return nil - } - target = peripheral + targetIdentifier = uuid let controller = DFUServiceController() let selector = DFUServiceSelector(initiator: self, controller: controller) diff --git a/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift b/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift index 907af030..061ec5d5 100644 --- a/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift +++ b/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift @@ -50,6 +50,7 @@ internal protocol BaseDFUPeripheralAPI : class, DFUController { internal class BaseDFUPeripheral : NSObject, BaseDFUPeripheralAPI, CBPeripheralDelegate, CBCentralManagerDelegate { /// Bluetooth Central Manager used to scan for the peripheral. internal let centralManager: CBCentralManager + internal let targetIdentifier: UUID internal let queue: DispatchQueue /// The DFU Target peripheral. internal var peripheral: CBPeripheral? @@ -89,14 +90,13 @@ internal class BaseDFUPeripheral : NSObject, BaseDF init(_ initiator: DFUServiceInitiator, _ logger: LoggerHelper) { self.centralManager = initiator.centralManager + self.targetIdentifier = initiator.targetIdentifier self.queue = initiator.queue self.logger = logger self.experimentalButtonlessServiceInSecureDfuEnabled = initiator.enableUnsafeExperimentalButtonlessServiceInSecureDfu self.uuidHelper = initiator.uuidHelper super.init() - // Set the initial peripheral. It may be changed later (flashing App fw after first flashing SD/BL) - self.peripheral = initiator.target } // MARK: - Base DFU Peripheral API @@ -109,14 +109,20 @@ internal class BaseDFUPeripheral : NSObject, BaseDF // Central manager not ready. Wait for poweredOn state. return } + // Set the initial peripheral. It may be changed later (flashing App fw after first flashing SD/BL). + guard let peripheral = centralManager.retrievePeripherals(withIdentifiers: [targetIdentifier]).first else { + delegate?.error(.bluetoothDisabled, didOccurWithMessage: "Could not obtain peripheral instance") + return + } + self.peripheral = peripheral - if peripheral!.state != .connected { + if peripheral.state != .connected { connect() } else { - let name = peripheral!.name ?? "Unknown device" + let name = peripheral.name ?? "Unknown device" logger.i("Connected to \(name)") - let dfuService = findDfuService(in: peripheral!.services) + let dfuService = findDfuService(in: peripheral.services) if dfuService == nil { // DFU service has not been found, but it doesn't matter it's not there. // Perhaps the user's application didn't discover it. Let's discover DFU services.