1.27.4 Hotfix for nil myinfo when cycling peripherals

This commit is contained in:
Garth Vander Houwen 2021-10-27 21:36:30 -07:00
parent 261af7de4b
commit 57dfbdd2e2
2 changed files with 6 additions and 3 deletions

View file

@ -174,7 +174,10 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
let peripheralIndex = peripherals.firstIndex(where: { $0.id == newPeripheral.id })
if peripheralIndex != nil {
newPeripheral.myInfo = self.meshData.nodes[peripheralIndex!].myInfo
if self.meshData.nodes[peripheralIndex!].myInfo != nil {
newPeripheral.myInfo = self.meshData.nodes[peripheralIndex!].myInfo
}
peripherals.remove(at: peripheralIndex!)
peripherals.append(newPeripheral)
print("Updating peripheral: \(peripheralName)");