diff --git a/meshtastic/mesh_interface.py b/meshtastic/mesh_interface.py index 4c90969..5e55a0c 100644 --- a/meshtastic/mesh_interface.py +++ b/meshtastic/mesh_interface.py @@ -470,9 +470,13 @@ class MeshInterface: # pylint: disable=R0902 """ # issue 464: allow for 0x prefix in destinationId for hex values - if type(destinationId) == str: - destinationId = destinationId.replace('0x', '!') - logging.debug(f'destinationId: {destinationId}') + # destination ids can either be integers or strings with a !prefix + try: + int(destinationId) + except ValueError: + # only take the last 8 characters of the destinationId and force a ! prefix + destinationId = f'!{destinationId[-8:]}' + logging.info(f"Formatted destinationId: {destinationId}") if getattr(data, "SerializeToString", None): logging.debug(f"Serializing protobuf as data: {stripnl(data)}")