Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mic-E & Compressed #397

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Mic-E & Compressed #397

wants to merge 2 commits into from

Conversation

na7q
Copy link
Contributor

@na7q na7q commented Dec 27, 2024

Initial commit for Mic-E and Compressed beacons.

Copy link
Owner

@ge0rg ge0rg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for the PR! I've left a bunch of comments marked as follows:

  • [important] = this needs to be resolved before merging the PR
  • [optional] = it would be nice, but I'm not insisting on them.

Please let me know if you would like to attempt the changes on your own, if you need some assistance, or if you'd prefer me to change the code accordingly.

android:parentActivityName=".PrefsAct"
android:launchMode="singleTop"
android:configChanges="orientation|keyboardHidden|screenSize" />

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[important] It would be more intuitive to have the compression setting use a de.duenndns.ListPreferenceWithValue drop-down with the title "Beacon compression" and the values "uncompressed", "compressed" and "Mic-E".

Together with the "Mic-E Status" that's down to two menu items, so they can appear in the main preferences screen and not be hidden in a sub-menu. The "Mic-E Status" menu then can be enabled/disabled based on the value of the tri-state.

<item>Special</item>
<item>Priority</item>
<item>EMERGENCY!</item>
</string-array>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] From APRS12b I take it that the "Custom 0...6" status types do not need to be supported.

[important] I'm not sure right now if the standard status type should be translated into the respective user locale or kept in English. In the former case, the array should be moved into the strings.xml file.

@@ -110,4 +110,14 @@
<item>460800</item>
<item>921600</item>
</string-array>
<string-array name="compressed_mice_status">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] For consistency, the name should be p_mice_status_e (preferences, Mic-E status, entries)

"W", "X", "Y", "Z"
)

def statusToBits(status: String): (Int, Int, Int) = status match {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[important] the function should be called miceStatusToBits() for consistency, also using the English string value is not a robust way to obtain the value. You should add a android:entryValues= property to the drop-down, and then you can encode the bit values ("111", "110", ...) in the compressed_mice_status_ev array.

[optional] But I'd rather use the numeric IDs (position in the array), 0, 1, 2, 3, ... and convert them to the respective bits algorithmically. PrefsWrapper.getListItemIndex() will return the numeric ID, and the bit-ops should be:

val a = ((mice_status_id >> 2) & 1) ^ 1;
val b = ((mice_status_id >> 1) & 1) ^ 1;
val c = ((mice_status_id >> 0) & 1) ^ 1;

(degrees, minutesInt, minutesHundreths)
}

def encodeDest(dd: Double, longOffset: Int, west: Int, messageA: Int, messageB: Int, messageC: Int, ambiguity: Int): String = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[important] should be called encodeMiceDest

encoded.take(6 - validAmbiguity) + "Z" * validAmbiguity
}

def encodeInfo(dd: Double, speed: Double, heading: Double, symbol: String): (String, Int, Int) = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[important] should be called encodeMiceInfo(). Also you are passing the latitude (as the dd parameter, but you are not encoding the ambiguity here. The code should also treat location ambiguity for latitude correctly.

(sb.toString(), west, longOffset)
}

def altitude(alt: Double): String = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[important] it's not clear what this function does. It should be called formatAltitude<something> where something tells the format. I guess it's formatAltitudeMice() but I'm not quite sure.

val val3 = rem % 91

// Ensure that the characters are treated as strings and concatenate properly
charFromInt(val1).toString + charFromInt(val2).toString + charFromInt(val3).toString + "}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] this line's indentation is not at the same level ;)

val micePacketParsed = Parser.parse(micePacketString)

micePacketParsed
}
def formatLoc(symbol : String, status : String, location : Location) = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] not sure if it would look cleaner if we'd split the compressed packet encoding into formatLocCompressed and then call that separately, instead of treating both cases from one method.

def postLocation(location : Location) {
var symbol = prefs.getString("symbol", "")
if (symbol.length != 2)
symbol = getString(R.string.default_symbol)
val status = prefs.getString("status", getString(R.string.default_status))
val packet = formatLoc(symbol, status, location)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[important] I'd prefer to keep the logic in this method agnostic to the used compression mechanism, so my suggestion would be:

  1. rename formatLoc to formatLocUncompressed
  2. move the compressed location encoding to formatLocCompressed
  3. make a new formatLoc wrapper method that will call and return the appropriate formatLocX according to the preference value.

@na7q
Copy link
Contributor Author

na7q commented Dec 29, 2024

Fixed Ambiguity & MessageC problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants