mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Node num details
This commit is contained in:
parent
fcbdaaf01f
commit
5eea9ea87c
7 changed files with 14 additions and 14 deletions
|
|
@ -919,6 +919,7 @@
|
|||
DDDB444529F8A96500EE2349 /* Character.swift */,
|
||||
DDDB444929F8AA3A00EE2349 /* CLLocationCoordinate2D.swift */,
|
||||
DDDB444B29F8AAA600EE2349 /* Color.swift */,
|
||||
25C49D8F2C471AEA0024FBD1 /* Constants.swift */,
|
||||
DDDB445329F8AD1600EE2349 /* Data.swift */,
|
||||
DDDB445129F8ACF900EE2349 /* Date.swift */,
|
||||
DDDB444129F8A88700EE2349 /* Double.swift */,
|
||||
|
|
@ -934,7 +935,6 @@
|
|||
DDD5BB172C2F9C36007E03CA /* OSLogEntryLog.swift */,
|
||||
DDF45C362BC46A5A005ED5F2 /* TimeZone.swift */,
|
||||
DDD5BB0C2C285F00007E03CA /* Logger.swift */,
|
||||
25C49D8F2C471AEA0024FBD1 /* Constants.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import Foundation
|
||||
|
||||
enum Constants {
|
||||
/// `UInt32.max` is used to identify messages that are being
|
||||
/// `UInt32.max` or FFFF,FFFF in hex is used to identify messages that are being
|
||||
/// sent to a channel and are not a DM to an individual user. This is used
|
||||
/// in the `to` field of some mesh packets.
|
||||
static let emptyNodeNum = UInt32.max
|
||||
|
||||
/// TODO: document me
|
||||
static let minimumNodeNum = Int16.max
|
||||
static let maximumNodeNum = UInt32.max
|
||||
/// Based on the NUM_RESERVED from the firmware.
|
||||
/// https://github.com/meshtastic/firmware/blob/46d7b82ac1a4292ba52ca690e1a433d3a501a9e5/src/mesh/NodeDB.cpp#L522
|
||||
static let minimumNodeNum = 4
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1009,7 +1009,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
if toUserNum > 0 {
|
||||
meshPacket.to = UInt32(toUserNum)
|
||||
} else {
|
||||
meshPacket.to = Constants.emptyNodeNum
|
||||
meshPacket.to = Constants.maximumNodeNum
|
||||
}
|
||||
meshPacket.channel = UInt32(channel)
|
||||
meshPacket.from = UInt32(fromUserNum)
|
||||
|
|
@ -1057,7 +1057,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
var success = false
|
||||
let fromNodeNum = UInt32(connectedPeripheral.num)
|
||||
var meshPacket = MeshPacket()
|
||||
meshPacket.to = Constants.emptyNodeNum
|
||||
meshPacket.to = Constants.maximumNodeNum
|
||||
meshPacket.from = fromNodeNum
|
||||
meshPacket.wantAck = true
|
||||
var dataMessage = DataMessage()
|
||||
|
|
|
|||
|
|
@ -799,7 +799,7 @@ func textMessageAppPacket(packet: MeshPacket, wantRangeTestPackets: Bool, connec
|
|||
newMessage.replyID = Int64(packet.decoded.replyID)
|
||||
}
|
||||
|
||||
if fetchedUsers.first(where: { $0.num == packet.to }) != nil && packet.to != Constants.emptyNodeNum {
|
||||
if fetchedUsers.first(where: { $0.num == packet.to }) != nil && packet.to != Constants.maximumNodeNum {
|
||||
if !storeForwardBroadcast {
|
||||
newMessage.toUser = fetchedUsers.first(where: { $0.num == packet.to })
|
||||
}
|
||||
|
|
@ -812,7 +812,7 @@ func textMessageAppPacket(packet: MeshPacket, wantRangeTestPackets: Bool, connec
|
|||
}
|
||||
newMessage.messagePayload = messageText
|
||||
newMessage.messagePayloadMarkdown = generateMessageMarkdown(message: messageText!)
|
||||
if packet.to != Constants.emptyNodeNum && newMessage.fromUser != nil {
|
||||
if packet.to != Constants.maximumNodeNum && newMessage.fromUser != nil {
|
||||
newMessage.fromUser?.lastMessage = Date()
|
||||
}
|
||||
var messageSaved = false
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
|
|||
newNode.rssi = packet.rxRssi
|
||||
newNode.viaMqtt = packet.viaMqtt
|
||||
|
||||
if packet.to == Constants.emptyNodeNum || packet.to == UserDefaults.preferredPeripheralNum {
|
||||
if packet.to == Constants.maximumNodeNum || packet.to == UserDefaults.preferredPeripheralNum {
|
||||
newNode.channel = Int32(packet.channel)
|
||||
}
|
||||
if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) {
|
||||
|
|
@ -231,7 +231,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
|
|||
fetchedNode[0].snr = packet.rxSnr
|
||||
fetchedNode[0].rssi = packet.rxRssi
|
||||
fetchedNode[0].viaMqtt = packet.viaMqtt
|
||||
if packet.to == Constants.emptyNodeNum || packet.to == UserDefaults.preferredPeripheralNum {
|
||||
if packet.to == Constants.maximumNodeNum || packet.to == UserDefaults.preferredPeripheralNum {
|
||||
fetchedNode[0].channel = Int32(packet.channel)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ private extension MessageDestination {
|
|||
var positionDestNum: Int64 {
|
||||
switch self {
|
||||
case let .user(user): return user.num
|
||||
case .channel: return Int64(Constants.emptyNodeNum)
|
||||
case .channel: return Int64(Constants.maximumNodeNum)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 0fd5023a0aa67eefdf2292a624e8fbbda4489a6c
|
||||
Subproject commit 10494bf328ac051fc4add9ddeb677eebf337b531
|
||||
Loading…
Add table
Add a link
Reference in a new issue