mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-25 08:31:04 +03:00
adjust client and server example to relative timers
This commit is contained in:
1 parent
1df1ef5483
commit
b116fc6d79
2 files changed
+8
-8
No files matched your search
+4
-4
@@ -1112,15 +1112,15 @@ main(int argc, char **argv) {
|
||||
nextpdu = coap_peek_next( ctx );
|
||||
|
||||
coap_ticks(&now);
|
||||
while ( nextpdu && nextpdu->t <= now ) {
|
||||
while (nextpdu && nextpdu->t <= now - ctx->sendqueue_basetime) {
|
||||
coap_retransmit( ctx, coap_pop_next( ctx ));
|
||||
nextpdu = coap_peek_next( ctx );
|
||||
}
|
||||
|
||||
if (nextpdu && nextpdu->t < min(obs_wait ? obs_wait : max_wait, max_wait)) {
|
||||
if (nextpdu && nextpdu->t < min(obs_wait ? obs_wait : max_wait, max_wait) - now) {
|
||||
/* set timeout if there is a pdu to send */
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (nextpdu->t - now) / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_usec = ((nextpdu->t) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (nextpdu->t) / COAP_TICKS_PER_SECOND;
|
||||
} else {
|
||||
/* check if obs_wait fires before max_wait */
|
||||
if (obs_wait && obs_wait < max_wait) {
|
||||
|
||||
+4
-4
@@ -398,15 +398,15 @@ main(int argc, char **argv) {
|
||||
nextpdu = coap_peek_next( ctx );
|
||||
|
||||
coap_ticks(&now);
|
||||
while ( nextpdu && nextpdu->t <= now ) {
|
||||
while (nextpdu && nextpdu->t <= now - ctx->sendqueue_basetime) {
|
||||
coap_retransmit( ctx, coap_pop_next( ctx ) );
|
||||
nextpdu = coap_peek_next( ctx );
|
||||
}
|
||||
|
||||
if ( nextpdu && nextpdu->t <= now + COAP_RESOURCE_CHECK_TIME ) {
|
||||
if ( nextpdu && nextpdu->t <= COAP_RESOURCE_CHECK_TIME ) {
|
||||
/* set timeout if there is a pdu to send before our automatic timeout occurs */
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (nextpdu->t - now) / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_usec = ((nextpdu->t) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (nextpdu->t) / COAP_TICKS_PER_SECOND;
|
||||
timeout = &tv;
|
||||
} else {
|
||||
tv.tv_usec = 0;
|
||||
|
||||
Reference in new issue
Block a user