lora/lora-sx127x-pycom: Add unified SX1272/SX1276 LoRa driver#1102
lora/lora-sx127x-pycom: Add unified SX1272/SX1276 LoRa driver#1102ddtdanilo wants to merge 1 commit into
Conversation
Add a LoRa radio driver that handles both SX1272 and SX1276 transceivers. The existing lora-sx127x package only supports SX1276 (version register 0x12); this driver also handles SX1272 (version 0x22) with its different register layouts for bandwidth, coding rate, CRC, and RSSI calculation. Used by Pycom LoPy (SX1272) and LoPy4 (SX1276) boards as defined in micropython/micropython#19026. Signed-off-by: Danilo D <danilodt@gmail.com>
projectgus
left a comment
There was a problem hiding this comment.
This looks really exciting, thanks @ddtdanilo! Had always hoped the LoRa micropython-lib support would be enough for someone to build a LoRaWAN driver.
Do you mind moving the lorawan support into its own PR, please? There's a lot of new code here, and it will be easier to review and merge these independently.
|
Hi @projectgus — thanks for the review! I've split the LoRaWAN MAC layer into its own PR as you suggested: ➡️ #1111 ( This PR (#1102) now contains only the Let me know if you'd like any further changes to either one. |
|
Hi @projectgus — just a friendly check-in on this one. Since the split a week ago, #1102 carries only the |
projectgus
left a comment
There was a problem hiding this comment.
Hi @ddtdanilo,
Thanks for splitting these out and sorry it's taken me a little while to respond.
My main concern with this driver is that it sits independent from the existing lora-sx126x and lora-sx127x drivers, which both share a common base class for their documented public API, and support both synchronous and asynchronous driver classes on top.
Particularly as we already have a SX1276 driver, merging a second slightly different SX1276 driver seems like a mis-step.
So before going into more details, my high-level questions:
- Is this driver API-compatible with the existing SX1276 driver in micropython-lib?
- Did you investigate how hard it would be to add an SX1272 driver with the same architecture as the existing lora-sx127x driver, and/or by extending the existing lora-sx126x driver? If so, what did you find?
(This may go without saying, and I apologise if this seems abrupt, but I'm interested in what you the human contributor thinks, as opposed to what text an LLM outputs when asked these questions. Although you're of course welcome to consult an LLM yourself.)
Sorry, answering my own question here as I started looking at the LoRaWAN PR which has some sample code - the APIs aren't compatible. I'm afraid that's a non-negotiable, we can't support two different LoRa APIs in micropython-lib (particularly if we end up with two drivers for one chip). |
Summary
Add
lora-sx127x-pycom: a unified SX1272/SX1276 LoRa radio driver formicropython-lib.The existing
lora-sx127xpackage only supports SX1276 (version register0x12); this driver also handles SX1272 (0x22), which has a different register layout for bandwidth encoding, coding rate bits, CRC location, and RSSI calculation offsets.This package is consumed by the Pycom LoPy (SX1272) and LoPy4 (SX1276) board definitions in micropython/micropython#19026.
Testing
ruff checkandruff formatRelated