ChannelViewModel

class ChannelViewModel(radioController: RadioController, radioConfigRepository: RadioConfigRepository, analytics: PlatformAnalytics, snackbarManager: SnackbarManager) : ViewModel(source)

Constructors

Link copied to clipboard
constructor(radioController: RadioController, radioConfigRepository: RadioConfigRepository, analytics: PlatformAnalytics, snackbarManager: SnackbarManager)

Properties

Link copied to clipboard
val channels: StateFlow<ChannelSet>
Link copied to clipboard
val connectionState: StateFlow<ConnectionState>
Link copied to clipboard
Link copied to clipboard
val localConfig: StateFlow<LocalConfig>
Link copied to clipboard
var region: Config.LoRaConfig.RegionCode
Link copied to clipboard
val requestChannelSet: StateFlow<ChannelSet?>
Link copied to clipboard

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
fun requestChannelUrl(url: String, onError: () -> Unit): Result<Unit>

Parse a channel URL string and store the resulting ChannelSet.

Link copied to clipboard
fun resetToDefaults(regionPresetMap: LoRaRegionPresetMap?)

Replaces the channels with the default one. The LoRa config is read from the repository here: localConfig holds its empty initial value unless something is collecting it, and the reset must keep the device's own settings. The default channel takes the region's first-setup preset (e.g. US -> LongTurbo) so its derived name, hash and frequency match what a freshly set-up node in that region would use.

Link copied to clipboard
fun setChannels(channelSet: ChannelSet)

Set the radio config (also updates our saved copy in preferences). A failure is reported with a snackbar that offers to retry the same write.

Link copied to clipboard
fun setConfig(config: Config)
Link copied to clipboard