reset channels no longer in use

pull/500/head
andrekir 2022-10-16 12:40:05 -03:00
rodzic d29c86ee74
commit a3cc422afc
1 zmienionych plików z 10 dodań i 9 usunięć

Wyświetl plik

@ -44,8 +44,9 @@ import java.io.BufferedWriter
import java.io.FileNotFoundException
import java.io.FileWriter
import java.text.SimpleDateFormat
import java.util.*
import java.util.Locale
import javax.inject.Inject
import kotlin.math.max
import kotlin.math.roundToInt
/// Given a human name, strip out the first letter of the first three words and return that as the initials for
@ -312,17 +313,17 @@ class UIViewModel @Inject constructor(
private var _channelSet: AppOnlyProtos.ChannelSet
get() = channels.value.protobuf
set(value) {
val asChannels = value.settingsList.mapIndexed { i, c ->
(0 until max(_channelSet.settingsCount, value.settingsCount)).map { i ->
channel {
role = if (i == 0) ChannelProtos.Channel.Role.PRIMARY
else ChannelProtos.Channel.Role.SECONDARY
role = when (i) {
0 -> ChannelProtos.Channel.Role.PRIMARY
in 1 until value.settingsCount -> ChannelProtos.Channel.Role.SECONDARY
else -> ChannelProtos.Channel.Role.DISABLED
}
index = i
settings = c
settings = value.settingsList.getOrNull(i) ?: channelSettings { }
}
}
debug("Sending channels to device")
asChannels.forEach {
}.forEach {
meshService?.setChannel(it.toByteArray())
}