From f2c6f15dfc095100a990a010315de263065d42b6 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 12 Dec 2017 10:42:50 +0100 Subject: [PATCH] add a lowest rssi --- files/dawn.config | 4 +++- src/include/datastorage.h | 4 +++- src/storage/datastorage.c | 3 ++- src/utils/dawn_uci.c | 22 +++++++++++++++++++--- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/files/dawn.config b/files/dawn.config index 55b6b32..83e67c2 100644 --- a/files/dawn.config +++ b/files/dawn.config @@ -24,8 +24,10 @@ config settings metric option no_ht_support '0' option no_vht_support '0' option rssi '10' + option low_rssi '-500' option freq '50' option chan_util '50' option max_chan_util '150' - option min_rssi '-60' + option rssi_val '-60' + option low_rssi_val '-79' option min_probe_count '2' diff --git a/src/include/datastorage.h b/src/include/datastorage.h index 93f845f..6371c6c 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -23,10 +23,12 @@ struct probe_metric_s { int no_ht_support; int no_vht_support; int rssi; + int low_rssi; int freq; int chan_util; int max_chan_util; - int min_rssi; + int rssi_val; + int low_rssi_val; int min_probe_count; }; diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index 206c594..5f4cfb2 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -79,7 +79,8 @@ int eval_probe_metric(struct probe_entry_s probe_entry) { } score += (probe_entry.freq > 5000) ? dawn_metric.freq : 0; - score += (probe_entry.signal >= dawn_metric.min_rssi) ? dawn_metric.rssi : 0; + score += (probe_entry.signal >= dawn_metric.rssi_val) ? dawn_metric.rssi : 0; + score += (probe_entry.signal <= dawn_metric.low_rssi_val) ? dawn_metric.low_rssi : 0; printf("SCORE: %d\n", score); print_probe_entry(probe_entry); diff --git a/src/utils/dawn_uci.c b/src/utils/dawn_uci.c index 186578c..687f3dc 100644 --- a/src/utils/dawn_uci.c +++ b/src/utils/dawn_uci.c @@ -142,13 +142,13 @@ struct probe_metric_s uci_get_dawn_metric() { if (ptr.o->type == UCI_TYPE_STRING) ret.chan_util = atoi(ptr.o->v.string); - char tmp_min_rssi[] = "dawn.metric.min_rssi"; - if (uci_lookup_ptr(c, &ptr, tmp_min_rssi, 1) != UCI_OK) { + char tmp_rssi_val[] = "dawn.metric.rssi_val"; + if (uci_lookup_ptr(c, &ptr, tmp_rssi_val, 1) != UCI_OK) { uci_perror(c, "uci_get_daw_metric Error"); return ret; } if (ptr.o->type == UCI_TYPE_STRING) - ret.min_rssi = atoi(ptr.o->v.string); + ret.rssi_val = atoi(ptr.o->v.string); char tmp_max_chan_util[] = "dawn.metric.max_chan_util"; if (uci_lookup_ptr(c, &ptr, tmp_max_chan_util, 1) != UCI_OK) { @@ -168,6 +168,22 @@ struct probe_metric_s uci_get_dawn_metric() { if (ptr.o->type == UCI_TYPE_STRING) ret.min_probe_count = atoi(ptr.o->v.string); + char tmp_low_rssi[] = "dawn.metric.low_rssi"; + if (uci_lookup_ptr(c, &ptr, tmp_low_rssi, 1) != UCI_OK) { + uci_perror(c, "uci_get_daw_metric Error"); + return ret; + } + if (ptr.o->type == UCI_TYPE_STRING) + ret.low_rssi = atoi(ptr.o->v.string); + + char tmp_low_rssi_val[] = "dawn.metric.low_rssi_val"; + if (uci_lookup_ptr(c, &ptr, tmp_low_rssi_val, 1) != UCI_OK) { + uci_perror(c, "uci_get_daw_metric Error"); + return ret; + } + if (ptr.o->type == UCI_TYPE_STRING) + ret.low_rssi_val = atoi(ptr.o->v.string); + printf("Loaded metric: %d\n", ret.min_probe_count); uci_free_context(c);