diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 24cfae62..4ebfc0fb 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -110,7 +110,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { self.timeoutTimerRuns += 1 self.startScanning() } else { - MeshLogger.log("🚨 BLE Connecting 2 Second Timeout Timer Fired \(timeoutTimerCount) Time(s): \(name)") + print("🚨 BLE Connecting 2 Second Timeout Timer Fired \(timeoutTimerCount) Time(s): \(name)") } } @@ -206,26 +206,30 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { let errorCode = (e as NSError).code if errorCode == 6 { // CBError.Code.connectionTimeout The connection has timed out unexpectedly. // Happens when device is manually reset / powered off - lastConnectionError = "🚨 \(e.localizedDescription) The app will automatically reconnect to the preferred radio if it come back in range." - MeshLogger.log("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") + lastConnectionError = "🚨" + String.localizedStringWithFormat(NSLocalizedString("%@ meshlog.ble.errorcode.6", + comment: "The app will automatically reconnect to the preferred radio if it come back in range."), + e.localizedDescription) + print("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") } else if errorCode == 7 { // CBError.Code.peripheralDisconnected The specified device has disconnected from us. // Seems to be what is received when a tbeam sleeps, immediately recconnecting does not work. - lastConnectionError = e.localizedDescription - MeshLogger.log("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") + lastConnectionError = "🚨 \(e.localizedDescription)" + print("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") } else if errorCode == 14 { // Peer removed pairing information // Forgetting and reconnecting seems to be necessary so we need to show the user an error telling them to do that - lastConnectionError = "🚨 \(e.localizedDescription) This error usually cannot be fixed without forgetting the device unders Settings > Bluetooth and re-connecting to the radio." - MeshLogger.log("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(lastConnectionError)") + lastConnectionError = "🚨" + String.localizedStringWithFormat(NSLocalizedString("%@ meshlog.ble.errorcode.14", + comment: "This error usually cannot be fixed without forgetting the device unders Settings > Bluetooth and re-connecting to the radio."), + e.localizedDescription) + print("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(lastConnectionError)") } else { - lastConnectionError = e.localizedDescription - MeshLogger.log("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") + lastConnectionError = "🚨" + e.localizedDescription + print("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") } } else { // Disconnected without error which indicates user intent to disconnect // Happens when swiping to disconnect - MeshLogger.log("ℹ️ BLE Disconnected: \(peripheral.name ?? "Unknown"): User Initiated Disconnect") + print("ℹ️ BLE Disconnected: \(peripheral.name ?? "Unknown"): User Initiated Disconnect") } // Start a scan so the disconnected peripheral is moved to the peripherals[] if it is awake self.startScanning() @@ -240,7 +244,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { for service in services { if service.uuid == meshtasticServiceCBUUID { peripheral.discoverCharacteristics([TORADIO_UUID, FROMRADIO_UUID, FROMNUM_UUID], for: service) - MeshLogger.log("βœ… BLE Service for Meshtastic discovered by \(peripheral.name ?? "Unknown")") + print("βœ… BLE Service for Meshtastic discovered by \(peripheral.name ?? "Unknown")") } } } @@ -249,7 +253,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { if let e = error { - MeshLogger.log("🚫 BLE Discover Characteristics error for \(peripheral.name ?? "Unknown") \(e) disconnecting device") + print("🚫 BLE Discover Characteristics error for \(peripheral.name ?? "Unknown") \(e) disconnecting device") // Try and stop crashes when this error occurs disconnectPeripheral() return @@ -261,16 +265,16 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { switch characteristic.uuid { case TORADIO_UUID: - MeshLogger.log("βœ… BLE did discover TORADIO characteristic for Meshtastic by \(peripheral.name ?? "Unknown")") + print("βœ… BLE did discover TORADIO characteristic for Meshtastic by \(peripheral.name ?? "Unknown")") TORADIO_characteristic = characteristic case FROMRADIO_UUID: - MeshLogger.log("βœ… BLE did discover FROMRADIO characteristic for Meshtastic by \(peripheral.name ?? "Unknown")") + print("βœ… BLE did discover FROMRADIO characteristic for Meshtastic by \(peripheral.name ?? "Unknown")") FROMRADIO_characteristic = characteristic peripheral.readValue(for: FROMRADIO_characteristic) case FROMNUM_UUID: - MeshLogger.log("βœ… BLE did discover FROMNUM (Notify) characteristic for Meshtastic by \(peripheral.name ?? "Unknown")") + print("βœ… BLE did discover FROMNUM (Notify) characteristic for Meshtastic by \(peripheral.name ?? "Unknown")") FROMNUM_characteristic = characteristic peripheral.setNotifyValue(true, for: characteristic) diff --git a/de.lproj/Localizable.strings b/de.lproj/Localizable.strings index 17586228..6e51b564 100644 --- a/de.lproj/Localizable.strings +++ b/de.lproj/Localizable.strings @@ -17,6 +17,8 @@ "available.radios"="GerΓ€te in der NΓ€he"; "automatic.detection"="Automatische erkennung"; "ble.name"="BLE Name"; +"%@ ble.errorcode.6"=" %@! The app will automatically reconnect to the preferred radio if it come back in range."; +"%@ ble.errorcode.14"="%&!This error usually cannot be fixed without forgetting the device unders Settings > Bluetooth and re-connecting to the radio."; "bluetooth"="Bluetooth"; "bluetooth.config"="Bluetooth Konfiguration"; "bluetooth.mode.randompin"="ZufΓ€llige PIN"; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index 8ce5133e..7cf8588c 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -107,6 +107,8 @@ "map"="Mesh Map"; "map.type"="Map Type"; "mesh.log"="Mesh Log"; +"%@ ble.errorcode.6"=" %@! The app will automatically reconnect to the preferred radio if it come back in range."; +"%@ ble.errorcode.14"="This error usually cannot be fixed without forgetting the device unders Settings > Bluetooth and re-connecting to the radio."; "message"="Message"; "message.details"="Message Details"; "messages"="Messages";