Skip to content

Instantly share code, notes, and snippets.

@bitbytedog
Created February 3, 2018 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitbytedog/f9e923a98de08eed5d55d40704f43db0 to your computer and use it in GitHub Desktop.
Save bitbytedog/f9e923a98de08eed5d55d40704f43db0 to your computer and use it in GitHub Desktop.
diff --git a/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift b/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift
index c6874fa..9590280 100644
--- a/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift
+++ b/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift
@@ -478,7 +478,13 @@ internal class BaseCommonDFUPeripheral<TD : DFUPeripheralDelegate, TS : DFUServi
activating = false
// This part of firmware has been successfully sent
if (delegate?.peripheralDidDisconnectAfterFirmwarePartSent() ?? false) {
- connect()
+ if newAddressExpected {
+ newAddressExpected = false
+ // Scan for a new device and connect to it
+ switchToNewPeripheralAndConnect()
+ } else {
+ connect()
+ }
}
} else {
super.peripheralDidDisconnect()
diff --git a/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift b/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift
index 24339e9..cb8decc 100644
--- a/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift
+++ b/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift
@@ -173,6 +173,7 @@ internal class LegacyDFUPeripheral : BaseCommonDFUPeripheral<LegacyDFUExecutor,
*/
func activateAndReset() {
activating = true
+ newAddressExpected = true;
dfuService!.sendActivateAndResetRequest(
// onSuccess the device gets disconnected and centralManager(_:didDisconnectPeripheral:error) will be called
onError: defaultErrorCallback
diff --git a/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift b/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift
index c6874fa..9590280 100644
--- a/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift
+++ b/iOSDFULibrary/Classes/Implementation/GenericDFU/DFUPeripheral.swift
@@ -478,7 +478,13 @@ internal class BaseCommonDFUPeripheral<TD : DFUPeripheralDelegate, TS : DFUServi
activating = false
// This part of firmware has been successfully sent
if (delegate?.peripheralDidDisconnectAfterFirmwarePartSent() ?? false) {
- connect()
+ if newAddressExpected {
+ newAddressExpected = false
+ // Scan for a new device and connect to it
+ switchToNewPeripheralAndConnect()
+ } else {
+ connect()
+ }
}
} else {
super.peripheralDidDisconnect()
diff --git a/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift b/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift
index 24339e9..cb8decc 100644
--- a/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift
+++ b/iOSDFULibrary/Classes/Implementation/LegacyDFU/Peripherals/LegacyDFUPeripheral.swift
@@ -173,6 +173,7 @@ internal class LegacyDFUPeripheral : BaseCommonDFUPeripheral<LegacyDFUExecutor,
*/
func activateAndReset() {
activating = true
+ newAddressExpected = true;
dfuService!.sendActivateAndResetRequest(
// onSuccess the device gets disconnected and centralManager(_:didDisconnectPeripheral:error) will be called
onError: defaultErrorCallback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment