-
Notifications
You must be signed in to change notification settings - Fork 2k
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
pkg/semtech-loramac: rework interaction with the MAC #11541
pkg/semtech-loramac: rework interaction with the MAC #11541
Conversation
5344c0e
to
f6290f3
Compare
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.
Some initial comments.
@@ -839,7 +837,7 @@ uint8_t semtech_loramac_send(semtech_loramac_t *mac, uint8_t *data, uint8_t len) | |||
return SEMTECH_LORAMAC_NOT_JOINED; | |||
} | |||
|
|||
/* Correctly set the caller pid */ | |||
/* Correctly set the sender thread pid */ |
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 think the comment should be inline with the variable names.
@@ -110,6 +110,7 @@ typedef struct { | |||
typedef struct { | |||
mutex_t lock; /**< loramac access lock */ | |||
uint8_t caller_pid; /**< pid of caller thread */ |
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.
Maybe it makes more sense if this is tx_pid
if I understand right this thread is in charge of join procedure and sending packets, so tx. Would be more inline with rx_pid (receiver thread)
@@ -95,12 +95,6 @@ | |||
* return 1; | |||
* } | |||
* | |||
* /* 5. wait for any potentially received data */ |
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.
Document starting and usage of a receiving thread.
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.
Done
Tested it does work and no deadlock, I confirm it fixes #11530. @ParksProjets can you confirm it fixes the issue on your side? |
@fjmolinas, I found a problem with the link_check feature. The current refactoring is breaking it. I know how to fix it simply but now that I'm thinking of it, I'd like to try a deeper refactoring of the interaction between the MAC events (MCPS confirm/indication, MLME confirm/indication) and the event loop. I hope this will simplify a bit more all this mess. |
@fjmolinas, I've reworked this the PR the way we discussed IRL and now everything is working (including link_check info and received ACKs). |
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 tested that your changes regarding link_check and ack are working. A minor comment on a border case.
* } | ||
* ``` | ||
* - Finally, this thread can be started after the join procedure |
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.
Is this a requirement?
_semtech_loramac_send(mac, NULL, 0); | ||
mac->port = prev_port; | ||
} | ||
else if (indication->RxData) { |
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.
There is a border case where if a downlink is received when a cnf messaged is sent the indication-AckReceived
doesn't go up to the application. Although this doesn't matter in class A, in class B or C this could be mixed. If using if
instead of elseif
this would work
90d8087
to
79fca24
Compare
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.
@aabadie Everyhting is looking good. I see all my comments have been addressed, can you squas?
79fca24
to
d7737a5
Compare
Done! |
Note that this PR will conflicts with #8855 once merged but I prefer this one being merged first. |
@aabadie somehow before the squash I oversaw that |
Noted! |
I think I already tried both:
For me it's a problem of missing RAM, and waspmote was already very short. Adding a second thread is too much for it. |
What about simply disabling RX thread ? |
I think that would be an acceptable compromise. The previous support had a bug so if fixing it adds some memory usage then I think it's okay to drop some feature support for waspmote, which was already buggy in master. :) |
79d5fac
to
8003567
Compare
8003567
to
c721efe
Compare
@fjmolinas, I made all RX related code optional using a pseudo-module |
c721efe
to
9da50dd
Compare
@aabadie everything is good! This commit need to be discarded though |
Now TX notification messages are only sent after mcps confirm event. RX message notification message is sent after mcps indication
This can highly happen when no message is received from the network after a send
9da50dd
to
56fb257
Compare
Done! |
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.
ACK! Lets wait for murdock ot be green!
Go! |
Great! Thanks a lot for reviewing @fjmolinas :) |
- with RIOT-OS#11541 TX notification are only sent after mcps confirm event this will send a SEMTECH_LORAMAC_TX_DONE instaed of SEMTECH_LORAMAC_TX_OK.
- with RIOT-OS#11541 TX notification are only sent after mcps confirm event this will send a SEMTECH_LORAMAC_TX_DONE instead of SEMTECH_LORAMAC_TX_OK.
- with RIOT-OS#11541 TX notification are only sent after mcps confirm event this will send a SEMTECH_LORAMAC_TX_DONE instead of SEMTECH_LORAMAC_TX_OK. (cherry picked from commit cdf687c)
- with RIOT-OS#11541 TX notification are only sent after mcps confirm event this will send a SEMTECH_LORAMAC_TX_DONE instead of SEMTECH_LORAMAC_TX_OK.
- with RIOT-OS#11541 TX notification are only sent after mcps confirm event this will send a SEMTECH_LORAMAC_TX_DONE instead of SEMTECH_LORAMAC_TX_OK.
Contribution description
This is another attempt to fix #11530.
It follows the suggestion of @ParksProjets in #11535 (comment):
I have tested this PR using OTAA, ABP activations and with CONFIRMED and UNCONFIRMED messages.
Everything is working as expected.
The only small thing is the link check which is not working correctly but it's already the case in master I think.
Finally, I also had to update the
examples/lorawan
application and doxygen documentation to avoid potential lock of autonomous application. Maybeexamples/lorawan
could be later refactored with downling messages better handled or adapted for class C devices.Testing procedure
Run
tests/pkg_semtech-loramac
, send messages from the device, send messages from the network using CONFIRMED/UNCONFIRMED (cnf/uncnf
option ofloramac tx
: everything should work, with this PR, the application doesn't block.Issues/PRs references
fixes #11530, closes #11535 (cleaner alternative)