diff --git a/Makefile.tools b/Makefile.tools
index 00a70a5..0583f3b 100644
--- a/Makefile.tools
+++ b/Makefile.tools
tools_ibeacon_SOURCES = tools/ibeacon.c monitor/bt.h \
monitor/mainloop.h monitor/mainloop.c \
src/shared/io.h src/shared/io-mainloop.c \
+ src/shared/timeout.h \
+ src/shared/timeout-mainloop.c \
src/shared/hci.h src/shared/hci.c \
src/shared/util.h src/shared/util.c \
src/shared/queue.h src/shared/queue.c
diff --git a/tools/ibeacon.c b/tools/ibeacon.c
index 093fba1..28967de 100644
--- a/tools/ibeacon.c
+++ b/tools/ibeacon.c
#include "monitor/mainloop.h"
#include "monitor/bt.h"
+#include "src/shared/timeout.h"
#include "src/shared/util.h"
#include "src/shared/hci.h"
static int urandom_fd;
static struct bt_hci *hci_dev;
-static void shutdown_timeout(int id, void *user_data)
+static bool shutdown_timeout(void *user_data)
{
- mainloop_remove_timeout(id);
-
mainloop_quit();
+
+ return false;
}
static void shutdown_complete(const void *data, uint8_t size, void *user_data)
{
unsigned int id = PTR_TO_UINT(user_data);
- shutdown_timeout(id, NULL);
+ timeout_remove(id);
+ mainloop_quit();
}
static void shutdown_device(void)
bt_hci_flush(hci_dev);
- id = mainloop_add_timeout(5000, shutdown_timeout, NULL, NULL);
+ id = timeout_add(5000, shutdown_timeout, NULL, NULL);
bt_hci_send(hci_dev, BT_HCI_CMD_LE_SET_ADV_ENABLE,
&enable, 1, NULL, NULL, NULL);