2025-09-25 17:22:14 -04:00
|
|
|
/*
|
2026-01-02 14:06:05 -06:00
|
|
|
* Copyright (c) 2025-2026 Meshtastic LLC
|
2025-09-25 17:22:14 -04:00
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
package com.geeksville.mesh.service
|
|
|
|
|
|
2025-11-17 15:15:22 -06:00
|
|
|
import kotlinx.coroutines.flow.MutableStateFlow
|
|
|
|
|
import kotlinx.coroutines.flow.asStateFlow
|
2026-03-02 12:15:33 -06:00
|
|
|
import org.meshtastic.core.model.ConnectionState
|
2025-09-25 17:22:14 -04:00
|
|
|
import javax.inject.Inject
|
|
|
|
|
import javax.inject.Singleton
|
|
|
|
|
|
|
|
|
|
@Singleton
|
2026-01-02 11:13:38 -06:00
|
|
|
class ConnectionStateHandler @Inject constructor() {
|
2025-11-17 15:15:22 -06:00
|
|
|
private val _connectionState = MutableStateFlow<ConnectionState>(ConnectionState.Disconnected)
|
|
|
|
|
val connectionState = _connectionState.asStateFlow()
|
2025-09-25 17:22:14 -04:00
|
|
|
|
|
|
|
|
fun setState(state: ConnectionState) {
|
2025-11-17 15:15:22 -06:00
|
|
|
_connectionState.value = state
|
2025-09-25 17:22:14 -04:00
|
|
|
}
|
|
|
|
|
}
|