|
7 | 7 |
|
8 | 8 | from typing import Optional, Union, List |
9 | 9 |
|
10 | | -from meshtastic.protobuf import admin_pb2, apponly_pb2, channel_pb2, localonly_pb2, mesh_pb2, portnums_pb2 |
| 10 | +from meshtastic.protobuf import admin_pb2, apponly_pb2, channel_pb2, config_pb2, localonly_pb2, mesh_pb2, portnums_pb2 |
11 | 11 | from meshtastic.util import ( |
12 | 12 | Timeout, |
13 | 13 | camel_to_snake, |
|
18 | 18 | message_to_json, |
19 | 19 | generate_channel_hash, |
20 | 20 | to_node_num, |
| 21 | + flags_to_list, |
21 | 22 | ) |
22 | 23 |
|
23 | 24 | logger = logging.getLogger(__name__) |
@@ -54,6 +55,16 @@ def __repr__(self): |
54 | 55 | r += ")" |
55 | 56 | return r |
56 | 57 |
|
| 58 | + @staticmethod |
| 59 | + def position_flags_list(position_flags: int) -> List[str]: |
| 60 | + "Return a list of position flags from the given flags integer" |
| 61 | + return flags_to_list(config_pb2.Config.PositionConfig.PositionFlags, position_flags) |
| 62 | + |
| 63 | + @staticmethod |
| 64 | + def excluded_modules_list(excluded_modules: int) -> List[str]: |
| 65 | + "Return a list of excluded modules from the given flags integer" |
| 66 | + return flags_to_list(mesh_pb2.ExcludedModules, excluded_modules) |
| 67 | + |
57 | 68 | def module_available(self, excluded_bit: int) -> bool: |
58 | 69 | """Check DeviceMetadata.excluded_modules to see if a module is available.""" |
59 | 70 | meta = getattr(self.iface, "metadata", None) |
@@ -902,6 +913,18 @@ def onRequestGetMetadata(self, p): |
902 | 913 | logger.debug(f"Received metadata {stripnl(c)}") |
903 | 914 | print(f"\nfirmware_version: {c.firmware_version}") |
904 | 915 | print(f"device_state_version: {c.device_state_version}") |
| 916 | + if c.role in config_pb2.Config.DeviceConfig.Role.values(): |
| 917 | + print(f"role: {config_pb2.Config.DeviceConfig.Role.Name(c.role)}") |
| 918 | + else: |
| 919 | + print(f"role: {c.role}") |
| 920 | + print(f"position_flags: {self.position_flags_list(c.position_flags)}") |
| 921 | + if c.hw_model in mesh_pb2.HardwareModel.values(): |
| 922 | + print(f"hw_model: {mesh_pb2.HardwareModel.Name(c.hw_model)}") |
| 923 | + else: |
| 924 | + print(f"hw_model: {c.hw_model}") |
| 925 | + print(f"hasPKC: {c.hasPKC}") |
| 926 | + if c.excluded_modules > 0: |
| 927 | + print(f"excluded_modules: {self.excluded_modules_list(c.excluded_modules)}") |
905 | 928 |
|
906 | 929 | def onResponseRequestChannel(self, p): |
907 | 930 | """Handle the response packet for requesting a channel _requestChannel()""" |
|
0 commit comments