drivers/wireless: Add support for the RN903 and RN2483 LoRa modules#15828
drivers/wireless: Add support for the RN903 and RN2483 LoRa modules#15828acassis merged 2 commits intoapache:masterfrom
Conversation
|
[Experimental Bot, please feedback here] Yes, this PR appears to meet the NuttX requirements, although there's room for improvement in the level of detail provided. Strengths:
Areas for Improvement:
Specific Recommendations:
By addressing these points, the PR will be even stronger and provide reviewers with all the necessary information to efficiently evaluate the changes. |
|
Thanks @linguini1! I suggest we rename the PR Title to "drivers/wireless: Add support for..."? So it looks nicer in the NuttX Release Notes :-) https://nuttx.apache.org/releases/12.8.0/ |
|
Hi, do you plans to port to STM32WL55 ? |
If that MCU is supported by NuttX, then this driver should work on it. This is a generic driver that should work with any UART interface. |
SX1262 ? |
If NuttX supports the STM32WL55, so long as you connect the RN2xx3 to a UART interface on that chip, you can use this driver with that chip running NuttX. This driver is not for the SX1262. It appears that the WL55 is supported so this driver could be used on that chip. |
d8c2055 to
d9f6ca3
Compare
| * | ||
| ****************************************************************************/ | ||
|
|
||
| static ssize_t read_line(FAR struct rn2xx3_dev_s *priv, FAR char *buf, |
There was a problem hiding this comment.
Something still does not quite sit right here with me. You implicitly trust in data returned from the modem.
Can modem send more than 2 lines at a time? Can your driver lead to situation where 2 lines are in uart buffer? What will happend when there are 2 lines in buffer (like 10 char long) and you call it with nbytes == 15? You will read half of line, and next call will return invalid data.
Second case, what if line in uart buffer is longer than nbytes? You again will read half of frame - and report success, so at least 2 consecutive calls will return invalid data. I think you should sanitize received frame here to line level. If you did not read whole line, return -1, and discard from uart buffer until you reach \n.
I think you should implement small (at least 2 times the maximum size of single line modem can throw at you) ring buffer here and use that to read data. You can then call file_read when buffer gets empty to fill it back in.
Otherwise you will be returning invalid data to userspace.
There was a problem hiding this comment.
Thank you for the catch on this case. I have resolved case 2. However, in regards to case 1, no it is not possible with this driver for 2 lines to be present in the UART buffer. All commands to the modem are call/response, and before each call/response sequence I flush the UART buffer to make sure there is no lingering data that will interrupt the regular flow. The modem cannot send more than one line at a time, unless I deliberately issue more than one command at a time.
d9f6ca3 to
9898258
Compare
9898258 to
01adeb5
Compare
|
Good idea. The same can be done to my pr. |
Sure, I'll mark this in the docs and code comments. |
1a30fa5 to
2a4bac2
Compare
|
@linguini1 I see that you added common IOCTL commands, however i would suggest looking at #15856 maybe. The common API is still being worked on. I just started implementing the features into ioctl.h |
Hey yeah, I did see that discussion and I like some of the solutions proposed there. However, I don't want to start implementing the API from that discussion in this PR since I know it is still under discussion (I have some ideas to discuss as well). My plan was just to merge this prototype (marked as EXPERIMENTAL) and then make changes to it once we have a better idea of a fleshed out API. I'm willing to commit to making those changes in another PR along with changing the sx17x legacy driver. |
|
@linguini1 So i suggest maybe only adding the name of your driver infront of the commands for this temporary experimental phase? Lets see what the others think. |
I see, I assumed we would just rework those common commands entirely. I think @raiden00pl mentioned that he was (afaik) the only user of the SX127X driver and was fine with having those commands be completely changed. As far as I'm aware, the only drivers using WIOCTL commands right now are the SX127X, your SX126X and my RN2XX3 drivers. I wouldn't mind changing the WIOCTL commands I added to be specific to the RN2XX3 in the interim though, I just assumed they'd be overhauled shortly anyways. I can make that change. |
|
Hmm. I thought adding more to what has to be removed might deliver extra work. My strategy is to 1: add experimental drivers, 2: add common API, 3: port drivers and then 4: remove legacy. Slowly. When we want to rework the entire complete thing at once, we need to rework everything connected to the wireless ioctl.h It would be very nice to be able to work them one by one without breaking them or porting them all at once. But i think as long the already established common ones stay completely untouched and your solution doesn't get away in this process, its fine. I think just moving them a bit down under a comment also is completely OK. I'm really happy that people start to add LoRa to NuttX though! I can really really use these features. Thank you for doing this |
The only one I will be touching is the TXPWR commands, to change from int32_t dBm to int32_t 0.01 dBm, as per the earlier discussion on this PR.
Okay, I can definitely make that change easily!
Me as well, I'm very excited about your work, too. My rocketry team wants to move away from the integrated RN2483 and towards the SX series LoRa chips, so your work is a huge help in that direction. |
jerpelea
left a comment
There was a problem hiding this comment.
please move documentation to a separate commit in the same PR
4d22158 to
9d13bc6
Compare
radio transceivers. This initial support includes transmit and receive functionality and configuration and reading of radio parameters like frequency and bandwidth. Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
Adds a documentation page about the driver's programming interface and new WLIOC commands. Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
| * of the address is driver specific */ | ||
| #define WLIOC_SETTXPOWER _WLCIOC(0x0005) /* arg: Pointer to int32_t, */ | ||
| /* output power (in dBm) */ | ||
| /* output power (in 0.01 dBm) */ |
There was a problem hiding this comment.
this is true only for this driver. All the other drivers use the old unit. Either all other usage of this command should be fixed or this comment should say that this value depends on the driver
There was a problem hiding this comment.
You're right, it was my intention to change this globally once we decided on a better LoRa framework, but I can patch the docs if that's necessary.
Summary
Add support for the RN2903 and RN2483 family of LoRa radio transceivers. This initial support includes transmit and receive functionality and configuration and reading of radio parameters like frequency and bandwidth.
Impact
NuttX users can now use these radio transceivers!
This changes touches the build system, wireless drivers and documentation. The documentation includes examples of how to use the driver and its available commands.
Testing
Testing was performed from an RP2040 based custom flight computer. The chip this code was tested again was the RN2903, but commands for both modules are the same. The only difference is the values allowed for each command, but the radio module does its own error checking so the driver code will not need to change between modules.
The test script that was used to test the commands was:
The output is:
I also performed transmit/receive testing using a second RN2903 which I used to transmit/receive from a Python script. I was able to successfully receive messages sent from the NuttX driver, and I was also able to successfully receive messages with the NuttX driver sent from the Python script controlled transceiver.
The code works with
read/writefunctions, so it can beechoed into orcatted from to transmit and receive in the shell.Documentation was built locally and verified for correct render in the browser.