From 8e1262c7f80042f52b90d3388fe137ee2a6997d8 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Mon, 20 Nov 2017 11:37:41 +0100 Subject: [PATCH] change to ubus timeout --- src/include/datastorage.h | 2 ++ src/main.c | 1 + src/utils/ubus.c | 16 ++-------------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/include/datastorage.h b/src/include/datastorage.h index 1f50f6d..0a66b3f 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -37,6 +37,8 @@ struct time_config_s { time_t update_hostapd; }; +struct time_config_s timeout_config; + // ---------------- Global variables ---------------- struct probe_metric_s dawn_metric; diff --git a/src/main.c b/src/main.c index b147250..e26efbc 100644 --- a/src/main.c +++ b/src/main.c @@ -147,6 +147,7 @@ int main(int argc, char **argv) { gcrypt_set_key_and_iv(shared_key, iv); struct time_config_s time_config = uci_get_time_config(); + timeout_config = time_config; // TODO: Refactor... if (pthread_mutex_init(&list_mutex, NULL) != 0) { printf("\n mutex init failed\n"); diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 923424f..7c75645 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -603,20 +603,8 @@ void *update_clients_thread(void *arg) { } void update_hostapd_sockets(struct uloop_timeout *t) { - //uloop_init(); - //time_t time_update_hostapd = *(time_t *) arg; - - //printf("Update hostapd thread with time: %lu\n", time_update_hostapd); - //const char *ubus_socket = NULL; - //ctx_hostapd = ubus_connect(ubus_socket); - //ubus_add_uloop(ctx_hostapd); - //uloop_run(); - uloop_timeout_set(&hostapd_timer, 1000); - -// while (1) { - subscribe_to_hostapd_interfaces(hostapd_dir_glob); -// sleep(time_update_hostapd); -// } + uloop_timeout_set(&hostapd_timer, timeout_config.update_hostapd); + subscribe_to_hostapd_interfaces(hostapd_dir_glob); } void del_client_all_interfaces(const uint8_t *client_addr, uint32_t reason, uint8_t deauth, uint32_t ban_time) {