Description
The driver has the option to set the SyncWord via its configure() command (also via driver init), in the option "syncword".
Most of the code is correct but when writing the syncword value to the SX126x device registry, it writes to a wrong registry because of a code issue.
Package: lora-sx126x
MicroPython: MicroPython v1.22.1 on 2024-01-05; Generic ESP32S3 module with ESP32S3
Board: Heltec LoRa 32 v3
code file: micropython-lib/micropython/lora/lora-sx126x/lora/sx126x.py
code line: 386
code current: self._cmd(">BBH", _CMD_WRITE_REGISTER, _REG_LSYNCRH, syncword)
code fixed: self._cmd(">BHH", _CMD_WRITE_REGISTER, _REG_LSYNCRH, syncword)
code note: Changing the data packing format from ">BBH"
to ">BHH"
so the full 16bit registry address is used.
I have tested the change with creating a separate function (as i have not been able to edit the library code)
def lora_write_syncword(modem, syncword: int = 0x12):
_CMD_WRITE_REGISTER = const(0x0D)
_REG_LSYNCRH = const(0x0740)
if syncword < 0x100:
syncword = 0x0404 + ((syncword & 0x0F) << 4) + ((syncword & 0xF0) << 8)
# Write Peripheral Register
modem._cmd(">BHH", _CMD_WRITE_REGISTER, _REG_LSYNCRH, syncword)
Tested by receiving messages from Meshtastic v2 devices witch use the syncword 0x2B.