Meshtastic-Android/app/src/main/java/com/geeksville/mesh/model/ChannelOption.kt

30 lines
1.3 KiB
Kotlin
Raw Normal View History

2021-02-27 13:43:55 +08:00
package com.geeksville.mesh.model
import com.geeksville.mesh.ChannelProtos
import com.geeksville.mesh.R
2021-03-29 20:33:06 +08:00
enum class ChannelOption(
val modemConfig: ChannelProtos.ChannelSettings.ModemConfig,
val configRes: Int,
val minBroadcastPeriodSecs: Int
) {
SHORT_FAST(ChannelProtos.ChannelSettings.ModemConfig.ShortFast,R.string.modem_config_short, 30),
SHORT_SLOW(ChannelProtos.ChannelSettings.ModemConfig.ShortSlow, R.string.modem_config_slow_short, 30),
MED_FAST(ChannelProtos.ChannelSettings.ModemConfig.MidFast,R.string.modem_config_medium, 60),
MED_SLOW(ChannelProtos.ChannelSettings.ModemConfig.MidSlow,R.string.modem_config_slow_medium, 60),
LONG_FAST(ChannelProtos.ChannelSettings.ModemConfig.LongFast, R.string.modem_config_long, 240),
LONG_SLOW(ChannelProtos.ChannelSettings.ModemConfig.LongSlow, R.string.modem_config_slow_long, 375),
VERY_LONG(ChannelProtos.ChannelSettings.ModemConfig.VLongSlow, R.string.modem_config_very_long, 375);
2021-02-27 13:43:55 +08:00
companion object {
fun fromConfig(modemConfig: ChannelProtos.ChannelSettings.ModemConfig?): ChannelOption? {
for (option in values()) {
if (option.modemConfig == modemConfig)
return option
}
return null
}
2021-03-29 20:33:06 +08:00
2021-02-27 13:43:55 +08:00
val defaultMinBroadcastPeriod = VERY_LONG.minBroadcastPeriodSecs
}
2020-06-14 00:11:08 -04:00
}