From 5f26aadcab8f436e93405c548f38b8be3e2e305b Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 23 Dec 2015 16:41:44 +0100 Subject: [PATCH] implement l2cap timeout check for HAVE_TIME_MS --- src/hci.c | 9 +++++++++ src/hci.h | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/hci.c b/src/hci.c index 8e397d654..65c6c6e73 100644 --- a/src/hci.c +++ b/src/hci.c @@ -207,6 +207,12 @@ static void hci_connection_timeout_handler(timer_source_t *timer){ // connections might be timed out hci_emit_l2cap_check_timeout(connection); } +#endif +#ifdef HAVE_TIME_MS + if (run_loop_get_time_ms() > connection->timestamp + HCI_CONNECTION_TIMEOUT_MS){ + // connections might be timed out + hci_emit_l2cap_check_timeout(connection); + } #endif run_loop_set_timer(timer, HCI_CONNECTION_TIMEOUT_MS); run_loop_add_timer(timer); @@ -219,6 +225,9 @@ static void hci_connection_timestamp(hci_connection_t *connection){ #ifdef HAVE_TICK connection->timestamp = embedded_get_ticks(); #endif +#ifdef HAVE_TIME_MS + connection->timestamp = run_loop_get_time_ms(); +#endif } diff --git a/src/hci.h b/src/hci.h index dc4a12266..d70bb358e 100644 --- a/src/hci.h +++ b/src/hci.h @@ -386,9 +386,12 @@ typedef struct { struct timeval timestamp; #endif #ifdef HAVE_TICK - uint32_t timestamp; // timeout in system ticks + uint32_t timestamp; // timestamp in system ticks #endif - +#ifdef HAVE_TIME_MS + uint32_t timestamp; // timestamp in ms +#endif + // ACL packet recombination - PRE_BUFFER + ACL Header + ACL payload uint8_t acl_recombination_buffer[HCI_INCOMING_PRE_BUFFER_SIZE + 4 + HCI_ACL_BUFFER_SIZE]; uint16_t acl_recombination_pos;