static void hci_connection_timestamp(hci_connection_t *connection){ #ifdef HAVE_TIME gettimeofday(&connection->timestamp, NULL); #endif #ifdef HAVE_TICK connection->timestamp = embedded_get_ticks(); #endif }
static void hci_connection_timeout_handler(timer_source_t *timer){ hci_connection_t * connection = (hci_connection_t *) linked_item_get_user(&timer->item); #ifdef HAVE_TIME struct timeval tv; gettimeofday(&tv, NULL); if (tv.tv_sec >= connection->timestamp.tv_sec + HCI_CONNECTION_TIMEOUT_MS/1000) { // connections might be timed out hci_emit_l2cap_check_timeout(connection); } #endif #ifdef HAVE_TICK if (embedded_get_ticks() > connection->timestamp + embedded_ticks_for_ms(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); }
static void msleep(uint32_t delay) { uint32_t wake = embedded_get_ticks() + delay / hal_tick_get_tick_period_in_ms(); while (wake > embedded_get_ticks()); }