Fix/2558 rangetest (#2569)

This commit is contained in:
DaneEvans
2025-07-30 21:50:25 +10:00
committed by GitHub
parent 00898d64be
commit edd40890be
4 changed files with 12 additions and 10 deletions

View File

@@ -207,10 +207,10 @@ class MainActivity :
return resultPendingIntent!!
}
private val createDocumentLauncher =
private val createRangetestLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == RESULT_OK) {
it.data?.data?.let { file_uri -> model.saveMessagesCSV(file_uri) }
it.data?.data?.let { file_uri -> model.saveRangetestCSV(file_uri) }
}
}
@@ -264,14 +264,14 @@ class MainActivity :
getVersionInfo()
}
MainMenuAction.EXPORT_MESSAGES -> {
MainMenuAction.EXPORT_RANGETEST -> {
val intent =
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "application/csv"
putExtra(Intent.EXTRA_TITLE, "rangetest.csv")
}
createDocumentLauncher.launch(intent)
createRangetestLauncher.launch(intent)
}
MainMenuAction.THEME -> {

View File

@@ -879,7 +879,8 @@ constructor(
}
/** Write the persisted packet data out to a CSV file in the specified location. */
fun saveMessagesCSV(uri: Uri) {
@Suppress("detekt:CyclomaticComplexMethod", "detekt:LongMethod")
fun saveRangetestCSV(uri: Uri) {
viewModelScope.launch(Dispatchers.Main) {
// Extract distances to this device from position messages and put (node,SNR,distance)
// in
@@ -917,9 +918,10 @@ constructor(
}
}
// Filter out of our results any packet that doesn't report SNR. This
// is primarily ADMIN_APP.
if (proto.rxSnr != 0.0f) {
// Only look at range test messages, with SNR reported.
if (
proto.decoded.portnumValue == Portnums.PortNum.RANGE_TEST_APP_VALUE && proto.rxSnr != 0.0f
) {
val rxDateTime = dateFormat.format(packet.received_date)
val rxFrom = proto.from.toUInt()
val senderName = nodes[proto.from]?.user?.longName ?: ""

View File

@@ -371,7 +371,7 @@ private fun VersionChecks(viewModel: UIViewModel) {
enum class MainMenuAction(@StringRes val stringRes: Int) {
DEBUG(R.string.debug_panel),
RADIO_CONFIG(R.string.radio_configuration),
EXPORT_MESSAGES(R.string.save_messages),
EXPORT_RANGETEST(R.string.save_rangetest),
THEME(R.string.theme),
LANGUAGE(R.string.preferences_language),
SHOW_INTRO(R.string.intro_show),

View File

@@ -156,7 +156,7 @@
<string name="okay">OK</string>
<string name="must_set_region">You must set a region!</string>
<string name="cant_change_no_radio">Couldn\'t change channel, because radio is not yet connected. Please try again.</string>
<string name="save_messages">Export rangetest.csv</string>
<string name="save_rangetest">Export rangetest.csv</string>
<string name="reset">Reset</string>
<string name="scan">Scan</string>
<string name="are_you_sure_change_default">Are you sure you want to change to the default channel?</string>