fix isESP32 logic

pull/443/head
andrekir 2022-06-10 20:22:06 -03:00
rodzic 4784e8d14b
commit d939f9784b
2 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -184,8 +184,11 @@ class UIViewModel @Inject constructor(
meshService?.region = value.number
}
// We consider hasWifi = ESP32
var isESP32: Boolean = _deviceConfig.value?.hasWifi() == true
fun isESP32(): Boolean {
// List of 'HardwareModel' enum values for ESP32 devices from mesh.proto
val hwModelESP32 = listOf(1, 2, 3, 4, 5, 6, 8, 10, 11, 32, 35, 39, 40, 41, 43, 44)
return hwModelESP32.contains(nodeDB.ourNodeInfo?.user?.hwModel?.number)
}
/// hardware info about our local device (can be null)
private val _myNodeInfo = MutableLiveData<MyNodeInfo?>()

Wyświetl plik

@ -43,8 +43,8 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
binding.lsSleepEditText.setText(model.lsSleepSecs.toString())
binding.positionBroadcastPeriodView.isEnabled = !model.gpsDisabled
binding.positionBroadcastSwitch.isChecked = !model.gpsDisabled
binding.lsSleepView.isEnabled = model.isPowerSaving ?: false && model.isESP32
binding.lsSleepSwitch.isChecked = model.isPowerSaving ?: false && model.isESP32
binding.lsSleepView.isEnabled = model.isPowerSaving ?: false && model.isESP32()
binding.lsSleepSwitch.isChecked = model.isPowerSaving ?: false && model.isESP32()
}
model.connectionState.observe(viewLifecycleOwner) { connectionState ->
@ -52,7 +52,7 @@ class AdvancedSettingsFragment : ScreenFragment("Advanced Settings"), Logging {
binding.positionBroadcastPeriodView.isEnabled = connected && !model.gpsDisabled
binding.lsSleepView.isEnabled = connected && model.isPowerSaving ?: false
binding.positionBroadcastSwitch.isEnabled = connected
binding.lsSleepSwitch.isEnabled = connected && model.isESP32
binding.lsSleepSwitch.isEnabled = connected && model.isESP32()
binding.shutdownButton.isEnabled = connected
binding.rebootButton.isEnabled = connected
}