-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Initial standalone sx126x driver [WIP] #15795
base: master
Are you sure you want to change the base?
Conversation
[Experimental Bot, please feedback here] Fill In The Commit Message: This PR contains a Commit with an Empty Commit Message. Please fill in the Commit Message with the PR Summary. This PR, as it stands, does not meet the NuttX requirements. While the idea is promising and addresses a real need, it's currently too incomplete to be considered a proper pull request. Here's why:
Recommendations:
By following these recommendations, you can create a PR that meets the NuttX requirements and is more likely to be accepted. |
FAR struct sx126x_dev_s g_sx126x_devices[SX126X_MAX_DEVICES]; | ||
static const struct file_operations sx126x_ops = | ||
{ | ||
sx126x_open, sx126x_close, sx126x_read, sx126x_write, 0, 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put an operation by line, it is easier to stop mistake or missing ops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agreed. This is very much a placeholder thing. I started off with a template for this. Will do.
I am not entirely sure why all the indents are triple space now. Maybe something happened after copying the file over and it somehow magically auto formatted it to tripple space from doubles. Maybe someone has an idea |
hm, i dont think that squashed, or did it |
0e88488
to
3fb5506
Compare
I am not sure if i should keep squashing it with force pushing on every change. Tell me if i am doing something wrong. Learning new things |
return -EINVAL; | ||
} | ||
|
||
printf("Reading\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest replacing printf() with syslog info or debug info() macro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good idea, also just placeholder for now. I am planning on replacing all of these to wlerr, wlinfo, etc. We have one of these already, so might as well. I just partially integrated everything into Nuttx, such as public includes, Kconfig and make files. I am testing everything on a board as described before. Is it a good idea to just add this one into this PR later? That makes things a bit easier.
return -EINVAL; | ||
} | ||
|
||
printf("Trying to write\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
ping @keever50 |
pong @acassis Update: Just did a ping pong test with two radios and it works perfectly. Will PR when ready. Most likely this week. |
I can drop the updates here for review if you like but it is not fully cleaned up yet. |
3fb5506
to
8936e44
Compare
Let me know if these integrations and ioctl look OK. I would appreciate that. If anything has to be changed lmk |
@keever50 I suggest just separating the board support from the driver. You can still keep everything is in PR, just separate logically the driver from the board |
@acassis Is it okay if i create a completely new fresh PR somewhere this week with the clean up and board removed? This makes things a bit easier to manage. Later afterwards i can do a PR for the board and a PR for the example app in the different repo. Ill make sure to link back to this PR. I am still quite new to open source projects. |
hi, can we make this driver interface compatible with sx127x ? It would be ideally if this driver can work with |
@raiden00pl yes! i was thinking about trying to do this... are we sure we want to break the API? Maybe we can add wrapper macros that point to SX12XX ioctls. That way old apps dont need to be ported. |
There are quite some things in common between these devices. For pretty much all LoRa devices(SF, BW). Maybe it would be nice to have ioctls for common lora devices. Let me know what you think. |
I think that a portable API is more important than breaking the code for a few users. Breaking changes will be easy to detect and fix (compiler errors), most likely it will be some names change in the user code. The sx127x API was never mature (I say this as the author of this driver), so I think this is a perfect example where a breaking change is justified. But that's just my opinion :) |
#15828 here is another PR with LORA chip support. Shared ioctl will be beneficial for this driver as well |
@raiden00pl good points. What do we imagine the ioctl commands would look like? Currently in that PR i see that WLIOC is used to implement specific LoRa features. Personally i think it would be logical to say WLIOC_LORA_xxx instead putting it all on WLIOC that might be shared with other modulations, such as GFSK, OOK etc. This allows WLIOC_GFSK, WLIOC_OOK etc in the future as well. |
8936e44
to
e3485a0
Compare
I will do more testing on this driver and put a test report here this week. Also go over the code for a cleanup. |
c1e8ddb
to
66d63cc
Compare
Fixed some issues after testing the driver using RAK11310 and a demo code. You can see that the RSSI and SNR appear to be incorrect. These values have not been decided on what they should be. However, the driver is fully functional otherwise. There are ofcourse some features not yet implemented, but they are less significant. The test code is available here. Its not yet PR'd before the driver is pushed. https://pastebin.com/S7iY6Z3m |
The serial output seems unstable. Missing characters sometimes. I am not entirely sure what is causing that. Might be because my app is using printf and the driver is using logging. Might be causing race conditions. |
Actually, @acassis if approved. Can this be pushed? This would significantly help testing it as boards and apps dont have to be removed from the PR every time. The rest of the less significant features, common API and RSSI/SNR can be implemented soon after. |
d70d248
to
ab612b6
Compare
Added a comment to both headers about this driver being currently experimental and breaking changes might happen in the near future. |
ab612b6
to
17f7213
Compare
Signed and changed message. Also includes [experimental] as tag. |
I suggest to follow the suggestion from @raiden00pl before merging this patch. The unified usersapce interface is very important for any os. |
@xiaoxiang781216 Yes thats the idea, however it could help to have this one pushed as experimental driver. So i can push a board and app which can be used for testing. Later when the common API is decided on, this driver can be updated and the [experimental] tag can be removed. (using a new PR). However, I'm fine with waiting as well if that works better for NuttX. It might be less efficient. |
The common API is discussed here #15856 |
@keever50 please create also the Documentation/ and include the screenshots about the SDR and NSH to let people get more information before using it. |
@acassis I can do that. |
Yes, sounds good! |
[Experimental] This adds a driver for the SX126x (SX1261 and SX1262) LoRa chips. All functions and definitions are coming directly from the DS SX1261-2 V2.1 datasheet. Signed-off-by: Kevin Witteveen (MartiniMarter) <[email protected]>
17f7213
to
c3a0b01
Compare
Documentation added |
Summary
This is a driver I am working on for the SX126x (SX1261 and SX1262) LoRa chips. NuttX only had the SX127x drivers before, which are the older variant LoRa chips which are becoming less common.
All functions and definitions are coming directly from the DS SX1261-2 V2.1 datasheet.
There are already existing SX126x drivers out there. For example, Semtech provides one themselves. There is also one written in Rust. This one is not vendor-driven and more free. Ofcourse also specifically made for NuttX in C.
Impact
This chip's output (RF) can communicate with the older variant chips, because it uses the same LoRa modulation. However, there are a few extra features to modulate LoRa beyond what the older variant can do.
For internal compatibility, it is about the same story. It got common features but also got new features.
The drivers in the other hand are not very identical. The chip is being handled differently than the older variant.
This driver allows a lot more IoT boards to be added to NuttX, because most of them using LoRa will use the new SX126x variants.
Testing
Deep testing has yet to be done. Other than there being one test function for development that fires when you open up the device.
This is mainly developed on Linux and a rak11310 board. This rak11310 board is also not yet supported by NuttX because it's main feature is the new LoRa chip. I may add this board to NuttX once it is ready. This might be useful for testing as well.
WIP!
Do not pull this before it is usable. Currently it is not integrated as a driver and purely a preview. I am asking for help or advice on how to take the next steps.
Currently it is missing:
And probably a few other things.
let me know what you think and if you want to help!