Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

added preamble deadline for proper LoRaWAN RX1+RX2 reception #33

Merged
merged 3 commits into from
Oct 20, 2023

Conversation

ilya-epifanov
Copy link
Contributor

No description provided.

@ilya-epifanov
Copy link
Contributor Author

Used by lora-rs/lora-rs#142

@lucasgranberg
Copy link
Collaborator

We have to wait for ceekdee to come back after October 23 for review. I do not understand this code enough to make a decision.

#29 (comment)

@ilya-epifanov
Copy link
Contributor Author

ilya-epifanov commented Oct 9, 2023

Basically it allows you to run the IRQ loop just until the preamble (or header) is received. Allows LoRaWAN RX1/RX2 windows to be properly implemented. As per spec the receiver should continue receiving the reply using RX1 settings if it's got the preamble in time, even if the RX1 window is already closed.
This allows, for example, joining with high SF, as the reply takes more than a second to receive, which is longer than the window duration.

Copy link
Member

@lulf lulf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look like they keep the existing mode to me, I have one comment on the tx path regarding the unreachable state.

Err(err) => {
self.radio_kind.ensure_ready(self.radio_mode).await?;
self.radio_kind.set_standby().await?;
self.radio_mode = RadioMode::Standby;
Err(err)
}
Ok(_) => unreachable!(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this is actually unreachable. What if you start an RX before, drop the future, and then try to TX? Couldn't the irq trigger with TargetIrqState::Preamble in that case? Feels safer if this was somewhat ignored or returned an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process_irq will only return TargetIrqState::PreambleReceived if explicitly asked to. In this case it's asked to only return TargetIrqState::Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking again I see what you mean. Looks good to me then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about changing the API to be a little bit more type-stateful. That'd resolve some issues like device being left in an inconsistent state after cancellation of a future. Also, it'd remove confustion between tx interrupts and rx interrupts.

Copy link
Collaborator

@lucasgranberg lucasgranberg Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a proper chat about thr overall layout of this crate. If you have the time you could join us at #public-lora-wan-rs:matrix.org

Copy link
Member

@lulf lulf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm these changes works on my lora-discovery board (although requiring some custom configuration for joining to work in embassy, but it is likely unrelated to this PR since it is required on the main branch too).

@lucasgranberg lucasgranberg merged commit 5654b53 into embassy-rs:main Oct 20, 2023
@lucasgranberg
Copy link
Collaborator

thank you @ilya-epifanov!

@ilya-epifanov ilya-epifanov deleted the preamble-deadline branch November 17, 2023 21:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants