Clean up disconnect notification

This commit is contained in:
Garth Vander Houwen 2023-11-07 15:25:20 -08:00
parent fc658743bc
commit 263d79cfb6
5 changed files with 15 additions and 17 deletions

View file

@ -143,7 +143,7 @@
DDDB26422AABF655003AFCB7 /* NodeListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26412AABF655003AFCB7 /* NodeListItem.swift */; };
DDDB26442AAC0206003AFCB7 /* NodeDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26432AAC0206003AFCB7 /* NodeDetail.swift */; };
DDDB26462AACC0B7003AFCB7 /* NodeInfoItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26452AACC0B7003AFCB7 /* NodeInfoItem.swift */; };
DDDB26482AACD6D1003AFCB7 /* NodeMapControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26472AACD6D1003AFCB7 /* NodeMapControl.swift */; };
DDDB26482AACD6D1003AFCB7 /* NodeMapMapkit.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26472AACD6D1003AFCB7 /* NodeMapMapkit.swift */; };
DDDB443629F6287000EE2349 /* MapButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB443529F6287000EE2349 /* MapButtons.swift */; };
DDDB443D29F6592F00EE2349 /* NetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB443C29F6592F00EE2349 /* NetworkManager.swift */; };
DDDB444029F79AB000EE2349 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB443F29F79AB000EE2349 /* UserDefaults.swift */; };
@ -367,7 +367,7 @@
DDDB26412AABF655003AFCB7 /* NodeListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeListItem.swift; sourceTree = "<group>"; };
DDDB26432AAC0206003AFCB7 /* NodeDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeDetail.swift; sourceTree = "<group>"; };
DDDB26452AACC0B7003AFCB7 /* NodeInfoItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeInfoItem.swift; sourceTree = "<group>"; };
DDDB26472AACD6D1003AFCB7 /* NodeMapControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeMapControl.swift; sourceTree = "<group>"; };
DDDB26472AACD6D1003AFCB7 /* NodeMapMapkit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeMapMapkit.swift; sourceTree = "<group>"; };
DDDB26492AAD743E003AFCB7 /* MeshtasticDataModelV18.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV18.xcdatamodel; sourceTree = "<group>"; };
DDDB443529F6287000EE2349 /* MapButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapButtons.swift; sourceTree = "<group>"; };
DDDB443C29F6592F00EE2349 /* NetworkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkManager.swift; sourceTree = "<group>"; };
@ -631,7 +631,8 @@
DDAD49EB2AFAE82500B4425D /* Map */ = {
isa = PBXGroup;
children = (
DDDB26472AACD6D1003AFCB7 /* NodeMapControl.swift */,
DDB6CCFA2AAF805100945AF6 /* NodeMapSwiftUI.swift */,
DDDB26472AACD6D1003AFCB7 /* NodeMapMapkit.swift */,
);
path = Map;
sourceTree = "<group>";
@ -831,7 +832,6 @@
DDDB26432AAC0206003AFCB7 /* NodeDetail.swift */,
DDDB26452AACC0B7003AFCB7 /* NodeInfoItem.swift */,
DDDB26412AABF655003AFCB7 /* NodeListItem.swift */,
DDB6CCFA2AAF805100945AF6 /* NodeMapSwiftUI.swift */,
DD13AA482AB73BF400BA0C98 /* PositionPopover.swift */,
DD760AAD2ABAC706002C022E /* WaypointPopover.swift */,
);
@ -1117,7 +1117,7 @@
DDDB263F2AABEE20003AFCB7 /* NodeList.swift in Sources */,
DDA0B6B2294CDC55001356EC /* Channels.swift in Sources */,
DDB8F4102A9EE5B400230ECE /* Messages.swift in Sources */,
DDDB26482AACD6D1003AFCB7 /* NodeMapControl.swift in Sources */,
DDDB26482AACD6D1003AFCB7 /* NodeMapMapkit.swift in Sources */,
DD4A911E2708C65400501B7E /* AppSettings.swift in Sources */,
DD5E5209298EE33B00D21B61 /* module_config.pb.swift in Sources */,
DD2160AF28C5552500C17253 /* MQTTConfig.swift in Sources */,

View file

@ -209,14 +209,13 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
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.
if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString{
if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString {
manager.notifications = [
Notification(
id: (peripheral.identifier.uuidString),
title: "Disconnected from Preferred Device",
subtitle: "Device: \(peripheral.name ?? "unknown".localized)",
content: "Error Code: 7, seems to be what is received when a tbeam sleeps, immediately recconnecting does not work.",
target: "device"
title: "Radio Disconnected",
subtitle: "\(peripheral.name ?? "unknown".localized)",
content: e.localizedDescription
)
]
manager.schedule()
@ -228,14 +227,13 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
lastConnectionError = "🚨 " + String.localizedStringWithFormat("ble.errorcode.14 %@".localized, e.localizedDescription)
print("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(lastConnectionError)")
} else {
if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString{
if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString {
manager.notifications = [
Notification(
id: (peripheral.identifier.uuidString),
title: "Disconnected from Preferred Device",
subtitle: "Device: \(peripheral.name ?? "unknown".localized)",
content: "Error Code: \(errorCode), \(e.localizedDescription)",
target: "device"
title: "Radio Disconnected",
subtitle: "\(peripheral.name ?? "unknown".localized)",
content: e.localizedDescription
)
]
manager.schedule()

View file

@ -9,7 +9,7 @@ import CoreLocation
import MapKit
import WeatherKit
struct NodeMapControl: View {
struct NodeMapMapkit: View {
@Environment(\.managedObjectContext) var context
@EnvironmentObject var bleManager: BLEManager

View file

@ -44,7 +44,7 @@ struct NodeDetail: View {
if #available (iOS 17, macOS 14, *) {
NodeMapSwiftUI(node: node, showUserLocation: connectedNode?.num ?? 0 == node.num)
} else {
NodeMapControl(node: node)
NodeMapMapkit(node: node)
}
} label: {