sforkowany z mirror/meshtastic-android
fix: set fixed position for local node only
rodzic
ad278f918b
commit
6297cf2b62
|
@ -1774,9 +1774,9 @@ class MeshService : Service(), Logging {
|
|||
// request position
|
||||
sendPosition(destNum = destNum, wantResponse = true)
|
||||
} else {
|
||||
// send fixed position
|
||||
// send fixed position (local only/no remote method, so we force destNum to null)
|
||||
val (lat, lon, alt) = position
|
||||
sendPosition(destNum = destNum, lat = lat, lon = lon, alt = alt)
|
||||
sendPosition(destNum = null, lat = lat, lon = lon, alt = alt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,6 +158,7 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) {
|
|||
val connected = connectionState == MeshService.ConnectionState.CONNECTED
|
||||
|
||||
val destNum = node.num
|
||||
val isLocal = destNum == viewModel.myNodeNum
|
||||
val maxChannels = viewModel.myNodeInfo.value?.maxChannels ?: 8
|
||||
|
||||
var userConfig by remember { mutableStateOf(MeshProtos.User.getDefaultInstance()) }
|
||||
|
@ -308,7 +309,7 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) {
|
|||
composable("home") {
|
||||
RadioSettingsScreen(
|
||||
enabled = connected && !isWaiting,
|
||||
isLocal = destNum == viewModel.myNodeNum,
|
||||
isLocal = isLocal,
|
||||
headerText = node.user?.longName ?: stringResource(R.string.unknown_username),
|
||||
onRouteClick = { configType ->
|
||||
packetResponseState = PacketResponseState.Loading.apply {
|
||||
|
@ -408,6 +409,7 @@ fun RadioConfigNavHost(node: NodeInfo, viewModel: UIViewModel = viewModel()) {
|
|||
}
|
||||
composable("position") {
|
||||
PositionConfigItemList(
|
||||
isLocal = isLocal,
|
||||
location = location,
|
||||
positionConfig = radioConfig.position,
|
||||
enabled = connected,
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.geeksville.mesh.ui.components.SwitchPreference
|
|||
|
||||
@Composable
|
||||
fun PositionConfigItemList(
|
||||
isLocal: Boolean = false,
|
||||
location: Position?,
|
||||
positionConfig: PositionConfig,
|
||||
enabled: Boolean,
|
||||
|
@ -93,7 +94,7 @@ fun PositionConfigItemList(
|
|||
item {
|
||||
EditTextPreference(title = "Latitude",
|
||||
value = locationInput?.latitude ?: 0.0,
|
||||
enabled = enabled,
|
||||
enabled = enabled && isLocal,
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
|
||||
onValueChanged = { value ->
|
||||
if (value >= -90 && value <= 90.0)
|
||||
|
@ -103,7 +104,7 @@ fun PositionConfigItemList(
|
|||
item {
|
||||
EditTextPreference(title = "Longitude",
|
||||
value = locationInput?.longitude ?: 0.0,
|
||||
enabled = enabled,
|
||||
enabled = enabled && isLocal,
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
|
||||
onValueChanged = { value ->
|
||||
if (value >= -180 && value <= 180.0)
|
||||
|
@ -113,7 +114,7 @@ fun PositionConfigItemList(
|
|||
item {
|
||||
EditTextPreference(title = "Altitude (meters)",
|
||||
value = locationInput?.altitude ?: 0,
|
||||
enabled = enabled,
|
||||
enabled = enabled && isLocal,
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
|
||||
onValueChanged = { value ->
|
||||
locationInput?.let { locationInput = it.copy(altitude = value) }
|
||||
|
|
Ładowanie…
Reference in New Issue