-
Notifications
You must be signed in to change notification settings - Fork 292
Enhance get_channels_with_hash() #859
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
base: master
Are you sure you want to change the base?
Conversation
To set the index 0 name to the preset name from localConfig.lora.modem_prese and compute hash so the output will not have bad index0 name or hash, also removes all disabled for clarity. this outputs `Device1 Channel Hash Table: [{'index': 0, 'role': 'PRIMARY', 'name': 'LongFast', 'hash': 8}` for a LongFast
ianmcorvidae
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of issues here -- the generated names won't always be right as-is and this needs to be done for secondary channels too. But a good change in general/otherwise
| result = [] | ||
| def format_preset_name(name): | ||
| # Convert name like MODEM_PRESET to ModemPreset | ||
| return ''.join(word.capitalize() for word in name.split('_')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite correct, because not every preset uses the full name for this. You can see what names firmware uses at https://github.com/meshtastic/firmware/blob/7212fb9caa15119c500edb3a074a5bc6b956605d/src/DisplayFormatters.cpp#L3-L41
Primarily it's just LONG_MODERATE though, and that the name Custom is used if a modem preset isn't in use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this too bulky? or should be in util?
MODEM_PRESET_DISPLAY_NAMES = {
"SHORT_TURBO": ("ShortTurbo", "ShortT"),
"SHORT_SLOW": ("ShortSlow", "ShortS"),
"SHORT_FAST": ("ShortFast", "ShortF"),
"MEDIUM_SLOW": ("MediumSlow", "MedS"),
"MEDIUM_FAST": ("MediumFast", "MedF"),
"LONG_SLOW": ("LongSlow", "LongS"),
"LONG_FAST": ("LongFast", "LongF"),
"LONG_MODERATE": ("LongMod", "LongM"),
}
def format_preset_name(name=None, use_short_name=False):
# Returns a user-friendly display name for a given preset.
if name is None:
return "Custom"
# Normalize input: extract the preset part from full enum string
if isinstance(name, str):
parts = name.split('_')
# Find the preset part (e.g., LONG_FAST)
for i in range(len(parts)):
key = '_'.join(parts[i:])
if key in MODEM_PRESET_DISPLAY_NAMES:
names = MODEM_PRESET_DISPLAY_NAMES[key]
return names[1] if use_short_name else names[0]
return "Invalid"Co-authored-by: Ian McEwen <[email protected]>
modem preset is set to none, the name used should be Custom
To set the index 0 name to the preset name from localConfig.lora.modem_preset when empty
and compute hash so the output will not have bad index0 name or hash, also removes all disabled for clarity.
This outputs
Device1 Channel Hash Table: [{'index': 0, 'role': 'PRIMARY', 'name': 'LongFast', 'hash': 8}for a LongFast