mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: skip nodeinfo upsert when we recieve defaults from the node (#3796)
This commit is contained in:
parent
5d61e78f37
commit
552097888f
1 changed files with 24 additions and 7 deletions
|
|
@ -1719,13 +1719,30 @@ class MeshService : Service() {
|
|||
// Just replace/add any entry
|
||||
updateNodeInfo(info.num) {
|
||||
if (info.hasUser()) {
|
||||
it.user =
|
||||
info.user.copy {
|
||||
if (isLicensed) clearPublicKey()
|
||||
if (info.viaMqtt) longName = "$longName (MQTT)"
|
||||
}
|
||||
it.longName = it.user.longName
|
||||
it.shortName = it.user.shortName
|
||||
// Check if this is a default/unknown user from firmware (node was evicted and re-created)
|
||||
val isDefaultName = info.user.longName.matches(Regex("^Meshtastic [0-9a-fA-F]{4}$"))
|
||||
val isDefaultHwModel = info.user.hwModel == MeshProtos.HardwareModel.UNSET
|
||||
val hasExistingUser = it.user.id.isNotEmpty() && it.user.hwModel != MeshProtos.HardwareModel.UNSET
|
||||
|
||||
// If firmware sends a default user (evicted node), preserve our existing user data
|
||||
val shouldPreserveExisting = hasExistingUser && isDefaultName && isDefaultHwModel
|
||||
|
||||
if (shouldPreserveExisting) {
|
||||
// Firmware sent us a placeholder - keep all our existing user data
|
||||
Timber.d(
|
||||
"Preserving existing user data for node ${info.num}: " +
|
||||
"kept='${it.user.longName}' (hwModel=${it.user.hwModel}), " +
|
||||
"skipped default='${info.user.longName}' (hwModel=UNSET)",
|
||||
)
|
||||
} else {
|
||||
it.user =
|
||||
info.user.copy {
|
||||
if (isLicensed) clearPublicKey()
|
||||
if (info.viaMqtt) longName = "$longName (MQTT)"
|
||||
}
|
||||
it.longName = it.user.longName
|
||||
it.shortName = it.user.shortName
|
||||
}
|
||||
}
|
||||
|
||||
if (info.hasPosition()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue