From 49ad7bdb79281e818a236be9bb3bf45a77db8f1e Mon Sep 17 00:00:00 2001 From: chrysn Date: Thu, 6 Jun 2013 02:03:12 +0200 Subject: [PATCH] use lwip provided time function --- coap_time.h | 16 ++++++++++------ config.h.lwip | 3 --- net.c | 2 -- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/coap_time.h b/coap_time.h index 2bc41e61..92ed6619 100644 --- a/coap_time.h +++ b/coap_time.h @@ -25,17 +25,21 @@ #ifdef WITH_LWIP -typedef int coap_tick_t; +#include +#include + +/* lwIP provides ms in sys_now */ +#define COAP_TICKS_PER_SECOND 1000 + +typedef uint32_t coap_tick_t; static inline void coap_ticks_impl(coap_tick_t *t) { - /* FIXME: defunct implementation to make things compile */ - *t = 0; + *t = sys_now(); } static inline void coap_clock_init_impl(void) { - #warning "cannot initialize clock" } #define coap_clock_init coap_clock_init_impl @@ -69,14 +73,14 @@ contiki_ticks_impl(coap_tick_t *t) { #define coap_ticks contiki_ticks_impl #endif /* WITH_CONTIKI */ -#if !defined(WITH_CONTIKI) && !defined(WITH_LWIP) +#ifdef WITH_POSIX typedef unsigned int coap_tick_t; #define COAP_TICKS_PER_SECOND 1024 /** Set at startup to initialize the internal clock (time in seconds). */ extern time_t clock_offset; -#endif /* neither contiki nor lwip */ +#endif /* WITH_POSIX */ #ifndef coap_clock_init static inline void diff --git a/config.h.lwip b/config.h.lwip index b5ff2a6c..88f6f90e 100644 --- a/config.h.lwip +++ b/config.h.lwip @@ -14,9 +14,6 @@ * building in */ #define HAVE_STRNLEN 1 -/* FIXME just a quick hack */ -#define COAP_TICKS_PER_SECOND 10 - #define COAP_RESOURCES_NOHASH #endif /* _CONFIG_H_ */ diff --git a/net.c b/net.c index d792ce77..4d22abbb 100644 --- a/net.c +++ b/net.c @@ -58,8 +58,6 @@ coap_free_node(coap_queue_t *node) { #include -time_t clock_offset; /* FIXME timing is currently ignored */ - static inline coap_queue_t * coap_malloc_node() { return (coap_queue_t *)memp_malloc(MEMP_COAP_NODE);