Skip to content
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

semtech-loramac: fix wrong behavior with RX windows #9618

Closed
wants to merge 1 commit into from

Conversation

jia200x
Copy link
Member

@jia200x jia200x commented Jul 20, 2018

Contribution description

Sometimes when receiving ACK (confirmed messages) with the Semtech LoRaMAC pkg, the RX_TIMEOUT event is called twice (one from this timer and also from this interrupt).

The reason is because the timer is used as an escape route if the longest possible LoRaWAN packet is not received in the whole process (around 3 seconds in EU868), and not for RX window timeout. This is not intended by the original LoRaMAC implementation (as seen here) and sometimes produces a wrong behavior in the MAC internal states.

This PR fixes that issue.

Also, another bug appeared when using the proper RX Symbol Timeout mechanism. The randr function from 0003-adapt-utilities-functions.patch had a wrong behavior due to int32_t casting and gave several numbers out of the given range, which caused unexpected behaviors in LoRaMAC. This is also addressed here (already fixed in #8864 )

Issues/PRs references

None so far

@jia200x jia200x changed the title Pr/loramac rx window fix semtech-loramac: fix wrong behavior with RX windows Jul 20, 2018
@jia200x jia200x requested review from dylad and aabadie July 20, 2018 14:32
@jia200x jia200x added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: LoRa Area: LoRa radio support labels Jul 20, 2018
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

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

Changes make sense (the same changes are also applied in #8864). I have one coding convention comment, see below and static tests fail because of trailing whitespaces.

I tested this PR on iotlab (st-lrwan1-1 node with TTN backend) but sometimes RX fails with DR5. I changed the time shift from 50ms to 22ms here and with that it works more reliably with both DR0 and DR5.


int32_t randr( int32_t min, int32_t max )
{
- return ( int32_t )rand1( ) % ( max - min + 1 ) + min;
-}
+ return (int32_t)random_uint32() % (max - min + 1) + min;
+};
+ return (int32_t) (random_uint32_range(0,max-min) + min);
Copy link
Contributor

Choose a reason for hiding this comment

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

put a space after the comma and around arithmetic operator:

(random_uint32_range(0, max - min) + min);

@jia200x jia200x force-pushed the pr/loramac_rx_window_fix branch from d8e1539 to 669c50b Compare August 13, 2018 11:44
@smlng
Copy link
Member

smlng commented Sep 20, 2018

@jia200x please address comments, so we can merge this - or is this outdated? Then close.

@jia200x
Copy link
Member Author

jia200x commented Sep 24, 2018

@smlng this PR is still valid. However, it will conflict with #8864 (they remove the timers from the driver, but this PR still fixes our current LoRaWAN integration)

@dylad
Copy link
Member

dylad commented Sep 24, 2018

@jia200x I thought #8864 was based on this PR. This is not the case ?

@jia200x
Copy link
Member Author

jia200x commented Sep 24, 2018

@dylad it was not based, but as far as I understand it already removes the timeout in the driver. I will test #8864 and merge it, and then check if the issue is still present

@dylad
Copy link
Member

dylad commented Sep 24, 2018

@jia200x Alright, let me know if #8864 doesn't solve your issue, I have some LoRa hardware to play here so I can test and merge too :)

@aabadie
Copy link
Contributor

aabadie commented Sep 25, 2018

but as far as I understand it already removes the timeout in the driver

#8864 doesn't remove the timeout in the driver but only in the package adaption. I think I did all the cleanup initially but removed it when I saw this PR. I can reapplied the change in #8864 if you want. I also think that #8864 is more priority since it improves quite some things and is opened for a long time now (~ 6 months).

@smlng
Copy link
Member

smlng commented Nov 30, 2018

@jia200x and @aabadie what's the state here, is this now outdated (and hence closable) or needs adaption?

@jia200x
Copy link
Member Author

jia200x commented Nov 30, 2018

@smlng I've still seen some issues regarded this. I prefer to keep it open

@smlng
Copy link
Member

smlng commented Nov 30, 2018

and I prefer to get it merged 😉 especially if the issue is still present and this is (kind of) a fix ... which might need some adaption, due to #8864 being merged

@aabadie
Copy link
Contributor

aabadie commented Nov 30, 2018

I prefer to keep it open

Do you plan to update this PR soon ? Some changes were applied in the last release but not all. Maybe it's worth having them merged ?

@jia200x
Copy link
Member Author

jia200x commented Nov 30, 2018

Do you plan to update this PR soon ? Some changes were applied in the last release but not all. Maybe it's worth having them merged ?

Yes, I agree. I will try to do it during the next days

@jia200x jia200x force-pushed the pr/loramac_rx_window_fix branch from 669c50b to 0232f14 Compare December 7, 2018 10:43
@jia200x
Copy link
Member Author

jia200x commented Dec 7, 2018

I confirm the original issue is not present anymore in master. The "RX Timeout" is set as expected from the Semtech LoRaMAC pkg.

Here's a picture of how the class A cycle look like on b-l072z-lrwan1. The first pulse is the transmission. The second and third pulses are the reception windows (RX2 is bigger than RX1, this comes from the MAC layer).

There are still some timing issues (related to #10545) which will be fixed as soon as that issue is solved.

@jia200x
Copy link
Member Author

jia200x commented Dec 7, 2018

I will then close this PR ;)

@jia200x jia200x closed this Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: LoRa Area: LoRa radio support Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants