Skip to content

Commit 426795f

Browse files
committed
semi-experimentally, add fallback code for message_to_json, allowing older protobuf library versions
1 parent fb88ee1 commit 426795f

File tree

3 files changed

+728
-766
lines changed

3 files changed

+728
-766
lines changed

meshtastic/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,5 +675,8 @@ def check_if_newer_version() -> Optional[str]:
675675

676676
def message_to_json(message: Message, multiline: bool=False) -> str:
677677
"""Return protobuf message as JSON. Always print all fields, even when not present in data."""
678-
json = MessageToJson(message, always_print_fields_with_no_presence=True)
678+
try:
679+
json = MessageToJson(message, always_print_fields_with_no_presence=True)
680+
except TypeError:
681+
json = MessageToJson(message, including_default_value_fields=True)
679682
return stripnl(json) if not multiline else json

0 commit comments

Comments
 (0)