Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ def _printSetting(config_type, uni_name, pref_value, repeated):
config_values = getattr(config, config_type.name)
if not wholeField:
pref_value = getattr(config_values, pref.name)
repeated = pref.label == pref.LABEL_REPEATED
repeated = _is_repeated_field(pref)
_printSetting(config_type, uni_name, pref_value, repeated)
else:
for field in config_values.ListFields():
repeated = field[0].label == field[0].LABEL_REPEATED
repeated = _is_repeated_field(field[0])
_printSetting(config_type, field[0].name, field[1], repeated)
else:
# Always show whole field for remote node
Expand Down Expand Up @@ -253,7 +253,7 @@ def setPref(config, comp_name, raw_val) -> bool:
return False

# repeating fields need to be handled with append, not setattr
if pref.label != pref.LABEL_REPEATED:
if not _is_repeated_field(pref):
try:
if config_type.message_type is not None:
config_values = getattr(config_part, config_type.name)
Expand Down Expand Up @@ -1131,6 +1131,12 @@ def subscribe() -> None:

# pub.subscribe(onNode, "meshtastic.node")

def _is_repeated_field(field_desc) -> bool:
"""Return True if the protobuf field is repeated. Protobuf 6:3.10 and later us an is_repeated property"""
if hasattr(field_desc, "is_repeated"):
return bool(field_desc.is_repeated)
return field_desc.label == field_desc.LABEL_REPEATED

def set_missing_flags_false(config_dict: dict, true_defaults: set[tuple[str, str]]) -> None:
"""Ensure that missing default=True keys are present in the config_dict and set to False."""
for path in true_defaults:
Expand Down
Loading