adjust client and server example to relative timers

This commit is contained in:
Olaf Bergmann committed 2013-11-06 22:34:48 +01:00
1 parent 1df1ef5483
commit b116fc6d79
2 files changed
+8 -8

No files matched your search

+4 -4
View File
@@ -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
View File
@@ -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;