MqttTopicFinderViewModel

class MqttTopicFinderViewModel(reverseGeocoder: ReverseGeocoder, locationService: LocationService, mqttRootsRepository: MqttRootsRepository) : ViewModel(source)

Samples the broker for the root topics in use and builds the suggestions for where the user is. The radio's own fix comes first and the phone's location is the fallback, read only when permission is already granted.

Constructors

Link copied to clipboard
constructor(reverseGeocoder: ReverseGeocoder, locationService: LocationService, mqttRootsRepository: MqttRootsRepository)

Types

Link copied to clipboard
data class UiState(val regionName: String? = null, val place: GeocodedPlace? = null, val location: LatLon? = null, val locating: Boolean = false, val geocodeFailed: Boolean = false, val sample: MqttTopicSampler.State = MqttTopicSampler.State(), val directory: MqttRootDirectory = MqttRootDirectory.EMPTY)

Properties

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
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
fun open(session: Int, config: ModuleConfig.MQTTConfig, regionName: String?, radioPosition: LatLon?)

Starts a sample once per opening of the sheet: a recomposition or rotation repeats session and keeps the running sample, a reopened sheet passes a new one.

Link copied to clipboard
fun start(config: ModuleConfig.MQTTConfig, regionName: String?, radioPosition: LatLon?)

Starts a fresh sample; a null region shows nothing but the custom field, as there is no default root to probe.

Link copied to clipboard
fun stop()

Ends the sample and keeps what was heard.