From 67fcaba74c09befedd1f16bb5f2bfeffaf513458 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Sat, 26 Aug 2017 23:58:10 +0200 Subject: [PATCH] Add print function --- src/include/datastorage.h | 1 + src/storage/datastorage.c | 18 ++++++++++++++++++ src/utils/ubus.c | 1 + 3 files changed, 20 insertions(+) diff --git a/src/include/datastorage.h b/src/include/datastorage.h index e9d1aa3..3abc942 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -90,6 +90,7 @@ struct ap_s ap_array[ARRAY_AP_LEN]; pthread_mutex_t ap_array_mutex; ap insert_to_ap_array(ap entry); +void print_ap_array(); // Array #define ARRAY_CLIENT_LEN 1000 diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index 23d8a34..20f0ee3 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -28,6 +28,8 @@ void ap_array_insert(ap entry); ap ap_array_delete(ap entry); +void print_ap_entry(ap entry); + int probe_entry_last = -1; int client_entry_last = -1; int ap_entry_last = -1; @@ -812,4 +814,20 @@ void print_client_array() { print_client_entry(client_array[i]); } printf("------------------\n"); +} + +void print_ap_entry(ap entry) { + char mac_buf_ap[20]; + + sprintf(mac_buf_ap, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.bssid_addr)); + printf("bssid_addr: %s, freq: %d, ht: %d, vht: %d\n", + mac_buf_ap, entry.freq, entry.ht, entry.vht); +} + +void print_ap_array() { + printf("--------APs------\n"); + for (int i = 0; i <= ap_entry_last; i++) { + print_ap_entry(ap_array[i]); + } + printf("------------------\n"); } \ No newline at end of file diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 59f69b6..0cfee43 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -508,6 +508,7 @@ static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_ char *str = blobmsg_format_json(msg, true); send_string_enc(str); print_client_array(); + print_ap_array(); } static int ubus_get_clients() {