mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Add user role to node list
This commit is contained in:
parent
0807fbfcaa
commit
089e13db08
4 changed files with 23 additions and 16 deletions
|
|
@ -40,7 +40,6 @@ import CoreLocation
|
|||
self.manager = CLLocationManager() // Creating a location manager instance is safe to call here in `MainActor`.
|
||||
locationsArray = [CLLocation]()
|
||||
enableSmartPosition = true
|
||||
self.manager.distanceFilter = 5
|
||||
}
|
||||
|
||||
func startLocationUpdates() {
|
||||
|
|
@ -66,7 +65,7 @@ import CoreLocation
|
|||
locationAdded = true
|
||||
}
|
||||
if !locationAdded {
|
||||
print("Bad Location \(self.count): \(loc)")
|
||||
//print("Bad Location \(self.count): \(loc)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,12 +84,15 @@ import CoreLocation
|
|||
func addLocation(_ location: CLLocation) -> Bool {
|
||||
let age = -location.timestamp.timeIntervalSinceNow
|
||||
if age > 10 {
|
||||
print("Bad Location \(self.count): Too Old \(location)")
|
||||
return false
|
||||
}
|
||||
if location.horizontalAccuracy < 0 {
|
||||
print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)")
|
||||
return false
|
||||
}
|
||||
if location.horizontalAccuracy > 100 {
|
||||
print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)")
|
||||
return false
|
||||
}
|
||||
locationsArray.append(location)
|
||||
|
|
|
|||
|
|
@ -268,6 +268,7 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje
|
|||
newUser.shortName = nodeInfo.user.shortName
|
||||
newUser.hwModel = String(describing: nodeInfo.user.hwModel).uppercased()
|
||||
newUser.isLicensed = nodeInfo.user.isLicensed
|
||||
newUser.role = Int32(nodeInfo.user.role.rawValue)
|
||||
newNode.user = newUser
|
||||
} else {
|
||||
let newUser = UserEntity(context: context)
|
||||
|
|
@ -337,6 +338,7 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje
|
|||
fetchedNode[0].user!.longName = nodeInfo.user.longName
|
||||
fetchedNode[0].user!.shortName = nodeInfo.user.shortName
|
||||
fetchedNode[0].user!.isLicensed = nodeInfo.user.isLicensed
|
||||
fetchedNode[0].user!.role = Int32(nodeInfo.user.role.rawValue)
|
||||
fetchedNode[0].user!.hwModel = String(describing: nodeInfo.user.hwModel).uppercased()
|
||||
} else {
|
||||
if (fetchedNode[0].user == nil) {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ struct NodeListItem: View {
|
|||
LastHeardText(lastHeard: node.lastHeard)
|
||||
.font(.callout)
|
||||
}
|
||||
HStack {
|
||||
let role = DeviceRoles(rawValue: Int(node.user?.role ?? 0))
|
||||
Image(systemName: role?.systemName ?? "figure")
|
||||
.font(.callout)
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
Text("Role: \(role?.name ?? "unknown".localized)")
|
||||
.font(.callout)
|
||||
}
|
||||
if node.positions?.count ?? 0 > 0 && connectedNode != node.num {
|
||||
HStack {
|
||||
let lastPostion = node.positions!.reversed()[0] as! PositionEntity
|
||||
|
|
@ -89,7 +97,6 @@ struct NodeListItem: View {
|
|||
.font(.callout)
|
||||
}
|
||||
}
|
||||
|
||||
if !connected {
|
||||
HStack {
|
||||
let preset = ModemPresets(rawValue: Int(modemPreset))
|
||||
|
|
|
|||
|
|
@ -46,9 +46,14 @@ struct TraceRouteLog: View {
|
|||
VStack {
|
||||
if selectedRoute != nil {
|
||||
if selectedRoute?.response ?? false && selectedRoute?.hops?.count ?? 0 > 0 {
|
||||
Text("Received by \(selectedRoute?.node?.user?.longName ?? "unknown".localized)")
|
||||
Text("Route: \(selectedRoute?.routeText ?? "unknown".localized)")
|
||||
.font(.title3)
|
||||
|
||||
Label {
|
||||
Text("Route: \(selectedRoute?.routeText ?? "unknown".localized)")
|
||||
} icon: {
|
||||
Image(systemName: "signpost.right.and.left")
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
}
|
||||
.font(.title2)
|
||||
} else if selectedRoute?.response ?? false {
|
||||
Label {
|
||||
Text("Trace route received directly by \(selectedRoute?.node?.user?.longName ?? "unknown".localized)")
|
||||
|
|
@ -56,7 +61,7 @@ struct TraceRouteLog: View {
|
|||
Image(systemName: "signpost.right.and.left")
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
}
|
||||
.font(.title3)
|
||||
.font(.title2)
|
||||
}
|
||||
|
||||
let hopsArray = selectedRoute?.hops?.array as? [TraceRouteHopEntity] ?? []
|
||||
|
|
@ -128,15 +133,6 @@ struct TraceRouteLog: View {
|
|||
.symbolRenderingMode(.hierarchical)
|
||||
}
|
||||
.font(.title3)
|
||||
Divider()
|
||||
Label {
|
||||
Text("\(selectedRoute?.time?.formatted() ?? "") - No response")
|
||||
|
||||
} icon: {
|
||||
Image(systemName: "person.slash")
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
}
|
||||
.font(.callout)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue