coap-client.c: Cleanup following observe cancellation

Delay exit briefly checking if there are any response packets following
observe cancellation and process as appropriate.

If multiple observes are outstanding, cancelling them using CON will
cause issues as NSTART limit is hit.  The server then does not know
about all of the cancellations.

Also, this can allow the server to properly shutdown observe
activity when blocks are used.
This commit is contained in:
Jon Shallow authored and obgm committed 2022-10-14 08:44:21 +02:00
1 parent d09d56860f
commit de369eb7c7
1 file changed
+5
+5
View File
@@ -1826,6 +1826,7 @@ main(int argc, char **argv) {
for (i = 0; i < tracked_tokens_count; i++) {
if (tracked_tokens[i].observe) {
coap_cancel_observe(session, tracked_tokens[i].token, msgtype);
coap_io_process(ctx, COAP_IO_NO_WAIT);
}
}
doing_observe = 0;
@@ -1834,6 +1835,10 @@ main(int argc, char **argv) {
/* make sure that the obs timer does not fire again */
obs_ms = 0;
obs_seconds = 0;
for (i = 0; i < 5 ; i++) {
/* Make sure all is flushed out */
coap_io_process(ctx, 100);
}
} else {
obs_ms -= result;
}