Update Protobufs

This commit is contained in:
Garth Vander Houwen 2022-06-03 18:13:31 -07:00
parent 59fe6f9ec5
commit e9e39e3c0c
2 changed files with 27 additions and 4 deletions

View file

@ -82,7 +82,6 @@ func myInfoPacket (myInfo: MyNodeInfo, meshLogging: Bool, context: NSManagedObje
}
return nil
}
func nodeInfoPacket (nodeInfo: NodeInfo, meshLogging: Bool, context: NSManagedObjectContext) -> NodeInfoEntity? {
@ -282,7 +281,24 @@ func nodeInfoAppPacket (packet: MeshPacket, meshLogging: Bool, context: NSManage
fetchedNode[0].num = Int64(packet.from)
fetchedNode[0].lastHeard = Date(timeIntervalSince1970: TimeInterval(Int64(packet.rxTime)))
fetchedNode[0].snr = packet.rxSnr
if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) {
if nodeInfoMessage.hasDeviceMetrics {
let telemetry = TelemetryEntity(context: context)
telemetry.batteryLevel = Int32(nodeInfoMessage.deviceMetrics.batteryLevel)
telemetry.voltage = nodeInfoMessage.deviceMetrics.voltage
telemetry.channelUtilization = nodeInfoMessage.deviceMetrics.channelUtilization
telemetry.airUtilTx = nodeInfoMessage.deviceMetrics.airUtilTx
var newTelemetries = [TelemetryEntity]()
newTelemetries.append(telemetry)
fetchedNode[0].telemetries? = NSOrderedSet(array: newTelemetries)
}
}
} else {
return
}
@ -394,8 +410,7 @@ func routingPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedObj
case Routing.Error.notAuthorized:
errorExplanation = "The application layer service on the remote node received your request, but considered your request not authorized (i.e you did not send the request on the required bound channel)"
fallthrough
default:
break
default: ()
}
if meshLogging { MeshLogger.log("🕸️ ROUTING PACKET received for RequestID: \(packet.decoded.requestID) Error: \(errorExplanation)") }

View file

@ -77,6 +77,10 @@ enum PortNum: SwiftProtobuf.Enum {
/// Compressed TEXT_MESSAGE payloads.
case textMessageCompressedApp // = 7
///
/// Waypoint payloads.
case waypointApp // = 8
///
/// Provides a 'ping' service that replies to any packet it receives.
/// Also serves as a small example module.
@ -143,6 +147,7 @@ enum PortNum: SwiftProtobuf.Enum {
case 5: self = .routingApp
case 6: self = .adminApp
case 7: self = .textMessageCompressedApp
case 8: self = .waypointApp
case 32: self = .replyApp
case 33: self = .ipTunnelApp
case 64: self = .serialApp
@ -167,6 +172,7 @@ enum PortNum: SwiftProtobuf.Enum {
case .routingApp: return 5
case .adminApp: return 6
case .textMessageCompressedApp: return 7
case .waypointApp: return 8
case .replyApp: return 32
case .ipTunnelApp: return 33
case .serialApp: return 64
@ -196,6 +202,7 @@ extension PortNum: CaseIterable {
.routingApp,
.adminApp,
.textMessageCompressedApp,
.waypointApp,
.replyApp,
.ipTunnelApp,
.serialApp,
@ -227,6 +234,7 @@ extension PortNum: SwiftProtobuf._ProtoNameProviding {
5: .same(proto: "ROUTING_APP"),
6: .same(proto: "ADMIN_APP"),
7: .same(proto: "TEXT_MESSAGE_COMPRESSED_APP"),
8: .same(proto: "WAYPOINT_APP"),
32: .same(proto: "REPLY_APP"),
33: .same(proto: "IP_TUNNEL_APP"),
64: .same(proto: "SERIAL_APP"),