Use the default logic when not using INS 29/267429/2
authorJaehyun Kim <jeik01.kim@samsung.com>
Fri, 3 Dec 2021 09:48:15 +0000 (18:48 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Mon, 6 Dec 2021 09:50:06 +0000 (18:50 +0900)
1. Use signal strength for bssid sorting
2. Send a signal when service->connect_reason is changed

Change-Id: Ia7b1598f9de34440ae1cad5b773784ca769603e4
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
gsupplicant/supplicant.c
src/network.c
src/service.c

index 427c8ca..6c997ba 100755 (executable)
@@ -1999,6 +1999,7 @@ static gchar *convert_bssid_to_str(unsigned char *bssid)
        return g_string_free(bssid_str, FALSE);
 }
 
+#if defined TIZEN_EXT_INS
 static void count_assoc_reject(gpointer data, gpointer user_data)
 {
        time_t assoc_reject_time = GPOINTER_TO_INT(data);
@@ -2054,7 +2055,6 @@ static uint16_t get_assoc_reject_cnt(GHashTable *assoc_reject_table, unsigned ch
        return assoc_count.assoc_count;
 }
 
-#if defined TIZEN_EXT_INS
 static int calculate_score_last_connected_bssid(bool is_last_connected)
 {
        int score = 0;
@@ -2133,14 +2133,12 @@ static int calculate_score(bool is_last_connected, uint16_t assoc_reject_cnt,
 {
        int score = 0;
 
-#if defined TIZEN_EXT_INS
        score += calculate_score_last_connected_bssid(is_last_connected);
        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);
-#endif
 
        return score;
 }
@@ -2164,23 +2162,23 @@ static void update_bssid_list(gpointer key, gpointer value, gpointer user_data)
 
                bssids->frequency = bss->frequency;
 
+#if defined TIZEN_EXT_INS
                bssids->assoc_reject_cnt = get_assoc_reject_cnt(bssid_data->assoc_reject_table, bssids->bssid);
-
                bssids->is_last_connected = compare_bssid(bssids->bssid, bssid_data->last_connected_bssid);
 
-#if defined TIZEN_EXT_INS
                bssids->score_last_connected_bssid = calculate_score_last_connected_bssid(bssids->is_last_connected);
                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,
                        bss->snr, bss->est_throughput);
-
+#else
+               bssids->ins_score = bss->signal;
+#endif
                bssid_data->bssid_list = g_slist_append(bssid_data->bssid_list, bssids);
        } else
                SUPPLICANT_DBG("Failed to allocate memory");
@@ -2563,6 +2561,7 @@ static bool update_best_bss(GSupplicantNetwork *network,
                return true;
        }
 
+#if defined TIZEN_EXT_INS
        score_new = calculate_score(
                compare_bssid(bss->bssid, network->last_connected_bssid),
                get_assoc_reject_cnt(network->assoc_reject_table, bss->bssid),
@@ -2573,6 +2572,10 @@ static bool update_best_bss(GSupplicantNetwork *network,
                get_assoc_reject_cnt(network->assoc_reject_table, network->best_bss->bssid),
                network->best_bss->frequency, network->best_bss->signal,
                network->best_bss->snr, network->best_bss->est_throughput);
+#else
+       score_new = bss->signal;
+       score_best = network->best_bss->signal;
+#endif
 
        if (score_new > score_best) {
                SUPPLICANT_DBG("new[" MACSTR "][%u] : best[" MACSTR "][%u]",
index 870749f..845fa00 100755 (executable)
@@ -2345,12 +2345,11 @@ int connman_network_set_bssid(struct connman_network *network,
 
        if (bssid == NULL)
                return -EINVAL;
-#if defined TIZEN_EXT
+
        if (!simplified_log)
-#endif
-       DBG("network %p bssid %02x:%02x:%02x:%02x:%02x:%02x", network,
-                       bssid[0], bssid[1], bssid[2],
-                       bssid[3], bssid[4], bssid[5]);
+               DBG("network %p bssid %02x:%02x:%02x:%02x:%02x:%02x", network,
+                               bssid[0], bssid[1], bssid[2],
+                               bssid[3], bssid[4], bssid[5]);
 
        for (;i < WIFI_BSSID_LEN_MAX;i++)
                network->wifi.bssid[i] = bssid[i];
@@ -2439,10 +2438,8 @@ int connman_network_set_enc_mode(struct connman_network *network,
        if (encryption_mode == NULL)
                return -EINVAL;
 
-#if defined TIZEN_EXT
        if (!simplified_log)
-#endif
-       DBG("network %p encryption mode %s", network, encryption_mode);
+               DBG("network %p encryption mode %s", network, encryption_mode);
 
        g_strlcpy(network->wifi.encryption_mode, encryption_mode,
                                        WIFI_ENCYPTION_MODE_LEN_MAX);
@@ -2535,11 +2532,9 @@ int connman_network_set_countrycode(struct connman_network *network,
        if (country_code == NULL)
                return -EINVAL;
 
-#if defined TIZEN_EXT
        if (!simplified_log)
-#endif
-       DBG("network %p Country Code %02x:%02x",network,
-           country_code[0],country_code[1]);
+               DBG("network %p Country Code %02x:%02x",network,
+                               country_code[0],country_code[1]);
 
        for (; i < WIFI_COUNTRY_CODE_LEN; i++)
                network->wifi.country_code[i] = country_code[i];
@@ -2564,10 +2559,8 @@ int connman_network_set_bssid_list(struct connman_network *network,
 int connman_network_set_phy_mode(struct connman_network *network,
                                    ieee80211_modes_e mode)
 {
-#if defined TIZEN_EXT
        if (!simplified_log)
-#endif
-       DBG("network %p phy mode %d", network, mode);
+               DBG("network %p phy mode %d", network, mode);
        network->wifi.phy_mode = mode;
 
        return 0;
index 8ffb254..6b2b980 100755 (executable)
@@ -860,10 +860,8 @@ static int service_ext_load(struct connman_service *service)
        int i;
        int err = 0;
 
-#if defined TIZEN_EXT
        if (!simplified_log)
-#endif
-       DBG("service %p", service);
+               DBG("service %p", service);
 
        if (!service->network)
                return -EINVAL;
@@ -3083,17 +3081,19 @@ static void state_changed(struct connman_service *service)
 #endif
 }
 
-#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+#if defined TIZEN_EXT
 static void connect_reason_changed(struct connman_service *service)
 {
+#if defined TIZEN_EXT_INS
        struct connman_device *device;
-
+#endif
        if (!service->path)
                return;
 
        if (!allow_property_changed(service))
                return;
 
+#if defined TIZEN_EXT_INS
        if (service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_USER) {
                device = connman_network_get_device(service->network);
                if (device) {
@@ -3110,12 +3110,13 @@ static void connect_reason_changed(struct connman_service *service)
                                connman_device_save_last_user_selection(device);
                }
        }
+#endif
 
        connman_dbus_property_changed_basic(service->path,
-                                           CONNMAN_SERVICE_INTERFACE,
-                                           "ConnectReason",
-                                           DBUS_TYPE_INT32,
-                                           &service->connect_reason);
+                                       CONNMAN_SERVICE_INTERFACE,
+                                       "ConnectReason",
+                                       DBUS_TYPE_INT32,
+                                       &service->connect_reason);
 }
 #endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
 
@@ -9981,9 +9982,9 @@ int __connman_service_connect(struct connman_service *service,
        DBG("service %p err %d", service, err);
 
        service->connect_reason = reason;
-#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+#if defined TIZEN_EXT
        connect_reason_changed(service);
-#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
+#endif
 
        if (err >= 0)
                return 0;