kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Removed checking for device name to contain MAC address. We still verify it starts with Mesh
rodzic
bd74d64be0
commit
b87ac0a1af
|
@ -194,57 +194,27 @@ class BTScanModel(app: Application) : AndroidViewModel(app), Logging {
|
||||||
val oldDevs = devices.value!!
|
val oldDevs = devices.value!!
|
||||||
val oldEntry = oldDevs[fullAddr]
|
val oldEntry = oldDevs[fullAddr]
|
||||||
if (oldEntry == null || oldEntry.bonded != isBonded) { // Don't spam the GUI with endless updates for non changing nodes
|
if (oldEntry == null || oldEntry.bonded != isBonded) { // Don't spam the GUI with endless updates for non changing nodes
|
||||||
|
val entry = DeviceListEntry(
|
||||||
val skipBogus = try {
|
result.device.name
|
||||||
// Note Soyes XS has a buggy BLE scan implementation and returns devices we didn't ask for. So we check to see if the
|
?: "unnamed-$addr", // autobug: some devices might not have a name, if someone is running really old device code?
|
||||||
// last two chars of the name matches the last two of the address - if not we skip it
|
fullAddr,
|
||||||
|
isBonded
|
||||||
// Note: the address is always two more than the hex string we show in the name
|
)
|
||||||
|
// If nothing was selected, by default select the first valid thing we see
|
||||||
// nasty parsing of a string that ends with ab:45 as four hex digits
|
val activity: MainActivity? = try {
|
||||||
val lastAddr = (addr.substring(
|
GeeksvilleApplication.currentActivity as MainActivity? // Can be null if app is shutting down
|
||||||
addr.length - 5,
|
} catch (_: ClassCastException) {
|
||||||
addr.length - 3
|
// Buggy "Z812" phones apparently have the wrong class type for this
|
||||||
) + addr.substring(addr.length - 2)).toInt(16)
|
errormsg("Unexpected class for main activity")
|
||||||
|
null
|
||||||
val lastName =
|
|
||||||
result.device.name.substring(result.device.name.length - 4).toInt(16)
|
|
||||||
|
|
||||||
// ESP32 macaddr are two higher than the reported device name
|
|
||||||
// NRF52 macaddrs match the portion used in the string
|
|
||||||
// either would be acceptable
|
|
||||||
(lastAddr - 2) != lastName && lastAddr != lastName
|
|
||||||
} catch (ex: Throwable) {
|
|
||||||
false // If we fail parsing anything, don't do this nasty hack
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipBogus)
|
if (selectedAddress == null && entry.bonded && activity != null)
|
||||||
errormsg("Skipping bogus BLE entry $result")
|
changeScanSelection(
|
||||||
else {
|
activity,
|
||||||
val entry = DeviceListEntry(
|
fullAddr
|
||||||
result.device.name
|
|
||||||
?: "unnamed-$addr", // autobug: some devices might not have a name, if someone is running really old device code?
|
|
||||||
fullAddr,
|
|
||||||
isBonded
|
|
||||||
)
|
)
|
||||||
debug("onScanResult ${entry}")
|
addDevice(entry) // Add/replace entry
|
||||||
|
|
||||||
// If nothing was selected, by default select the first valid thing we see
|
|
||||||
val activity: MainActivity? = try {
|
|
||||||
GeeksvilleApplication.currentActivity as MainActivity? // Can be null if app is shutting down
|
|
||||||
} catch (_: ClassCastException) {
|
|
||||||
// Buggy "Z812" phones apparently have the wrong class type for this
|
|
||||||
errormsg("Unexpected class for main activity")
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedAddress == null && entry.bonded && activity != null)
|
|
||||||
changeScanSelection(
|
|
||||||
activity,
|
|
||||||
fullAddr
|
|
||||||
)
|
|
||||||
addDevice(entry) // Add/replace entry
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue