-
Notifications
You must be signed in to change notification settings - Fork 19
Implement radio traits #248
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
Conversation
I hope you don't mind me pushing, just wanted to run rustfmt to remove some minor formatting difference from the diff. |
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 guess a lot of this depends on the discussion happening in rust-iot/radio-hal#24, I'm subscribed to that PR now so I'll keep an eye on that as well 👍
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.
Looks good so far!
|
||
/// Timer for delays. | ||
#[derive(Debug)] | ||
pub struct Tim2 { |
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.
Tim2 should probably be made more general as well, that can be done later though.
hal/src/subghz/sx126x.rs
Outdated
const IRQ_CFG: CfgIrq = CfgIrq::new() | ||
.irq_enable_all(Irq::RxDone) | ||
.irq_enable_all(Irq::Timeout) | ||
.irq_enable_all(Irq::TxDone) | ||
.irq_enable_all(Irq::Err); | ||
|
||
const PREAMBLE_LEN: u16 = 5 * 8; | ||
const TX_BUF_OFFSET: u8 = 0; | ||
const RX_BUF_OFFSET: u8 = 128; | ||
|
||
const PA_CONFIG: PaConfig = PaConfig::LP_10; | ||
const TX_PARAMS: TxParams = TxParams::LP_10.set_ramp_time(RampTime::Micros40); | ||
|
||
const TCXO_MODE: TcxoMode = TcxoMode::new() | ||
.set_txco_trim(TcxoTrim::Volts1pt7) | ||
.set_timeout(Timeout::from_millis_sat(10)); |
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.
What is the future plan for this? Leave it opinionated, make it configurable?
I am trying to keep the HAL generic, if opinionated this file would make more sense as a separate crate as it does not depend on the private types in the HAL.
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'll see if I can make this configurable! I could include these settings in the Sx126x
struct. Would default settings be acceptable (with a builder pattern), or should the user specify all settings?
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'll see if I can make this configurable! I could include these settings in the Sx126x struct. Would default settings be acceptable (with a builder pattern), or should the user specify all settings?
I generally like to set things to sane defaults, and give the user the option to modify them.
One thing I try to do is make it so configuration can be made a const
, because most applications will have a static configuration that doesn't need to be changed, and it is helpful to enable const
for that usecase.
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 updated it, is this better? I wasn't sure what to do with TX_BUF_OFFSET
and RX_BUF_OFFSET
, are those configurable? Also not sure what the default CalibrateImage
should be. For LoRaWAN, there is EU863-870
, US902-928
, CN779-787
, EU433
, etc.
I cannot seem to get the LoRa-E5 Dev Board to receive a Join-Accept message from The Things Network, even though the gateway that transmits it is right next to it. Do you see anything that could be wrong with the |
Do you have some sample code I could run? I don't have a gateway nearby, but I could give it a shot. |
You could try the example in this repository, but it uses the EUIs from the device on my TTN account, so you won't see much unless it actually receives the Join-Accept. I can verify if the Join-Accept is being sent, though. |
Looks like I destroyed the commit order there, sorry. 😬 |
This is a work in progress implementation of the radio traits for the SX126x LoRa transceiver. These traits will allow easy interoperability with crates that use radios, such as https://github.com/Tortoaster/lorawan-device.