From bb4967fbf419696f6bedaa3f24a5a73e42d546fc Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 17 Aug 2024 13:12:13 -0700 Subject: [PATCH] Use new set time method after want config is complete --- Meshtastic/Helpers/BLEManager.swift | 25 +++++++++++ .../Weather/LocalWeatherConditions.swift | 18 ++++---- .../Nodes/Helpers/Map/PositionPopover.swift | 31 +++++++------- .../Views/Nodes/Helpers/NodeListItem.swift | 4 +- Meshtastic/Views/Nodes/MeshMap.swift | 25 ++++++----- .../Sources/meshtastic/mesh.pb.swift | 42 ++++++++++++++++++- .../Sources/meshtastic/module_config.pb.swift | 2 +- .../Sources/meshtastic/portnums.pb.swift | 2 +- protobufs | 2 +- 9 files changed, 105 insertions(+), 46 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 4e7489dc..7e08ccfa 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -893,6 +893,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate lastConnectionError = "" isSubscribed = true Logger.mesh.info("🤜 [BLE] Want Config Complete. ID:\(decodedInfo.configCompleteID)") + sendTime() peripherals.removeAll(where: { $0.peripheral.state == CBPeripheralState.disconnected }) // Config conplete returns so we don't read the characteristic again @@ -1298,6 +1299,30 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate } } + public func sendTime() -> Bool { + var adminPacket = AdminMessage() + adminPacket.setTimeOnly = UInt32(Date().timeIntervalSince1970) + var meshPacket: MeshPacket = MeshPacket() + meshPacket.to = 0 + meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Bool { var adminPacket = AdminMessage() adminPacket.shutdownSeconds = 5 diff --git a/Meshtastic/Views/Helpers/Weather/LocalWeatherConditions.swift b/Meshtastic/Views/Helpers/Weather/LocalWeatherConditions.swift index 8f057610..27675141 100644 --- a/Meshtastic/Views/Helpers/Weather/LocalWeatherConditions.swift +++ b/Meshtastic/Views/Helpers/Weather/LocalWeatherConditions.swift @@ -101,7 +101,7 @@ struct WeatherConditionsCompactWidget: View { .font(temperature.length < 4 ? .system(size: 90) : .system(size: 60) ) } .frame(maxWidth: .infinity) - .frame(height: 175) + .frame(height: 150) .background(.tertiary, in: RoundedRectangle(cornerRadius: 20, style: .continuous)) } } @@ -123,7 +123,7 @@ struct HumidityCompactWidget: View { } .padding(.horizontal) .frame(maxWidth: .infinity) - .frame(height: 175) + .frame(height: 150) .background(.tertiary, in: RoundedRectangle(cornerRadius: 20, style: .continuous)) } } @@ -135,16 +135,15 @@ struct PressureCompactWidget: View { var body: some View { VStack(alignment: .leading) { Label { Text("PRESSURE") } icon: { Image(systemName: "gauge").symbolRenderingMode(.multicolor) } - .font(.caption2) + .font(.callout) Text(pressure) .font(pressure.length < 7 ? .system(size: 35) : .system(size: 30) ) Text(low ? "LOW" : "HIGH") .padding(.bottom) Text(unit) } - .padding(.horizontal) - .frame(maxWidth: .infinity) - .frame(height: 175) + .padding(.horizontal, 5) + .frame(width: 175, height: 175) .background(.tertiary, in: RoundedRectangle(cornerRadius: 20, style: .continuous)) } } @@ -156,17 +155,14 @@ struct WindCompactWidget: View { var body: some View { VStack(alignment: .leading) { Label { Text("WIND") } icon: { Image(systemName: "wind").foregroundColor(.accentColor) } - .font(.caption) Text("\(direction)") - .font(.caption) .padding(.bottom, 10) Text(speed) .font(.system(size: 35)) Text("Gusts \(gust)") } - .padding(.horizontal) - .frame(maxWidth: .infinity) - .frame(height: 175) + //.padding(.horizontal) + .frame(width: 175, height: 175) .background(.tertiary, in: RoundedRectangle(cornerRadius: 20, style: .continuous)) } } diff --git a/Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift b/Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift index 0c708058..6a717629 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift @@ -154,6 +154,22 @@ struct PositionPopover: View { .rotationEffect(degrees) } .padding(.bottom, 5) + /// Distance + if let lastLocation = locationsHandler.locationsArray.last { + /// Distance + if lastLocation.distance(from: CLLocation(latitude: LocationsHandler.DefaultLocation.latitude, longitude: LocationsHandler.DefaultLocation.longitude)) > 0.0 { + let metersAway = position.coordinate.distance(from: CLLocationCoordinate2D(latitude: lastLocation.coordinate.latitude, longitude: lastLocation.coordinate.longitude)) + Label { + Text("distance".localized + ": \(distanceFormatter.string(fromDistance: Double(metersAway)))") + .foregroundColor(.primary) + .font(idiom == .phone ? .callout : .body) + } icon: { + Image(systemName: "lines.measurement.horizontal") + .symbolRenderingMode(.hierarchical) + .frame(width: 35) + } + } + } /// Speed let speed = Measurement(value: Double(position.speed), unit: UnitSpeed.kilometersPerHour) Label { @@ -179,21 +195,6 @@ struct PositionPopover: View { } .padding(.bottom, 5) } - if let lastLocation = locationsHandler.locationsArray.last { - /// Distance - if lastLocation.distance(from: CLLocation(latitude: LocationsHandler.DefaultLocation.latitude, longitude: LocationsHandler.DefaultLocation.longitude)) > 0.0 { - let metersAway = position.coordinate.distance(from: CLLocationCoordinate2D(latitude: lastLocation.coordinate.latitude, longitude: lastLocation.coordinate.longitude)) - Label { - Text("distance".localized + ": \(distanceFormatter.string(fromDistance: Double(metersAway)))") - .foregroundColor(.primary) - .font(idiom == .phone ? .callout : .body) - } icon: { - Image(systemName: "lines.measurement.horizontal") - .symbolRenderingMode(.hierarchical) - .frame(width: 35) - } - } - } Spacer() } Spacer() diff --git a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift index 5d46806c..3013e8df 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeListItem.swift @@ -98,7 +98,7 @@ struct NodeListItem: View { DistanceText(meters: metersAway) .font(UIDevice.current.userInterfaceIdiom == .phone ? .callout : .caption) .foregroundColor(.gray) - let trueBearing = getBearingBetweenTwoPoints(point1: myCoord, point2: CLLocation(latitude: lastPostion.coordinate.latitude, longitude: lastPostion.coordinate.longitude)) + let trueBearing = getBearingBetweenTwoPoints(point1: myCoord, point2: nodeCoord) let headingDegrees = Angle.degrees(trueBearing) Image(systemName: "location.north") .font(.callout) @@ -124,7 +124,7 @@ struct NodeListItem: View { DistanceText(meters: metersAway) .font(UIDevice.current.userInterfaceIdiom == .phone ? .callout : .caption) .foregroundColor(.secondary) - let trueBearing = getBearingBetweenTwoPoints(point1: myCoord, point2: CLLocation(latitude: lastPostion.coordinate.latitude, longitude: lastPostion.coordinate.longitude)) + let trueBearing = getBearingBetweenTwoPoints(point1: myCoord, point2: nodeCoord) let headingDegrees = Angle.degrees(trueBearing) Image(systemName: "location.north") .font(.callout) diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 31923562..9e09a0c0 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -62,7 +62,6 @@ struct MeshMap: View { MapReader { reader in Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) { MeshMapContent(showUserLocation: $showUserLocation, showTraffic: $showTraffic, showPointsOfInterest: $showPointsOfInterest, selectedMapLayer: $selectedMapLayer, selectedPosition: $selectedPosition, selectedWaypoint: $selectedWaypoint) - } .mapScope(mapScope) .mapStyle(mapStyle) @@ -159,6 +158,7 @@ struct MeshMap: View { } .safeAreaInset(edge: .bottom, alignment: .trailing) { HStack { + Spacer() Button(action: { withAnimation { editingSettings = !editingSettings @@ -170,18 +170,17 @@ struct MeshMap: View { .tint(Color(UIColor.secondarySystemBackground)) .foregroundColor(.accentColor) .buttonStyle(.borderedProminent) - Spacer() - Button(action: { - withAnimation { - editingFilters = !editingFilters - } - }) { - Image(systemName: !editingFilters ? "line.3.horizontal.decrease.circle" : "line.3.horizontal.decrease.circle.fill") - .padding(.vertical, 5) - } - .tint(Color(UIColor.secondarySystemBackground)) - .foregroundColor(.accentColor) - .buttonStyle(.borderedProminent) +// Button(action: { +// withAnimation { +// editingFilters = !editingFilters +// } +// }) { +// Image(systemName: !editingFilters ? "line.3.horizontal.decrease.circle" : "line.3.horizontal.decrease.circle.fill") +// .padding(.vertical, 5) +// } +// .tint(Color(UIColor.secondarySystemBackground)) +// .foregroundColor(.accentColor) +// .buttonStyle(.borderedProminent) } .controlSize(.regular) .padding(5) diff --git a/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift index 1f4c60a5..ba12908d 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift @@ -342,6 +342,10 @@ public enum HardwareModel: SwiftProtobuf.Enum { /// SSD1306 OLED and No GPS case radiomaster900Bandit // = 74 + /// + /// Minewsemi ME25LS01 (ME25LE01_V1.0). NRF52840 w/ LR1110 radio, buttons and leds and pins. + case me25Ls014Y10Td // = 75 + /// /// ------------------------------------------------------------------------------------------------------------------------------------------ /// Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. @@ -429,6 +433,7 @@ public enum HardwareModel: SwiftProtobuf.Enum { case 72: self = .rak3172 case 73: self = .wioE5 case 74: self = .radiomaster900Bandit + case 75: self = .me25Ls014Y10Td case 255: self = .privateHw default: self = .UNRECOGNIZED(rawValue) } @@ -510,6 +515,7 @@ public enum HardwareModel: SwiftProtobuf.Enum { case .rak3172: return 72 case .wioE5: return 73 case .radiomaster900Bandit: return 74 + case .me25Ls014Y10Td: return 75 case .privateHw: return 255 case .UNRECOGNIZED(let i): return i } @@ -596,6 +602,7 @@ extension HardwareModel: CaseIterable { .rak3172, .wioE5, .radiomaster900Bandit, + .me25Ls014Y10Td, .privateHw, ] } @@ -1219,16 +1226,28 @@ public struct User { } /// -/// A message used in our Dynamic Source Routing protocol (RFC 4728 based) +/// A message used in a traceroute public struct RouteDiscovery { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. /// - /// The list of nodenums this packet has visited so far + /// The list of nodenums this packet has visited so far to the destination. public var route: [UInt32] = [] + /// + /// The list of SNRs (in dB, scaled by 4) in the route towards the destination. + public var snrTowards: [Int32] = [] + + /// + /// The list of nodenums the packet has visited on the way back from the destination. + public var routeBack: [UInt32] = [] + + /// + /// The list of SNRs (in dB, scaled by 4) in the route back from the destination. + public var snrBack: [Int32] = [] + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -3221,6 +3240,7 @@ extension HardwareModel: SwiftProtobuf._ProtoNameProviding { 72: .same(proto: "RAK3172"), 73: .same(proto: "WIO_E5"), 74: .same(proto: "RADIOMASTER_900_BANDIT"), + 75: .same(proto: "ME25LS01_4Y10TD"), 255: .same(proto: "PRIVATE_HW"), ] } @@ -3600,6 +3620,9 @@ extension RouteDiscovery: SwiftProtobuf.Message, SwiftProtobuf._MessageImplement public static let protoMessageName: String = _protobuf_package + ".RouteDiscovery" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "route"), + 2: .standard(proto: "snr_towards"), + 3: .standard(proto: "route_back"), + 4: .standard(proto: "snr_back"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -3609,6 +3632,9 @@ extension RouteDiscovery: SwiftProtobuf.Message, SwiftProtobuf._MessageImplement // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { case 1: try { try decoder.decodeRepeatedFixed32Field(value: &self.route) }() + case 2: try { try decoder.decodeRepeatedInt32Field(value: &self.snrTowards) }() + case 3: try { try decoder.decodeRepeatedFixed32Field(value: &self.routeBack) }() + case 4: try { try decoder.decodeRepeatedInt32Field(value: &self.snrBack) }() default: break } } @@ -3618,11 +3644,23 @@ extension RouteDiscovery: SwiftProtobuf.Message, SwiftProtobuf._MessageImplement if !self.route.isEmpty { try visitor.visitPackedFixed32Field(value: self.route, fieldNumber: 1) } + if !self.snrTowards.isEmpty { + try visitor.visitPackedInt32Field(value: self.snrTowards, fieldNumber: 2) + } + if !self.routeBack.isEmpty { + try visitor.visitPackedFixed32Field(value: self.routeBack, fieldNumber: 3) + } + if !self.snrBack.isEmpty { + try visitor.visitPackedInt32Field(value: self.snrBack, fieldNumber: 4) + } try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: RouteDiscovery, rhs: RouteDiscovery) -> Bool { if lhs.route != rhs.route {return false} + if lhs.snrTowards != rhs.snrTowards {return false} + if lhs.routeBack != rhs.routeBack {return false} + if lhs.snrBack != rhs.snrBack {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/MeshtasticProtobufs/Sources/meshtastic/module_config.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/module_config.pb.swift index c68ffd83..3186c349 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/module_config.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/module_config.pb.swift @@ -1044,7 +1044,7 @@ public struct ModuleConfig { /// /// Input event origin accepted by the canned message module. - /// Can be e.g. "rotEnc1", "upDownEnc1" or keyword "_any" + /// Can be e.g. "rotEnc1", "upDownEnc1", "scanAndSelect", "cardkb", "serialkb", or keyword "_any" public var allowInputSource: String = String() /// diff --git a/MeshtasticProtobufs/Sources/meshtastic/portnums.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/portnums.pb.swift index c728c961..dd7e036f 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/portnums.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/portnums.pb.swift @@ -167,7 +167,7 @@ public enum PortNum: SwiftProtobuf.Enum { /// /// Provides a traceroute functionality to show the route a packet towards - /// a certain destination would take on the mesh. + /// a certain destination would take on the mesh. Contains a RouteDiscovery message as payload. /// ENCODING: Protobuf case tracerouteApp // = 70 diff --git a/protobufs b/protobufs index 59d035a3..b6237629 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 59d035a37dbeadb28db97acce5f738ba52ee9d3a +Subproject commit b623762940ebdb1887a3b31b86f4d9cdaa7e6ecf