Skip to content

Commit d0023df

Browse files
committed
slight logic rework
1 parent b522abf commit d0023df

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

meshtastic/mesh_interface.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,13 @@ def sendData(
470470
"""
471471

472472
# issue 464: allow for 0x prefix in destinationId for hex values
473-
if type(destinationId) == str:
474-
destinationId = destinationId.replace('0x', '!')
475-
logging.debug(f'destinationId: {destinationId}')
473+
# destination ids can either be integers or strings with a !prefix
474+
try:
475+
int(destinationId)
476+
except ValueError:
477+
# only take the last 8 characters of the destinationId and force a ! prefix
478+
destinationId = f'!{destinationId[-8:]}'
479+
logging.info(f"Formatted destinationId: {destinationId}")
476480

477481
if getattr(data, "SerializeToString", None):
478482
logging.debug(f"Serializing protobuf as data: {stripnl(data)}")

0 commit comments

Comments
 (0)