Fixed bug with the names of the devices not being decoded

This commit is contained in:
Gleb Tcivie 2024-06-25 23:09:06 +03:00
parent 2a9b47b4b3
commit aebb5a0456
2 changed files with 9 additions and 7 deletions

2
.env
View file

@ -27,4 +27,4 @@ MESH_HIDE_DESTINATION_DATA=false
## Filtered ports in the exporter (default: 1, can be a comma-separated list of ports) ## Filtered ports in the exporter (default: 1, can be a comma-separated list of ports)
FILTERED_PORTS=0 FILTERED_PORTS=0
## Hide message content in the TEXT_MESSAGE_APP packets (default: true) (Currently we only log message length, if we hide then all messages would have the same length) ## Hide message content in the TEXT_MESSAGE_APP packets (default: true) (Currently we only log message length, if we hide then all messages would have the same length)
HIDE_MESSAGE=true HIDE_MESSAGE=false

View file

@ -361,15 +361,17 @@ class ClientDetails:
self.role: Config.DeviceConfig.Role = role self.role: Config.DeviceConfig.Role = role
def get_role_name_from_role(self): def get_role_name_from_role(self):
for name, value in Config.DeviceConfig.Role.__dict__.items(): descriptor = Config.DeviceConfig.Role.DESCRIPTOR
if isinstance(value, int) and value == self.role: for enum_value in descriptor.values:
return name if enum_value.number == self.role:
return enum_value.name
return 'UNKNOWN_ROLE' return 'UNKNOWN_ROLE'
def get_hardware_model_name_from_code(self): def get_hardware_model_name_from_code(self):
for name, value in HardwareModel.__dict__.items(): descriptor = HardwareModel.DESCRIPTOR
if isinstance(value, int) and value == self.hardware_model: for enum_value in descriptor.values:
return name if enum_value.number == self.hardware_model:
return enum_value.name
return 'UNKNOWN_HARDWARE_MODEL' return 'UNKNOWN_HARDWARE_MODEL'
def to_dict(self): def to_dict(self):