kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
* Update MeshService.kt to store the channel for received packets. The channel for received packets is now stored, allowing for better tracking and management. * Update node info creation to include channel data - Updates `getOrCreateNodeInfo` to accept a channel parameter and to save the channel to the node info during instantiation of a new/unknown node. - Updates `updateNodeInfo` to accept a channel parameter and pass it to the updated function. - Updates call to `updateNodeInfo` in `handleReceivedData` to pass the packet channel data to it.pull/1687/head
rodzic
8e5accd518
commit
f3ba084d5b
|
@ -473,7 +473,7 @@ class MeshService : Service(), Logging {
|
|||
}
|
||||
|
||||
// given a nodeNum, return a db entry - creating if necessary
|
||||
private fun getOrCreateNodeInfo(n: Int) = nodeDBbyNodeNum.getOrPut(n) {
|
||||
private fun getOrCreateNodeInfo(n: Int, channel: Int = 0) = nodeDBbyNodeNum.getOrPut(n) {
|
||||
val userId = DataPacket.nodeNumToDefaultId(n)
|
||||
val defaultUser = user {
|
||||
id = userId
|
||||
|
@ -486,6 +486,7 @@ class MeshService : Service(), Logging {
|
|||
num = n,
|
||||
user = defaultUser,
|
||||
longName = defaultUser.longName,
|
||||
channel = channel,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -527,9 +528,10 @@ class MeshService : Service(), Logging {
|
|||
private inline fun updateNodeInfo(
|
||||
nodeNum: Int,
|
||||
withBroadcast: Boolean = true,
|
||||
channel: Int = 0,
|
||||
crossinline updateFn: (NodeEntity) -> Unit,
|
||||
) {
|
||||
val info = getOrCreateNodeInfo(nodeNum)
|
||||
val info = getOrCreateNodeInfo(nodeNum, channel)
|
||||
updateFn(info)
|
||||
|
||||
if (info.user.id.isNotEmpty() && haveNodeDB) {
|
||||
|
@ -1174,7 +1176,7 @@ class MeshService : Service(), Logging {
|
|||
|
||||
// Do not generate redundant broadcasts of node change for this bookkeeping updateNodeInfo call
|
||||
// because apps really only care about important updates of node state - which handledReceivedData will give them
|
||||
updateNodeInfo(fromNum, withBroadcast = false) {
|
||||
updateNodeInfo(fromNum, withBroadcast = false, channel = packet.channel) {
|
||||
// Update our last seen based on any valid timestamps. If the device didn't provide a timestamp make one
|
||||
it.lastHeard = packet.rxTime
|
||||
it.snr = packet.rxSnr
|
||||
|
|
Ładowanie…
Reference in New Issue