 
 extension BLEDiscoveryManager: CBCentralManagerDelegate {
     public func centralManager(_ central: CBCentralManager, willRestoreState state: [String : Any]) {
+        didRestoreState = true
+
         NuimoSwift.DDLogDebug("BLEDiscoveryManager willRestoreState with state \(central.state.rawValue) on queue \(DispatchQueue.currentQueueLabel)")
         guard let centralManager = centralManager else {
             queue.async { self.centralManager(central, willRestoreState: state) }


    internal let queue: DispatchQueue

    fileprivate var knownPeripheralUUIDs:   [UUID]
    fileprivate var deviceForUUID:          [UUID : BLEDevice] = [:]
    fileprivate var alreadyDiscoveredUUIDs: Set<UUID> = []

        }

        if centralManager.state.rawValue >= CBCentralManagerState.poweredOff.rawValue {
            if !didRestoreState {
                self.centralManager(central, willRestoreState: [:])
            }

            // Update all devices with a freshly retrieved peripheral from central manager for those which have an invalidated peripheral
            centralManager.retrievePeripherals(withIdentifiers: Array(deviceForUUID.keys)).forEach {
                guard let device = self.deviceForUUID[$0.identifier], device.peripheral == nil else { return }
