// set timer static void embedded_set_timer(timer_source_t *ts, uint32_t timeout_in_ms){ #ifdef HAVE_TICK uint32_t ticks = embedded_ticks_for_ms(timeout_in_ms); if (ticks == 0) ticks++; // time until next tick is < hal_tick_get_tick_period_in_ms() and we don't know, so we add one ts->timeout = system_ticks + 1 + ticks; #endif #ifdef HAVE_TIME_MS ts->timeout = hal_time_ms() + timeout_in_ms + 1; #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); }
// set timer void embedded_set_timer(timer_source_t *ts, uint32_t timeout_in_ms){ uint32_t ticks = embedded_ticks_for_ms(timeout_in_ms); if (ticks == 0) ticks++; ts->timeout = system_ticks + ticks; }