Change the roaming scan interval 47/268647/1 submit/tizen/20211230.063452
authorJaehyun Kim <jeik01.kim@samsung.com>
Tue, 28 Dec 2021 13:41:31 +0000 (22:41 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Tue, 28 Dec 2021 13:41:31 +0000 (22:41 +0900)
If no AP is found to roam, change the scan interval
to minimize performance degradation due to frequent scans.

Change-Id: I1d655fa0d2215358531f772b6d697e537ed3a2d5
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/network.h
plugins/wifi.c
src/main.conf
src/network.c

index 8ca5314..d1838a7 100755 (executable)
@@ -241,6 +241,9 @@ unsigned char *connman_network_get_last_connected_bssid(struct connman_network *
 void connman_network_set_assoc_reject_table(struct connman_network *network,
                GHashTable *assoc_reject_table);
 GHashTable *connman_network_get_assoc_reject_table(struct connman_network *network);
+__time_t connman_network_get_roam_scan_time(struct connman_network *network);
+void connman_network_set_roam_scan_time(struct connman_network *network,
+                                               __time_t roam_scan_time);
 int connman_network_get_snr(struct connman_network *network);
 void connman_network_set_snr(struct connman_network *network, int snr);
 #endif
index ba35f5f..7c15996 100755 (executable)
 #define WIFI_BSSID_STR_LEN 18
 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+#define ROAM_SCAN_INTERVAL 60 /* 60 seconds */
 #endif
 
 static struct connman_technology *wifi_technology = NULL;
@@ -4124,6 +4125,8 @@ static void signalpoll_callback(int result, int maxspeed, int strength,
        char bssid_buff[WIFI_BSSID_STR_LEN] = {0,};
        char *bssid_str = bssid_buff;
        unsigned char *bssid;
+       struct timespec curr_time = {0};
+       __time_t roam_scan_time;
        const char *interface = NULL;
        struct connman_device *device;
        struct connman_network *network = user_data;
@@ -4146,23 +4149,29 @@ static void signalpoll_callback(int result, int maxspeed, int strength,
        connman_network_set_maxspeed(network, maxspeed);
        set_connection_mode(network, maxspeed);
 
-       bssid = connman_network_get_bssid(network);
-       device = connman_network_get_device(network);
-
-       if (device)
-               interface = connman_device_get_string(device, "Interface");
-
-       connman_network_unref(network);
+       clock_gettime(CLOCK_MONOTONIC, &curr_time);
+       roam_scan_time = connman_network_get_roam_scan_time(network);
+       if (curr_time.tv_sec <= roam_scan_time + ROAM_SCAN_INTERVAL)
+               goto done;
 
        if (need_bss_transition(freq, snr, strength)) {
+               device = connman_network_get_device(network);
+               if (device)
+                       interface = connman_device_get_string(device, "Interface");
+
+               bssid = connman_network_get_bssid(network);
                snprintf(bssid_str, WIFI_BSSID_STR_LEN, MACSTR, MAC2STR(bssid));
                __connman_technology_notify_roaming_state(interface, "required", bssid_str, NULL);
 
                if (connman_setting_get_bool("WifiRoamingScan") == false)
-                       return;
+                       goto done;
 
                throw_wifi_scan(device, scan_callback);
+               connman_network_set_roam_scan_time(network, curr_time.tv_sec);
        }
+
+done:
+       connman_network_unref(network);
 }
 
 static int network_signalpoll(struct wifi_data *wifi)
index 662af2b..f761da7 100755 (executable)
@@ -187,12 +187,12 @@ DefaultWifiInterface = wlan0
 
 # Allow ConnMan to start scan for wifi roaming when SNR and signal are weakened
 # Default value is false.
-WifiRoamingScan = true
+WifiRoamingScan = true
 
 # Allow ConnMan to start wifi roaming when SNR and signal are weakened
 # and there is another BSS in better condition.
 # Default value is false.
-WifiRoaming = true
+WifiRoaming = true
 
 
 [INS]
index b1643e7..ded1040 100755 (executable)
@@ -148,6 +148,7 @@ struct connman_network {
                bool roaming_progress;
                char *roaming_cur_bssid;
                char *roaming_dst_bssid;
+               __time_t roam_scan_time;
                int snr;
 #endif
        } wifi;
@@ -2651,6 +2652,17 @@ GHashTable *connman_network_get_assoc_reject_table(struct connman_network *netwo
        return network->wifi.assoc_reject_table;
 }
 
+__time_t connman_network_get_roam_scan_time(struct connman_network *network)
+{
+       return network->wifi.roam_scan_time;
+}
+
+void connman_network_set_roam_scan_time(struct connman_network *network,
+                                               __time_t roam_scan_time)
+{
+       network->wifi.roam_scan_time = roam_scan_time;
+}
+
 int connman_network_get_snr(struct connman_network *network)
 {
        return network->wifi.snr;