@@ -158,11 +158,11 @@ def _printSetting(config_type, uni_name, pref_value, repeated):
158158 config_values = getattr (config , config_type .name )
159159 if not wholeField :
160160 pref_value = getattr (config_values , pref .name )
161- repeated = pref . label == pref . LABEL_REPEATED
161+ repeated = _is_repeated_field ( pref )
162162 _printSetting (config_type , uni_name , pref_value , repeated )
163163 else :
164164 for field in config_values .ListFields ():
165- repeated = field [0 ]. label == field [ 0 ]. LABEL_REPEATED
165+ repeated = _is_repeated_field ( field [0 ])
166166 _printSetting (config_type , field [0 ].name , field [1 ], repeated )
167167 else :
168168 # Always show whole field for remote node
@@ -253,7 +253,7 @@ def setPref(config, comp_name, raw_val) -> bool:
253253 return False
254254
255255 # repeating fields need to be handled with append, not setattr
256- if pref . label != pref . LABEL_REPEATED :
256+ if not _is_repeated_field ( pref ) :
257257 try :
258258 if config_type .message_type is not None :
259259 config_values = getattr (config_part , config_type .name )
@@ -1131,6 +1131,14 @@ def subscribe() -> None:
11311131
11321132 # pub.subscribe(onNode, "meshtastic.node")
11331133
1134+ def _is_repeated_field (field_desc ) -> bool :
1135+ """Return True if the protobuf field is repeated.
1136+ Protobuf 6.31.0 and later use an is_repeated property, while older versions compare against the label field.
1137+ """
1138+ if hasattr (field_desc , "is_repeated" ):
1139+ return bool (field_desc .is_repeated )
1140+ return field_desc .label == field_desc .LABEL_REPEATED
1141+
11341142def set_missing_flags_false (config_dict : dict , true_defaults : set [tuple [str , str ]]) -> None :
11351143 """Ensure that missing default=True keys are present in the config_dict and set to False."""
11361144 for path in true_defaults :
0 commit comments