-
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
sys/net/application_layer/gcoap: fix Observe notifications correlation #20684
sys/net/application_layer/gcoap: fix Observe notifications correlation #20684
Conversation
Of course the Observe notification must be sent from the same address as well ... RIOT/sys/net/application_layer/gcoap/gcoap.c Lines 1824 to 1837 in 230df5f
|
977ce56
to
b7ce179
Compare
Depends on #20711 now due to aux tx local supply in |
40bbd42
to
81fd3e7
Compare
for better testing I added an |
cd72b36
to
886b1b0
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.
A rebase would be good to only have the changes from this PR visible
886b1b0
to
9fe6dfe
Compare
Only one observer per resource is supported:
Because, given a request, identifying a resource we look for only one RIOT/sys/net/application_layer/gcoap/gcoap.c Line 670 in c2efa3e
|
Maybe there is a CoAP way to tell the client, that Observe cannot be honored for the reason that another client is observing the resource currently. |
Please squash directly |
From RFC7641
|
33a979c
to
c898d75
Compare
Looks like |
I executed
|
Had to delete |
Contribution description
When a CONfirmable CoAP request with an Observe option is sent, the sending client has to store the CoAP token to match multiple responses from the server sending Observe notifications.
The
gcoap
memo is not cleared when the 2.xx response for the client registration contains an Observe option.RIOT/sys/net/application_layer/gcoap/gcoap.c
Lines 521 to 531 in 3f41494
For a confirmable request with a token length >0, the problem happens right before, where the resend buffer is released by actually overwriting the first byte of the request header in
pdu_buf
with 0. The first byte contains the token length which is required to match in:RIOT/sys/net/application_layer/gcoap/gcoap.c
Lines 888 to 914 in 3f41494
There, the overwritten request header is accessed in
gcoap_request_memo_get_hdr()
.RIOT/sys/include/net/gcoap.h
Lines 1182 to 1190 in 3f41494
Solution:
When a response is received, the retransmission buffer is released, but before the header is copied to
hdr_buf
in:RIOT/sys/include/net/gcoap.h
Lines 809 to 833 in 3f41494
Testing procedure
Internal project. CoAP Observe is not so well tested. I hope the explanation makes sense.
In
examples/gcoap/client.c
:RIOT/examples/gcoap/client.c
Lines 397 to 408 in 3f41494
the notification is sent right after the registration was sent. I have not tried that.
Issues/PRs references
Depends on and includes #20711