sforkowany z mirror/meshtastic-android
refactor: use Position object as requestPosition parameter
rodzic
2d9f0a56f2
commit
fb8a640873
|
@ -5,6 +5,7 @@ package com.geeksville.mesh;
|
||||||
parcelable DataPacket;
|
parcelable DataPacket;
|
||||||
parcelable NodeInfo;
|
parcelable NodeInfo;
|
||||||
parcelable MeshUser;
|
parcelable MeshUser;
|
||||||
|
parcelable Position;
|
||||||
parcelable MyNodeInfo;
|
parcelable MyNodeInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,7 +102,7 @@ interface IMeshService {
|
||||||
void commitEditSettings();
|
void commitEditSettings();
|
||||||
|
|
||||||
/// Send position packet with wantResponse to nodeNum
|
/// Send position packet with wantResponse to nodeNum
|
||||||
void requestPosition(in int idNum, in double lat, in double lon, in int alt);
|
void requestPosition(in int idNum, in Position position);
|
||||||
|
|
||||||
/// Send Shutdown admin packet to nodeNum
|
/// Send Shutdown admin packet to nodeNum
|
||||||
void requestShutdown(in int idNum);
|
void requestShutdown(in int idNum);
|
||||||
|
|
|
@ -207,9 +207,9 @@ class UIViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun requestPosition(destNum: Int, lat: Double = 0.0, lon: Double = 0.0, alt: Int = 0) {
|
fun requestPosition(destNum: Int, position: Position = Position(0.0, 0.0, 0)) {
|
||||||
try {
|
try {
|
||||||
meshService?.requestPosition(destNum, lat, lon, alt)
|
meshService?.requestPosition(destNum, position)
|
||||||
} catch (ex: RemoteException) {
|
} catch (ex: RemoteException) {
|
||||||
errormsg("Request position error: ${ex.message}")
|
errormsg("Request position error: ${ex.message}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1741,8 +1741,9 @@ class MeshService : Service(), Logging {
|
||||||
stopLocationRequests()
|
stopLocationRequests()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun requestPosition(idNum: Int, lat: Double, lon: Double, alt: Int) =
|
override fun requestPosition(idNum: Int, position: Position) =
|
||||||
toRemoteExceptions {
|
toRemoteExceptions {
|
||||||
|
val (lat, lon, alt) = with(position) { Triple(latitude, longitude, altitude) }
|
||||||
// request position
|
// request position
|
||||||
if (idNum != 0) sendPosition(time = 1, destNum = idNum, wantResponse = true)
|
if (idNum != 0) sendPosition(time = 1, destNum = idNum, wantResponse = true)
|
||||||
// set local node's fixed position
|
// set local node's fixed position
|
||||||
|
|
|
@ -336,9 +336,8 @@ fun DeviceSettingsItemList(viewModel: UIViewModel = viewModel()) {
|
||||||
},
|
},
|
||||||
onSaveClicked = {
|
onSaveClicked = {
|
||||||
focusManager.clearFocus()
|
focusManager.clearFocus()
|
||||||
if (positionInfo != ourNodeInfo?.position && positionInput.fixedPosition) positionInfo?.let {
|
if (positionInfo != ourNodeInfo?.position && positionInput.fixedPosition)
|
||||||
viewModel.requestPosition(0, it.latitude, it.longitude, it.altitude)
|
positionInfo?.let { viewModel.requestPosition(0, it) }
|
||||||
}
|
|
||||||
if (positionInput != localConfig.position) viewModel.updatePositionConfig { positionInput }
|
if (positionInput != localConfig.position) viewModel.updatePositionConfig { positionInput }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue