varroa: strip Wigle integration (deferred, not in base stack)
This commit is contained in:
parent
44473990c1
commit
672fbbe324
1 changed files with 0 additions and 66 deletions
|
|
@ -9,8 +9,6 @@ import com.adamaps.varroa.data.ApiResult
|
||||||
import com.adamaps.varroa.data.SettingsDataStore
|
import com.adamaps.varroa.data.SettingsDataStore
|
||||||
import com.adamaps.varroa.data.SshStatus
|
import com.adamaps.varroa.data.SshStatus
|
||||||
import com.adamaps.varroa.data.VarroaSettings
|
import com.adamaps.varroa.data.VarroaSettings
|
||||||
import com.adamaps.varroa.data.WigleStatus
|
|
||||||
import com.adamaps.varroa.data.WigleStats
|
|
||||||
import com.adamaps.varroa.data.WifiStatus
|
import com.adamaps.varroa.data.WifiStatus
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
|
|
@ -66,15 +64,6 @@ class SettingsViewModel(app: Application) : AndroidViewModel(app) {
|
||||||
private val _wifiConnectResult = MutableStateFlow<String?>(null)
|
private val _wifiConnectResult = MutableStateFlow<String?>(null)
|
||||||
val wifiConnectResult: StateFlow<String?> = _wifiConnectResult.asStateFlow()
|
val wifiConnectResult: StateFlow<String?> = _wifiConnectResult.asStateFlow()
|
||||||
|
|
||||||
// WiGLE state
|
|
||||||
private val _wigleStatus = MutableStateFlow<WigleStatus?>(null)
|
|
||||||
val wigleStatus: StateFlow<WigleStatus?> = _wigleStatus.asStateFlow()
|
|
||||||
|
|
||||||
private val _wigleStats = MutableStateFlow<WigleStats?>(null)
|
|
||||||
val wigleStats: StateFlow<WigleStats?> = _wigleStats.asStateFlow()
|
|
||||||
|
|
||||||
private val _wigleConfigResult = MutableStateFlow<String?>(null)
|
|
||||||
val wigleConfigResult: StateFlow<String?> = _wigleConfigResult.asStateFlow()
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Initialize BeeApiClient with stored settings and token
|
// Initialize BeeApiClient with stored settings and token
|
||||||
|
|
@ -90,7 +79,6 @@ class SettingsViewModel(app: Application) : AndroidViewModel(app) {
|
||||||
if (s.isPaired) {
|
if (s.isPaired) {
|
||||||
refreshSshStatus()
|
refreshSshStatus()
|
||||||
refreshWifiStatus()
|
refreshWifiStatus()
|
||||||
refreshWigleStatus()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -273,58 +261,4 @@ class SettingsViewModel(app: Application) : AndroidViewModel(app) {
|
||||||
fun clearSshResult() {
|
fun clearSshResult() {
|
||||||
_sshToggleResult.value = null
|
_sshToggleResult.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── WiGLE ─────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh WiGLE status from device.
|
|
||||||
*/
|
|
||||||
fun refreshWigleStatus() {
|
|
||||||
viewModelScope.launch {
|
|
||||||
val client = beeClient ?: return@launch
|
|
||||||
when (val result = client.getWigleStatus()) {
|
|
||||||
is ApiResult.Success -> {
|
|
||||||
_wigleStatus.value = result.data
|
|
||||||
}
|
|
||||||
is ApiResult.Error -> {
|
|
||||||
Log.w(TAG, "Failed to get WiGLE status: ${result.message}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
when (val result = client.getWigleStats()) {
|
|
||||||
is ApiResult.Success -> {
|
|
||||||
_wigleStats.value = result.data
|
|
||||||
}
|
|
||||||
is ApiResult.Error -> {
|
|
||||||
Log.w(TAG, "Failed to get WiGLE stats: ${result.message}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set WiGLE configuration.
|
|
||||||
*/
|
|
||||||
fun setWigleConfig(enabled: Boolean, apiName: String, apiToken: String) {
|
|
||||||
viewModelScope.launch {
|
|
||||||
val client = beeClient ?: run {
|
|
||||||
_wigleConfigResult.value = "Not connected to device"
|
|
||||||
return@launch
|
|
||||||
}
|
|
||||||
_wigleConfigResult.value = null
|
|
||||||
|
|
||||||
when (val result = client.setWigleConfig(enabled, apiName, apiToken)) {
|
|
||||||
is ApiResult.Success -> {
|
|
||||||
_wigleConfigResult.value = "WiGLE configuration saved"
|
|
||||||
refreshWigleStatus()
|
|
||||||
}
|
|
||||||
is ApiResult.Error -> {
|
|
||||||
_wigleConfigResult.value = "Failed: ${result.message}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clearWigleResult() {
|
|
||||||
_wigleConfigResult.value = null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue