mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
More cleanup
This commit is contained in:
parent
3b8b5ff7d8
commit
5501574530
9 changed files with 14 additions and 95 deletions
|
|
@ -36,7 +36,6 @@
|
|||
DD457188293C7E63000C49FB /* SignalStrengthIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD457187293C7E63000C49FB /* SignalStrengthIndicator.swift */; };
|
||||
DD47E3CE26F103C600029299 /* NodeList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3CD26F103C600029299 /* NodeList.swift */; };
|
||||
DD47E3D626F17ED900029299 /* CircleText.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3D526F17ED900029299 /* CircleText.swift */; };
|
||||
DD47E3D926F3093800029299 /* MessageBubble.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD47E3D826F3093800029299 /* MessageBubble.swift */; };
|
||||
DD4A911E2708C65400501B7E /* AppSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD4A911D2708C65400501B7E /* AppSettings.swift */; };
|
||||
DD4C158C2824A91E0032668E /* module_config.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD4C158B2824A91E0032668E /* module_config.pb.swift */; };
|
||||
DD4C158E2824AA7E0032668E /* config.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD4C158D2824AA7E0032668E /* config.pb.swift */; };
|
||||
|
|
@ -155,7 +154,6 @@
|
|||
DD457BC4295D5E35004BCE4D /* MeshtasticDataModelV5.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV5.xcdatamodel; sourceTree = "<group>"; };
|
||||
DD47E3CD26F103C600029299 /* NodeList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeList.swift; sourceTree = "<group>"; };
|
||||
DD47E3D526F17ED900029299 /* CircleText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleText.swift; sourceTree = "<group>"; };
|
||||
DD47E3D826F3093800029299 /* MessageBubble.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageBubble.swift; sourceTree = "<group>"; };
|
||||
DD4A911D2708C65400501B7E /* AppSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettings.swift; sourceTree = "<group>"; };
|
||||
DD4C158B2824A91E0032668E /* module_config.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = module_config.pb.swift; sourceTree = "<group>"; };
|
||||
DD4C158D2824AA7E0032668E /* config.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = config.pb.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -521,7 +519,6 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
DD47E3D526F17ED900029299 /* CircleText.swift */,
|
||||
DD47E3D826F3093800029299 /* MessageBubble.swift */,
|
||||
DDF924C926FBB953009FE055 /* ConnectedDevice.swift */,
|
||||
DDC3B273283F411B00AC321C /* LastHeardText.swift */,
|
||||
DDA6B2EA28420A7B003E8C16 /* NodeAnnotation.swift */,
|
||||
|
|
@ -796,7 +793,6 @@
|
|||
DDD94A502845C8F5004A87A0 /* DateTimeText.swift in Sources */,
|
||||
C9A88B57278B559900BD810A /* apponly.pb.swift in Sources */,
|
||||
DD4C158E2824AA7E0032668E /* config.pb.swift in Sources */,
|
||||
DD47E3D926F3093800029299 /* MessageBubble.swift in Sources */,
|
||||
DDB6ABE228B13FB500384BA1 /* PositionConfigEnums.swift in Sources */,
|
||||
DD415828285859C4009B0E59 /* TelemetryConfig.swift in Sources */,
|
||||
DD73FD1128750779000852D6 /* PositionLog.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ 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 = "🚨" + String.localizedStringWithFormat(NSLocalizedString("%@ meshlog.ble.errorcode.6",
|
||||
lastConnectionError = "🚨" + String.localizedStringWithFormat(NSLocalizedString("%@ 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)")
|
||||
|
|
@ -217,7 +217,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
|
||||
} 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 = "🚨" + String.localizedStringWithFormat(NSLocalizedString("%@ meshlog.ble.errorcode.14",
|
||||
lastConnectionError = "🚨" + String.localizedStringWithFormat(NSLocalizedString("%@ 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)")
|
||||
|
|
@ -288,31 +288,25 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
}
|
||||
|
||||
func requestDeviceMetadata() {
|
||||
|
||||
guard (connectedPeripheral!.peripheral.state == CBPeripheralState.connected) else { return }
|
||||
|
||||
MeshLogger.log("ℹ️ Requesting Device Metadata for \(connectedPeripheral!.peripheral.name ?? "Unknown")")
|
||||
|
||||
var adminPacket = AdminMessage()
|
||||
adminPacket.getDeviceMetadataRequest = true
|
||||
|
||||
var meshPacket: MeshPacket = MeshPacket()
|
||||
meshPacket.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
|
||||
meshPacket.priority = MeshPacket.Priority.reliable
|
||||
meshPacket.wantAck = true
|
||||
|
||||
var dataMessage = DataMessage()
|
||||
dataMessage.payload = try! adminPacket.serializedData()
|
||||
dataMessage.portnum = PortNum.adminApp
|
||||
dataMessage.wantResponse = true
|
||||
|
||||
meshPacket.decoded = dataMessage
|
||||
|
||||
var toRadio: ToRadio = ToRadio()
|
||||
toRadio.packet = meshPacket
|
||||
|
||||
let binaryData: Data = try! toRadio.serializedData()
|
||||
connectedPeripheral!.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse)
|
||||
|
||||
// Either Read the config complete value or from num notify value
|
||||
connectedPeripheral!.peripheral.readValue(for: FROMRADIO_characteristic)
|
||||
}
|
||||
|
|
@ -341,7 +335,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
if connectedPeripheral!.peripheral.state == CBPeripheralState.connected {
|
||||
connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse)
|
||||
success = true
|
||||
MeshLogger.log("🪧 Sent a Trace Route Packet to node: \(destNum).")
|
||||
MeshLogger.log("🪧 Sent a Trace Route Request to node: \(destNum).")
|
||||
}
|
||||
return success
|
||||
}
|
||||
|
|
@ -354,7 +348,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
invalidVersion = true
|
||||
return
|
||||
} else {
|
||||
MeshLogger.log("ℹ️ Issuing wantConfig to \(connectedPeripheral!.peripheral.name ?? "Unknown")")
|
||||
MeshLogger.log("ℹ️ Issuing Want Config to \(connectedPeripheral!.peripheral.name ?? "Unknown")")
|
||||
//BLE Characteristics discovered, issue wantConfig
|
||||
var toRadio: ToRadio = ToRadio()
|
||||
configNonce += 1
|
||||
|
|
@ -367,7 +361,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
}
|
||||
|
||||
func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?) {
|
||||
|
||||
if let errorText = error?.localizedDescription {
|
||||
print("🚫 didUpdateNotificationStateFor error: \(errorText)")
|
||||
}
|
||||
|
|
@ -386,7 +379,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
// BLE PIN connection errors
|
||||
// 5 CBATTErrorDomain Code=5 "Authentication is insufficient."
|
||||
// 15 CBATTErrorDomain Code=15 "Encryption is insufficient."
|
||||
lastConnectionError = "🚨" + String.localizedStringWithFormat(NSLocalizedString("%@ meshlog.ble.errorcode.pin",
|
||||
lastConnectionError = "🚨" + String.localizedStringWithFormat(NSLocalizedString("%@ ble.errorcode.pin",
|
||||
comment: "Please try connecting again and check the PIN carefully."),
|
||||
e.localizedDescription)
|
||||
print("🚨 \(e.localizedDescription) Please try connecting again and check the PIN carefully.")
|
||||
|
|
@ -433,7 +426,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
let supportedVersion = connectedVersion == "0.0.0" || self.minimumVersion.compare(connectedVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(connectedVersion, options: .numeric) == .orderedSame
|
||||
if !supportedVersion {
|
||||
invalidVersion = true
|
||||
lastConnectionError = "🚨 Update your firmware"
|
||||
lastConnectionError = "🚨" + NSLocalizedString("update.firmware", comment: "Update Your Firmware")
|
||||
return
|
||||
|
||||
} else {
|
||||
|
|
@ -573,7 +566,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
lastConnectionError = ""
|
||||
timeoutTimerRuns = 0
|
||||
isSubscribed = true
|
||||
MeshLogger.log("🤜 Want Config Request Complete. Packet Id: \(decodedInfo.configCompleteID)")
|
||||
print("🤜 Want Config Complete. ID:\(decodedInfo.configCompleteID)")
|
||||
peripherals.removeAll(where: { $0.peripheral.state == CBPeripheralState.disconnected })
|
||||
// Config conplete returns so we don't read the characteristic again
|
||||
// MARK: Share Location Position Update Timer
|
||||
|
|
|
|||
|
|
@ -1272,20 +1272,15 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage
|
|||
do {
|
||||
|
||||
let fetchedNode = try context.fetch(fetchNodeTelemetryRequest) as! [NodeInfoEntity]
|
||||
|
||||
if fetchedNode.count == 1 {
|
||||
|
||||
if telemetryMessage.variant == Telemetry.OneOf_Variant.deviceMetrics(telemetryMessage.deviceMetrics) {
|
||||
|
||||
// Device Metrics
|
||||
telemetry.airUtilTx = telemetryMessage.deviceMetrics.airUtilTx
|
||||
telemetry.channelUtilization = telemetryMessage.deviceMetrics.channelUtilization
|
||||
telemetry.batteryLevel = Int32(telemetryMessage.deviceMetrics.batteryLevel)
|
||||
telemetry.voltage = telemetryMessage.deviceMetrics.voltage
|
||||
telemetry.metricsType = 0
|
||||
|
||||
} else if telemetryMessage.variant == Telemetry.OneOf_Variant.environmentMetrics(telemetryMessage.environmentMetrics) {
|
||||
|
||||
// Environment Metrics
|
||||
telemetry.barometricPressure = telemetryMessage.environmentMetrics.barometricPressure
|
||||
telemetry.current = telemetryMessage.environmentMetrics.current
|
||||
|
|
@ -1295,12 +1290,10 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage
|
|||
telemetry.current = telemetryMessage.environmentMetrics.current
|
||||
telemetry.voltage = telemetryMessage.environmentMetrics.voltage
|
||||
telemetry.metricsType = 1
|
||||
|
||||
}
|
||||
telemetry.time = Date(timeIntervalSince1970: TimeInterval(Int64(telemetryMessage.time)))
|
||||
let mutableTelemetries = fetchedNode[0].telemetries!.mutableCopy() as! NSMutableOrderedSet
|
||||
mutableTelemetries.add(telemetry)
|
||||
|
||||
fetchedNode[0].lastHeard = telemetry.time
|
||||
fetchedNode[0].telemetries = mutableTelemetries.copy() as? NSOrderedSet
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ struct InvalidVersion: View {
|
|||
|
||||
VStack {
|
||||
|
||||
Text("Update Firmware")
|
||||
Text("update.firmware")
|
||||
.font(.largeTitle)
|
||||
.foregroundColor(.orange)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
import SwiftUI
|
||||
|
||||
struct MessageBubble: View {
|
||||
|
||||
@State var showAlert = false
|
||||
var contentMessage: String
|
||||
var isCurrentUser: Bool
|
||||
var time: Int32
|
||||
var shortName: String
|
||||
var id: UInt32
|
||||
|
||||
var body: some View {
|
||||
|
||||
HStack(alignment: .top) {
|
||||
|
||||
CircleText(text: shortName, color: isCurrentUser ? .accentColor : Color(.gray)).padding(.all, 5)
|
||||
.gesture(LongPressGesture(minimumDuration: 2)
|
||||
.onEnded {_ in
|
||||
print("I want to delete message: \(id)")
|
||||
self.showAlert = true
|
||||
})
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text(contentMessage)
|
||||
.textSelection(.enabled)
|
||||
.padding(10)
|
||||
.foregroundColor(.white)
|
||||
.background(isCurrentUser ? .accentColor : Color(.gray))
|
||||
.cornerRadius(10)
|
||||
HStack(spacing: 4) {
|
||||
|
||||
let messageDate = Date(timeIntervalSince1970: TimeInterval(time))
|
||||
|
||||
if time != 0 {
|
||||
Text(messageDate, style: .date).font(.caption2).foregroundColor(.gray)
|
||||
Text(messageDate, style: .time).font(.caption2).foregroundColor(.gray)
|
||||
} else {
|
||||
Text("Unknown").font(.caption2).foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
.padding(.bottom, 10)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.alert(isPresented: $showAlert) {
|
||||
|
||||
Alert(title: Text("Are you sure you want to delete this message?"), message: Text("This action is permanent."),
|
||||
primaryButton: .destructive(Text("OK")) {
|
||||
print("OK button tapped")
|
||||
},
|
||||
secondaryButton: .cancel()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MessageBubble_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
MessageBubble(contentMessage: "this is the best text ever", isCurrentUser: true, time: 0, shortName: "EB", id: 12)
|
||||
}
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ struct NodeAnnotation: View {
|
|||
} else {
|
||||
|
||||
VStack(spacing: 0) {
|
||||
Text("Unknown Time")
|
||||
Text("unknown.age")
|
||||
.font(.caption2).foregroundColor(.accentColor)
|
||||
.padding(5)
|
||||
.background(Color(.white))
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct MeshLog: View {
|
|||
@State private var document: LogDocument = LogDocument(logFile: "MESHTASTIC MESH ACTIVITY LOG\n")
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
||||
List(logs, id: \.self, rowContent: Text.init)
|
||||
.task {
|
||||
do {
|
||||
|
|
@ -62,9 +62,8 @@ struct MeshLog: View {
|
|||
}
|
||||
}
|
||||
)
|
||||
|
||||
.textSelection(.enabled)
|
||||
.font(.caption)
|
||||
.font(.caption2)
|
||||
|
||||
HStack(alignment: .center) {
|
||||
Spacer()
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@
|
|||
"timeout"="Zeitlimit erreicht";
|
||||
"twitter"="Twitter";
|
||||
"unknown.age"="Unbekanntes alter";
|
||||
"update.firmware"="Update Your Firmware";
|
||||
"update.interval"="Update intervall";
|
||||
"user"="Benutzer";
|
||||
"user.details"="Benutzer Details";
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@
|
|||
"timeout"="timeout";
|
||||
"twitter"="Twitter";
|
||||
"unknown.age"="Unknown Age";
|
||||
"update.firmware"="Update Your Firmware";
|
||||
"update.interval"="Update Interval";
|
||||
"user"="User";
|
||||
"user.details"="User Details";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue