Skip to content

Commit

Permalink
Fix the handling of hexadecimal message payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
janakj committed Aug 25, 2022
1 parent 5ef8f1d commit 5e6703d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions python/lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def write(self, cmd: bytes, flush=True):

print(f'< {msg.decode("ascii", errors="replace")}')

self.port.write(cmd + b'\r\n')
self.port.write(cmd + b'\r')
if flush:
self.flush()

Expand Down Expand Up @@ -2078,10 +2078,7 @@ def tx(self, data: bytes, confirmed = False, timeout: float = None, hex = False)
with self.modem.lock:
with self.modem.events as events:
self.modem.AT(f'+{type}TX {len(data)}', wait=False, flush=False)
if hex:
self.modem.port.write(binascii.hexlify(data))
else:
self.modem.port.write(data)
self.modem.port.write(binascii.hexlify(data) if hex else data)
self.modem.flush()
self.modem.read_inline_response()
if confirmed:
Expand Down Expand Up @@ -3816,7 +3813,7 @@ def trx(get_modem: Callable[[], OpenLoRaModem], encoding, delimiter: str, messag

modem = get_modem()

hex = modem.data_encoding == 1
hex = modem.data_encoding == DataFormat.HEXADECIMAL
delim = delimiter.encode('utf-8')
if len(delim) != 1:
raise Exception('Delimiter must be a single-byte character')
Expand Down

0 comments on commit 5e6703d

Please sign in to comment.