fix new hwmodel based on testing with the simulator

pull/261/head
Kevin Hester 2021-03-15 10:31:44 +08:00
rodzic 483bd878ab
commit fa17c4efe1
3 zmienionych plików z 14 dodań i 14 usunięć

Wyświetl plik

@ -375,10 +375,10 @@ class MeshService : Service(), Logging {
}
}
private fun installNewNodeDB(newMyNodeInfo: MyNodeInfo, nodes: Array<NodeInfo>) {
private fun installNewNodeDB(ni: MyNodeInfo, nodes: Array<NodeInfo>) {
discardNodeDB() // Get rid of any old state
myNodeInfo = newMyNodeInfo
myNodeInfo = ni
// put our node array into our two different map representations
nodeDBbyNodeNum.putAll(nodes.map { Pair(it.num, it) })
@ -1228,15 +1228,13 @@ class MeshService : Service(), Logging {
val isBluetoothInterface = a != null && a.startsWith("x")
var hwModelStr = myInfo.hwModelDeprecated
if(hwModelStr.isEmpty()) {
try {
val ni = toNodeInfo(myNodeNum)
val asStr = ni.user?.hwModelString
if (asStr != null)
hwModelStr = asStr
} catch(_: NodeNumNotFoundException) {
warn("Can't find local node to get hardware model")
}
if (hwModelStr.isEmpty()) {
val nodeNum =
myInfo.myNodeNum // Note: can't use the normal property because myNodeInfo not yet setup
val ni = nodeDBbyNodeNum[nodeNum] // can't use toNodeInfo because too early
val asStr = ni?.user?.hwModelString
if (asStr != null)
hwModelStr = asStr
}
val mi = with(myInfo) {
MyNodeInfo(
@ -1397,7 +1395,7 @@ class MeshService : Service(), Logging {
else {
discardNodeDB()
debug("Installing new node DB")
myNodeInfo = newMyNodeInfo
myNodeInfo = newMyNodeInfo// Install myNodeInfo as current
newNodes.forEach(::installNodeInfo)
newNodes.clear() // Just to save RAM ;-)
@ -1405,6 +1403,8 @@ class MeshService : Service(), Logging {
haveNodeDB = true // we now have nodes from real hardware
regenMyNodeInfo() // we have a node db now, so can possibly find a better hwmodel
myNodeInfo = newMyNodeInfo // we might have just updated myNodeInfo
sendAnalytics()
requestRadioConfig()

Wyświetl plik

@ -162,7 +162,7 @@ class MockInterface(private val service: RadioInterfaceService) : Logging, IRadi
myInfo = MeshProtos.MyNodeInfo.newBuilder().apply {
myNodeNum = MY_NODE
messageTimeoutMsec = 5 * 60 * 1000
firmwareVersion = service.getString(R.string.cur_firmware_version)
firmwareVersion = "1.2.8" // Pretend to be running an older 1.2 version
numBands = 13
maxChannels = 8
}.build()

Wyświetl plik

@ -610,7 +610,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
statusText.text = getString(R.string.must_set_region)
connected == MeshService.ConnectionState.CONNECTED -> {
val fwStr = info?.firmwareString ?: ""
val fwStr = info?.firmwareString ?: "unknown"
statusText.text = getString(R.string.connected_to).format(fwStr)
}
connected == MeshService.ConnectionState.DISCONNECTED ->