From 37b6ce46671cc0a19f6fd7e8067ce0a01cb2230e Mon Sep 17 00:00:00 2001 From: Anjali Nijhara Date: Tue, 22 Aug 2023 10:52:58 +0530 Subject: [PATCH] Refactor Code Change-Id: Icb3ce5439ec50b7e365cc3ca697c82e2eeab6358 --- include/service.h | 2 +- plugins/wifi.c | 90 +++++++++++++++++++++++++++---------------------------- src/dhcp.c | 2 +- src/service.c | 2 +- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/include/service.h b/include/service.h index 3f4c58c..f27e424 100755 --- a/include/service.h +++ b/include/service.h @@ -210,7 +210,7 @@ int connman_service_set_proxy(struct connman_service *service, void connman_service_set_disconnection_requested(struct connman_service *service, bool disconnection_requested); -void connman_service_notify_reconnection(struct connman_service *service); +void connman_service_notify_reconnection_roaming(struct connman_service *service); #endif #if defined TIZEN_EXT diff --git a/plugins/wifi.c b/plugins/wifi.c index e9e4ae9..9362a71 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -2260,69 +2260,69 @@ static void start_roaming(struct wifi_data *wifi) if (!wifi || !wifi->network) return; - if (connman_setting_get_bool("WifiRoaming")) { - struct connman_network *network = wifi->network; - bssid_list = connman_network_get_bssid_list(network); + if (!connman_setting_get_bool("WifiRoaming")) + return; - if (g_slist_length(bssid_list) <= 1) - return; + struct connman_network *network = wifi->network; + bssid_list = connman_network_get_bssid_list(network); - if (!connman_network_get_connected(network)) - return; + if (g_slist_length(bssid_list) <= 1) + return; - if (connman_network_get_bool(network, "WiFi.Roaming")) - return; + if (!connman_network_get_connected(network)) + return; - uint16_t cur_freq = connman_network_get_frequency(network); - uint8_t cur_strength = connman_network_get_strength(network); - unsigned int cur_est_throughput = connman_network_get_est_throughput(network); + if (connman_network_get_bool(network, "WiFi.Roaming")) + return; - if (!need_bss_transition( - cur_freq, - connman_network_get_snr(network), - cur_strength)) - return; + uint16_t cur_freq = connman_network_get_frequency(network); + uint8_t cur_strength = connman_network_get_strength(network); + unsigned int cur_est_throughput = connman_network_get_est_throughput(network); - unsigned char *cur_bssid = connman_network_get_bssid(network); + if (!need_bss_transition( + cur_freq, + connman_network_get_snr(network), + cur_strength)) + return; - for (; bssid_list; bssid_list = bssid_list->next) { - struct g_connman_bssids *bssid = bssid_list->data; + unsigned char *cur_bssid = connman_network_get_bssid(network); - if (memcmp(cur_bssid, bssid->bssid, WIFI_BSSID_LEN_MAX) == 0) - continue; + for (; bssid_list; bssid_list = bssid_list->next) { + struct g_connman_bssids *bssid = bssid_list->data; - if (check_bss_condition( - bssid->frequency, bssid->strength, bssid->est_throughput, - cur_freq, cur_strength, cur_est_throughput)) { - roaming_ap_found = true; + if (memcmp(cur_bssid, bssid->bssid, WIFI_BSSID_LEN_MAX) == 0) + continue; - char bssid_buff[WIFI_BSSID_STR_LEN] = {0,}; - char *bssid_str = bssid_buff; + if (check_bss_condition( + bssid->frequency, bssid->strength, bssid->est_throughput, + cur_freq, cur_strength, cur_est_throughput)) { + roaming_ap_found = true; - snprintf(bssid_str, WIFI_BSSID_STR_LEN, MACSTR, MAC2STR(bssid->bssid)); - connman_network_set_string(network, - "WiFi.RoamingDstBSSID", bssid_str); - break; - } - } - - if (roaming_ap_found) { char bssid_buff[WIFI_BSSID_STR_LEN] = {0,}; char *bssid_str = bssid_buff; - unsigned char *bssid; - bssid = connman_network_get_bssid(network); - snprintf(bssid_str, WIFI_BSSID_STR_LEN, MACSTR, MAC2STR(bssid)); + snprintf(bssid_str, WIFI_BSSID_STR_LEN, MACSTR, MAC2STR(bssid->bssid)); connman_network_set_string(network, - "WiFi.RoamingCurBSSID", bssid_str); - - network_disconnect(network); - wifi->pending_network = network; - connman_network_set_bool(network, "WiFi.Roaming", true); + "WiFi.RoamingDstBSSID", bssid_str); + break; } } -} + if (roaming_ap_found) { + char bssid_buff[WIFI_BSSID_STR_LEN] = {0,}; + char *bssid_str = bssid_buff; + unsigned char *bssid; + + bssid = connman_network_get_bssid(network); + snprintf(bssid_str, WIFI_BSSID_STR_LEN, MACSTR, MAC2STR(bssid)); + connman_network_set_string(network, + "WiFi.RoamingCurBSSID", bssid_str); + + network_disconnect(network); + wifi->pending_network = network; + connman_network_set_bool(network, "WiFi.Roaming", true); + } +} #endif static void scan_callback(int result, GSupplicantInterface *interface, diff --git a/src/dhcp.c b/src/dhcp.c index 4b6cbf6..5ad1efb 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -591,7 +591,7 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data) if (connman_network_get_bool(dhcp->network, "WiFi.RoamingDHCP")) { if (ip_change) - connman_service_notify_reconnection( + connman_service_notify_reconnection_roaming( connman_service_lookup_from_network(dhcp->network)); connman_network_set_bool(dhcp->network, "WiFi.RoamingDHCP", false); diff --git a/src/service.c b/src/service.c index 59d0af3..bbb639a 100755 --- a/src/service.c +++ b/src/service.c @@ -3245,7 +3245,7 @@ static void connman_service_emit_state(struct connman_service *service, service->state = cur_state; } -void connman_service_notify_reconnection(struct connman_service *service) +void connman_service_notify_reconnection_roaming(struct connman_service *service) { if (!service) return; -- 2.7.4