diff options
author | Jaehyun Kim <jeik01.kim@samsung.com> | 2024-08-20 14:27:33 +0900 |
---|---|---|
committer | Jaehyun Kim <jeik01.kim@samsung.com> | 2024-08-20 17:07:07 +0900 |
commit | 081e3a5fa55d56c100bf1675449097335d4dac27 (patch) | |
tree | 0454626c850badc80465f38b65e9465d0e6b7210 /src | |
parent | a0c21eabcf3994537ca506b788acebc26862f2e8 (diff) | |
download | connman-081e3a5fa55d56c100bf1675449097335d4dac27.tar.gz connman-081e3a5fa55d56c100bf1675449097335d4dac27.tar.bz2 connman-081e3a5fa55d56c100bf1675449097335d4dac27.zip |
Support Wi-Fi band selection for scanning
Change-Id: I6215077d2cb467df4e56039491146062f9aca6e9
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/device.c | 4 | ||||
-rw-r--r-- | src/technology.c | 69 |
2 files changed, 73 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c index da86084f..580e325d 100755 --- a/src/device.c +++ b/src/device.c @@ -2324,4 +2324,8 @@ unsigned int connman_device_get_random_mac_lifetime(struct connman_device *devic return device->random_mac_lifetime; } +int connman_device_get_wifi_scan_band(struct connman_device *device) +{ + return connman_technology_get_wifi_scan_band(device); +} #endif diff --git a/src/technology.c b/src/technology.c index d21d790f..1b17db2f 100644 --- a/src/technology.c +++ b/src/technology.c @@ -104,6 +104,7 @@ struct connman_technology { unsigned int mac_policy; unsigned int preassoc_mac_policy; unsigned int random_mac_lifetime; + char *wifi_band_selection; #endif #if defined TIZEN_EXT_WIFI_MESH DBusMessage *mesh_dbus_msg; @@ -234,6 +235,11 @@ static void technology_save(struct connman_technology *technology) g_key_file_set_uint64(keyfile, identifier, "RandomMacLifetime", technology->random_mac_lifetime); + + if (technology->wifi_band_selection) + g_key_file_set_string(keyfile, identifier, + "WifiBandSelection", + technology->wifi_band_selection); } #endif /* TIZEN_EXT */ if (technology->tethering_freq == 0) @@ -397,6 +403,47 @@ static struct connman_technology *technology_find(enum connman_service_type type return NULL; } +#if defined TIZEN_EXT +static void connman_technology_set_wifi_scan_band( + struct connman_technology *technology, const char *band) +{ + if (!band) + return; + + if (technology->wifi_band_selection) + g_free(technology->wifi_band_selection); + + technology->wifi_band_selection = g_strdup(band); + + technology_save(technology); +} + +int connman_technology_get_wifi_scan_band(struct connman_device *device) +{ + struct connman_technology *technology; + enum connman_service_type type; + + DBG("device %p", device); + + type = __connman_device_get_service_type(device); + + technology = technology_find(type); + if (!technology || !technology->wifi_band_selection) + return WIFI_BAND_SELECTION_ALL; + + if (g_str_equal(technology->wifi_band_selection, "all")) + return WIFI_BAND_SELECTION_ALL; + else if (g_str_equal(technology->wifi_band_selection, "2.4GHz")) + return WIFI_BAND_SELECTION_2_4GHZ; + else if (g_str_equal(technology->wifi_band_selection, "5GHz")) + return WIFI_BAND_SELECTION_5GHZ; + else if (g_str_equal(technology->wifi_band_selection, "6GHz")) + return WIFI_BAND_SELECTION_6GHZ; + + return WIFI_BAND_SELECTION_ALL; +} +#endif + enum connman_service_type connman_technology_get_type (struct connman_technology *technology) { @@ -529,6 +576,7 @@ static void technology_load(struct connman_technology *technology) #ifdef TIZEN_EXT if (technology->type == CONNMAN_SERVICE_TYPE_WIFI) { unsigned int val = 0; + char *scan_band = NULL; val = g_key_file_get_uint64(keyfile, identifier, "MacPolicy", NULL); @@ -550,6 +598,13 @@ static void technology_load(struct connman_technology *technology) technology->random_mac_lifetime = val; else technology->random_mac_lifetime = 60; + + scan_band = g_key_file_get_string(keyfile, + identifier, "WifiBandSelection", NULL); + if (scan_band) + technology->wifi_band_selection = scan_band; + else + technology->wifi_band_selection = g_strdup("all"); } #endif /* TIZEN_EXT */ @@ -754,10 +809,16 @@ static void append_properties(DBusMessageIter *iter, if (technology->type == CONNMAN_SERVICE_TYPE_WIFI) connman_dbus_dict_append_dict(&dict, "Device.List", append_devices, technology); + if (technology->regdom) connman_dbus_dict_append_basic(&dict, "CountryCode", DBUS_TYPE_STRING, &technology->regdom); + + if (technology->wifi_band_selection) + connman_dbus_dict_append_basic(&dict, "WifiBandSelection", + DBUS_TYPE_STRING, + &technology->wifi_band_selection); #endif connman_dbus_dict_append_basic(&dict, "TetheringFreq", DBUS_TYPE_INT32, @@ -1553,6 +1614,13 @@ static DBusMessage *set_property(DBusConnection *conn, dbus_message_iter_get_basic(&value, &str); DBG("country code %s", str); connman_technology_set_regdom(str); + } else if (g_str_equal(name, "WifiBandSelection")) { + const char *str; + + dbus_message_iter_get_basic(&value, &str); + DBG("WifiBandSelection %s", str); + + connman_technology_set_wifi_scan_band(technology, str); #endif } else return __connman_error_invalid_property(msg); @@ -3032,6 +3100,7 @@ static void technology_put(struct connman_technology *technology) } #ifdef TIZEN_EXT g_strfreev(technology->enabled_devices); + g_free(technology->wifi_band_selection); #endif g_free(technology->path); g_free(technology->regdom); |