fix autobug when changing channels

pull/266/head
Kevin Hester 2021-03-23 13:40:03 +08:00
rodzic dd9a2b99d7
commit 12ea70174e
1 zmienionych plików z 15 dodań i 6 usunięć

Wyświetl plik

@ -549,7 +549,7 @@ class MeshService : Service(), Logging {
setChannel(it)
}
channels = asChannels.toTypedArray()
channels = fixupChannelList(asChannels).toTypedArray()
}
/// Generate a new mesh packet builder with our node as the sender, and the specified node num
@ -1305,11 +1305,20 @@ class MeshService : Service(), Logging {
radioConfig = null
// prefill the channel array with null channels
channels = Array(myInfo.maxChannels) {
val b = ChannelProtos.Channel.newBuilder()
b.index = it
b.build()
}
channels = fixupChannelList(listOf<ChannelProtos.Channel>()).toTypedArray()
}
/// scan the channel list and make sure it has one PRIMARY channel and is maxChannels long
private fun fixupChannelList(lIn: List<ChannelProtos.Channel>): List<ChannelProtos.Channel> {
val mi = myNodeInfo
var l = lIn
if (mi != null)
while (l.size < mi.maxChannels) {
val b = ChannelProtos.Channel.newBuilder()
b.index = l.size
l += b.build()
}
return l
}