Use SNR and estimated throughput for BSS scoring 08/262708/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Wed, 18 Aug 2021 08:02:06 +0000 (17:02 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Wed, 18 Aug 2021 08:02:06 +0000 (17:02 +0900)
Change-Id: Ie80ad47361166cd3b22a430111dda5c91791dca2
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
gsupplicant/supplicant.c

index f4abb07..906f0ea 100755 (executable)
@@ -304,6 +304,8 @@ struct g_supplicant_bss {
        dbus_bool_t hs20;
        unsigned char country_code[COUNTRY_CODE_LENGTH];
        GSupplicantPhy_mode phy_mode;
+       dbus_int16_t snr;
+       dbus_uint32_t est_throughput;
 #endif
        unsigned int wps_capabilities;
 #if defined TIZEN_EXT
@@ -443,6 +445,8 @@ struct g_connman_bssids {
        int score_assoc_reject;
        int score_frequency;
        int score_strength;
+       int score_snr;
+       int score_est_throughput;
 #endif
        int ins_score;
 };
@@ -2110,8 +2114,22 @@ static int calculate_score_strength(dbus_int16_t strength)
        return score;
 }
 
+static int calculate_score_est_throughput(dbus_uint32_t est_throughput)
+{
+       int score = 0;
+
+       if (est_throughput >= 10000)
+               score = est_throughput / 10000;
+
+       if (score > 40)
+               score = 40;
+
+       return score;
+}
+
 static int calculate_score(bool is_last_connected, uint16_t assoc_reject_cnt,
-               dbus_int16_t strength, dbus_uint16_t frequency)
+               dbus_uint16_t frequency, dbus_int16_t strength,
+               dbus_int16_t snr, dbus_uint32_t est_throughput)
 {
        int score = 0;
 
@@ -2119,6 +2137,8 @@ static int calculate_score(bool is_last_connected, uint16_t assoc_reject_cnt,
        score += calculate_score_assoc_reject(assoc_reject_cnt);
        score += calculate_score_frequency(strength, frequency);
        score += calculate_score_strength(strength);
+       score += (int)snr;
+       score += calculate_score_est_throughput(est_throughput);
 
        return score;
 }
@@ -2151,10 +2171,13 @@ static void update_bssid_list(gpointer key, gpointer value, gpointer user_data)
                bssids->score_assoc_reject = calculate_score_assoc_reject(bssids->assoc_reject_cnt);
                bssids->score_frequency = calculate_score_frequency(bss->signal, bssids->frequency);
                bssids->score_strength = calculate_score_strength(bssids->strength);
+               bssids->score_snr = (int)bss->snr;
+               bssids->score_est_throughput = calculate_score_est_throughput(bss->est_throughput);
 #endif
 
                bssids->ins_score = calculate_score(bssids->is_last_connected,
-                       bssids->assoc_reject_cnt, bssids->frequency, bss->signal);
+                       bssids->assoc_reject_cnt, bssids->frequency, bss->signal,
+                       bss->snr, bss->est_throughput);
 
                bssid_data->bssid_list = g_slist_append(bssid_data->bssid_list, bssids);
        } else
@@ -2541,12 +2564,13 @@ static bool update_best_bss(GSupplicantNetwork *network,
        score_new = calculate_score(
                compare_bssid(bss->bssid, network->last_connected_bssid),
                get_assoc_reject_cnt(network->assoc_reject_table, bss->bssid),
-               bss->frequency, bss->signal);
+               bss->frequency, bss->signal, bss->snr, bss->est_throughput);
 
        score_best = calculate_score(
                compare_bssid(network->best_bss->bssid, network->last_connected_bssid),
                get_assoc_reject_cnt(network->assoc_reject_table, network->best_bss->bssid),
-               network->best_bss->frequency, network->best_bss->signal);
+               network->best_bss->frequency, network->best_bss->signal,
+               network->best_bss->snr, network->best_bss->est_throughput);
 
        if (score_new > score_best) {
                SUPPLICANT_DBG("new[" MACSTR "][%u] : best[" MACSTR "][%u]",
@@ -3240,6 +3264,17 @@ static void bss_property(const char *key, DBusMessageIter *iter,
                dbus_bool_t hs20 = FALSE;
                dbus_message_iter_get_basic(iter, &hs20);
                bss->hs20 = hs20;
+       } else if (g_strcmp0(key, "SNR") == 0) {
+               dbus_int16_t snr = 0;
+
+               dbus_message_iter_get_basic(iter, &snr);
+               bss->snr = snr;
+       } else if (g_strcmp0(key, "EstThroughput") == 0) {
+               dbus_uint32_t est_throughput = 0;
+
+               dbus_message_iter_get_basic(iter, &est_throughput);
+               if (est_throughput != 0)
+                       bss->est_throughput = est_throughput;
 #endif
        } else if (g_strcmp0(key, "IEs") == 0)
                bss_process_ies(iter, bss);
@@ -7800,7 +7835,7 @@ int g_supplicant_interface_connect(GSupplicantInterface *interface,
                                        interface_add_network_result, data,
                                        interface);
                }
-        }
+       }
 
        if (ret < 0) {
                g_free(data->path);