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
benpicco
left a comment
There was a problem hiding this comment.
A rebase would be good to only have the changes from this PR visible
886b1b0 to
9fe6dfe
Compare
|
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
gcoapmemo 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_bufwith 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_bufin: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