Merge pull request #500 from meshtastic/channel-config

install channels from wantConfig
pull/505/head
Andre K 2022-10-16 19:27:23 -03:00 zatwierdzone przez GitHub
commit 69e4a175bf
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 22 dodań i 28 usunięć

Wyświetl plik

@ -42,7 +42,7 @@ class ChannelSetRepository @Inject constructor(
suspend fun addSettings(channel: ChannelProtos.Channel) {
channelSetStore.updateData { preference ->
preference.toBuilder().addSettings(channel.index, channel.settings).build()
preference.toBuilder().addSettings(channel.settings).build()
}
}

Wyświetl plik

@ -712,28 +712,8 @@ class MeshService : Service(), Logging {
val ch = a.getChannelResponse
debug("Admin: Received channel ${ch.index}")
val packetToSave = MeshLog(
UUID.randomUUID().toString(),
"Channel",
System.currentTimeMillis(),
ch.toString()
)
insertMeshLog(packetToSave)
if (ch.index + 1 < mi.maxChannels) {
// Stop once we get to the first disabled entry
if (/* ch.hasSettings() || */ ch.role != ChannelProtos.Channel.Role.DISABLED) {
// Not done yet, add new entries and request next channel
addChannelSettings(ch)
requestChannel(ch.index + 1)
} else {
debug("We've received the last channel, allowing rest of app to start...")
onHasSettings()
}
} else {
debug("Received max channels, starting app")
onHasSettings()
handleChannel(ch)
}
}
}
@ -1110,6 +1090,7 @@ class MeshService : Service(), Logging {
MeshProtos.FromRadio.CONFIG_COMPLETE_ID_FIELD_NUMBER -> handleConfigComplete(proto.configCompleteId)
MeshProtos.FromRadio.MY_INFO_FIELD_NUMBER -> handleMyInfo(proto.myInfo)
MeshProtos.FromRadio.NODE_INFO_FIELD_NUMBER -> handleNodeInfo(proto.nodeInfo)
MeshProtos.FromRadio.CHANNEL_FIELD_NUMBER -> handleChannel(proto.channel)
MeshProtos.FromRadio.CONFIG_FIELD_NUMBER -> handleDeviceConfig(proto.config)
MeshProtos.FromRadio.MODULECONFIG_FIELD_NUMBER -> handleModuleConfig(proto.moduleConfig)
else -> errormsg("Unexpected FromRadio variant")
@ -1152,6 +1133,18 @@ class MeshService : Service(), Logging {
// setModuleConfig(config)
}
private fun handleChannel(ch: ChannelProtos.Channel) {
debug("Received channel ${ch.index}")
val packetToSave = MeshLog(
UUID.randomUUID().toString(),
"Channel",
System.currentTimeMillis(),
ch.toString()
)
insertMeshLog(packetToSave)
if (ch.role != ChannelProtos.Channel.Role.DISABLED) addChannelSettings(ch)
}
/**
* Convert a protobuf NodeInfo into our model objects and update our node DB
*/
@ -1328,8 +1321,8 @@ class MeshService : Service(), Logging {
if (deviceVersion < minDeviceVersion || appVersion < minAppVersion) {
info("Device firmware or app is too old, faking config so firmware update can occur")
clearLocalConfig()
onHasSettings()
} else requestChannel(0) // Now start reading channels
}
onHasSettings()
}
} else
warn("Ignoring stale config complete")

Wyświetl plik

@ -299,14 +299,15 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
model.localConfig.asLiveData().observe(viewLifecycleOwner) {
if (!model.isConnected()) {
val configCount = it.allFields.size
binding.scanStatusText.text = "Device config ($configCount / 7)"
if (configCount > 0)
binding.scanStatusText.text = "Device config ($configCount / 7)"
} else updateNodeInfo()
}
model.channels.asLiveData().observe(viewLifecycleOwner) {
if (!model.isConnected()) {
val channelCount = it.protobuf.settingsCount
if (channelCount > 0) binding.scanStatusText.text = "Channels ($channelCount / 8)"
if (!model.isConnected()) it.protobuf.let { ch ->
if (!ch.hasLoraConfig() && ch.settingsCount > 0)
binding.scanStatusText.text = "Channels (${ch.settingsCount} / 8)"
}
}