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