Skip to content

LoRa Driver SX126x does not set SyncWord #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oeysteinhansen opened this issue Feb 3, 2024 · 2 comments · Fixed by #804
Closed

LoRa Driver SX126x does not set SyncWord #796

oeysteinhansen opened this issue Feb 3, 2024 · 2 comments · Fixed by #804

Comments

@oeysteinhansen
Copy link

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.

projectgus added a commit to projectgus/micropython-lib that referenced this issue Feb 13, 2024
Closes micropython#796.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
@projectgus
Copy link
Contributor

@oeysteinhansen Thanks for the very clear bug report! I've got a fix for this ready now, exactly along the lines you suggested.

projectgus added a commit to projectgus/micropython-lib that referenced this issue Feb 13, 2024
Closes micropython#796.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
projectgus added a commit to projectgus/micropython-lib that referenced this issue Feb 13, 2024
Closes micropython#796.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
@oeysteinhansen
Copy link
Author

Thank you for your quick response. Had a look at the #804 committed code. Looks correct.
I will update when a version with the fixes is available.

projectgus added a commit to projectgus/micropython-lib that referenced this issue Feb 19, 2024
Closes micropython#796.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
dpgeorge pushed a commit to projectgus/micropython-lib that referenced this issue Feb 20, 2024
Fixes issue micropython#796.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants