Handle packets from other networks

This commit is contained in:
Garth Vander Houwen 2022-10-28 05:45:44 -07:00
parent 2cb61a3022
commit 45944ba61e
4 changed files with 14 additions and 7 deletions

View file

@ -1105,7 +1105,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
meshPacket.id = UInt32.random(in: UInt32(UInt8.max)..<UInt32.max)
meshPacket.priority = MeshPacket.Priority.reliable
meshPacket.wantAck = true
meshPacket.wantAck = false
meshPacket.hopLimit = 0
var dataMessage = DataMessage()

View file

@ -1254,6 +1254,12 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, context: NSM
do {
let fetchedUsers = try context.fetch(messageUsers) as! [UserEntity]
if fetchedUsers.count <= 1 && fetchedUsers.first(where: { $0.num == packet.from }) == nil {
print("Message from another mesh, unable to manage for now")
return
}
let newMessage = MessageEntity(context: context)
newMessage.messageId = Int64(packet.id)

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21279" systemVersion="21G115" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21279" systemVersion="22A380" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="BluetoothConfigEntity" representedClassName="BluetoothConfigEntity" syncable="YES" codeGenerationType="class">
<attribute name="enabled" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="fixedPin" optional="YES" attributeType="Integer 32" defaultValueString="123456" usesScalarValueType="YES"/>
@ -77,6 +77,7 @@
<attribute name="ackTimestamp" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="admin" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="adminDescription" optional="YES" attributeType="String"/>
<attribute name="channel" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="isEmoji" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="messageId" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="messagePayload" optional="YES" attributeType="String" defaultValueString=""/>

View file

@ -26,10 +26,10 @@ struct PositionLog: View {
//Add a table for mac and ipad
VStack {
Table(node.positions!.reversed() as! [PositionEntity]) {
TableColumn("SeqNo") { position in
TableColumn("Seq No") { position in
Text(String(position.seqNo))
}
.width(75)
//.width(75)
TableColumn("Latitude") { position in
Text(String(format: "%.6f", position.latitude ?? 0))
}
@ -39,15 +39,15 @@ struct PositionLog: View {
TableColumn("Altitude") { position in
Text(String(position.altitude))
}
.width(75)
//.width(75)
TableColumn("Sats") { position in
Text(String(position.satsInView))
}
.width(75)
//.width(75)
TableColumn("Speed") { position in
Text(String(position.speed))
}
.width(75)
//.width(75)
TableColumn("Heading") { position in
Text(String(position.heading))
}