WIFI_MANAGER_PS_MODE_DYNAMIC,
} wifi_manager_power_save_mode_e;
+/* Wi-Fi band to scan */
+typedef enum {
+ WIFI_MANAGER_BAND_SELECTION_ALL = 0x00,
+ WIFI_MANAGER_BAND_SELECTION_2_4GHZ,
+ WIFI_MANAGER_BAND_SELECTION_5GHZ,
+ WIFI_MANAGER_BAND_SELECTION_6GHZ,
+} wifi_manager_band_selection_e;
+
/**
* @brief The Wi-Fi netlink scan handle.
* @since_tizen 5.0
*/
int wifi_manager_get_country_code(wifi_manager_h wifi, char **country_code);
+/**
+ * @brief Sets the Wi-Fi band to scan.
+ * @since_tizen 9.0
+ *
+ * @param[in] wifi The Wi-Fi handle
+ * @param[in] scan_band The Wi-Fi band to scan
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ * @pre This API needs wifi_manager_initialize() before use.
+ */
+int wifi_manager_set_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e scan_band);
+
+/**
+ * @brief Gets the Wi-Fi band to scan.
+ * @since_tizen 9.0
+ *
+ * @param[in] wifi The Wi-Fi handle
+ * @param[out] scan_band The Wi-Fi band to scan
+ *
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE Successful
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported
+ * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed
+ */
+int wifi_manager_get_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e *scan_band);
+
/**
* @brief Called when the Roaming state is changed.
* @since_tizen 7.0
return Error;
}
+int _net_dbus_set_scan_band(network_info_s *network_info, const char *scan_band)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+
+ const char *prop_key = "WifiBandSelection";
+ const char *method = "SetProperty";
+ GVariant *params = NULL;
+
+ params = g_variant_new("(sv)", prop_key, g_variant_new_string(scan_band));
+
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ CONNMAN_TECHNOLOGY_INTERFACE,
+ method, params, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to set country code");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int _net_dbus_get_scan_band(network_info_s *network_info, char **scan_band)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+ GVariant *message = NULL;
+ GVariant *value = NULL;
+ GVariantIter *iter = NULL;
+ gchar *key = NULL;
+
+ message = _net_invoke_dbus_method(network_info,
+ CONNMAN_SERVICE, CONNMAN_WIFI_TECHNOLOGY_PREFIX,
+ CONNMAN_TECHNOLOGY_INTERFACE, "GetProperties",
+ NULL, &Error);
+
+ if (message == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get properties");
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
+
+ g_variant_get(message, "(a{sv})", &iter);
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+ if (g_strcmp0(key, "WifiBandSelection") == 0) {
+ const gchar *str = g_variant_get_string(value, NULL);
+ *scan_band = g_strdup(str);
+ WIFI_LOG(WIFI_INFO, "Successfully get country code: %s", *scan_band);
+
+ g_variant_unref(value);
+ g_free(key);
+ break;
+ }
+ }
+
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
int _net_dbus_get_vconf_value(network_info_s *network_info,
const char *key, const char *type, int *ret, int *int_value, char **str_value)
{
int _net_dbus_set_country_code(network_info_s *network_info, const char *country);
int _net_dbus_get_country_code(network_info_s *network_info, char **country);
+int _net_dbus_set_scan_band(network_info_s *network_info, const char *band);
+int _net_dbus_get_scan_band(network_info_s *network_info, char **band);
int _net_dbus_get_vconf_value(network_info_s *network_info,
const char *key, const char *type, int *ret, int *int_value, char **str_value);
}
//LCOV_EXCL_START
+int net_wifi_set_scan_band(network_info_s *network_info, const char *scan_band)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = _net_dbus_set_scan_band(network_info, scan_band);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
+int net_wifi_get_scan_band(network_info_s *network_info, char **scan_band)
+{
+ __NETWORK_FUNC_ENTER__;
+
+ net_err_e Error = NET_ERR_NONE;
+
+ Error = _net_dbus_get_scan_band(network_info, scan_band);
+
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+}
+
int net_wifi_get_power_save_state(network_info_s *network_info, unsigned int *ps_state)
{
__NETWORK_FUNC_ENTER__;
int net_wifi_set_country_code(network_info_s *network_info, const char *country);
int net_wifi_get_country_code(network_info_s *network_info, char **country);
+int net_wifi_set_scan_band(network_info_s *network_info, const char *scan_band);
+int net_wifi_get_scan_band(network_info_s *network_info, char **scan_band);
typedef enum {
WIFI_POWER_SAVE_OFF = 0x00,
return "UNKNOWN";
}
}
+
+static const char *__convert_wifi_band_to_string(wifi_manager_band_selection_e wifi_band)
+{
+ switch (wifi_band) {
+ case WIFI_MANAGER_BAND_SELECTION_ALL:
+ return "all";
+ case WIFI_MANAGER_BAND_SELECTION_2_4GHZ:
+ return "2.4GHz";
+ case WIFI_MANAGER_BAND_SELECTION_5GHZ:
+ return "5GHz";
+ case WIFI_MANAGER_BAND_SELECTION_6GHZ:
+ return "6GHz";
+ default:
+ return "all";
+ }
+}
+
+static wifi_manager_band_selection_e __convert_string_to_wifi_band(const char *wifi_band)
+{
+ if (g_strcmp0(wifi_band, "all") == 0)
+ return WIFI_MANAGER_BAND_SELECTION_ALL;
+ else if (g_strcmp0(wifi_band, "2.4GHz") == 0)
+ return WIFI_MANAGER_BAND_SELECTION_2_4GHZ;
+ else if (g_strcmp0(wifi_band, "5GHz") == 0)
+ return WIFI_MANAGER_BAND_SELECTION_5GHZ;
+ else if (g_strcmp0(wifi_band, "6GHz") == 0)
+ return WIFI_MANAGER_BAND_SELECTION_6GHZ;
+ else
+ return WIFI_MANAGER_BAND_SELECTION_ALL;
+}
//LCOV_EXCL_STOP
static gchar *__wifi_change_name_to_hexadecimal(const gchar *name)
}
//LCOV_EXCL_START
+int _wifi_set_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e scan_band)
+{
+ int rv;
+ const char *scan_band_str;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
+ scan_band_str = __convert_wifi_band_to_string(scan_band);
+ rv = net_wifi_set_scan_band(wifi_handle->network_info, scan_band_str);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
+int _wifi_get_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e *scan_band)
+{
+ int rv;
+ char *scan_band_str = NULL;
+ wifi_manager_handle_s *wifi_handle = wifi;
+
+ rv = net_wifi_get_scan_band(wifi_handle->network_info, &scan_band_str);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ } else if (rv != NET_ERR_NONE)
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+
+ *scan_band = __convert_string_to_wifi_band(scan_band_str);
+ g_free(scan_band_str);
+
+ return WIFI_MANAGER_ERROR_NONE;
+}
+
int _wifi_get_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e *ps_state)
{
int rv = 0;
int _wifi_set_country_code(wifi_manager_h wifi, const char *country);
int _wifi_get_country_code(wifi_manager_h wifi, char **country);
+int _wifi_set_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e scan_band);
+int _wifi_get_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e *scan_band);
int _wifi_get_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e *ps_state);
int _wifi_set_power_save_state(wifi_manager_h wifi, wifi_manager_power_save_state_e ps_state);
return rv;
}
+EXPORT_API int wifi_manager_set_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e scan_band)
+{
+ int rv;
+
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+
+ if (scan_band < WIFI_MANAGER_BAND_SELECTION_ALL || scan_band > WIFI_MANAGER_BAND_SELECTION_6GHZ) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_set_scan_band(wifi, scan_band);
+ if (rv != WIFI_MANAGER_ERROR_NONE)
+ WIFI_LOG(WIFI_ERROR, "Set Wi-Fi scan band failed");
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
+}
+
+EXPORT_API int wifi_manager_get_scan_band(wifi_manager_h wifi, wifi_manager_band_selection_e *scan_band)
+{
+ int rv;
+
+ __NETWORK_CAPI_FUNC_ENTER__;
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ RET_ERR_IF_HANDLE_IS_NOT_VALID_OR_NOT_INITIALIZED(wifi, __NETWORK_CAPI_FUNC_EXIT__);
+
+ if (scan_band == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+
+ rv = _wifi_get_scan_band(wifi, scan_band);
+
+ __NETWORK_CAPI_FUNC_EXIT__;
+ return rv;
+}
+
EXPORT_API int wifi_manager_set_roaming_cb(wifi_manager_h wifi,
wifi_manager_roaming_state_changed_cb callback, void *user_data)
{
return 1;
}
+
+int wman_test_get_scan_band(wifi_manager_h wifi)
+{
+ int rv;
+ wifi_manager_band_selection_e scan_band;
+
+ rv = wifi_manager_get_scan_band(wifi, &scan_band);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Fail to get band info for Wi-Fi scanning [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ switch (scan_band) {
+ case WIFI_MANAGER_BAND_SELECTION_ALL:
+ printf("Wi-Fi band to scan: All\n");
+ break;
+ case WIFI_MANAGER_BAND_SELECTION_2_4GHZ:
+ printf("Wi-Fi band to scan: 2.4GHz\n");
+ break;
+ case WIFI_MANAGER_BAND_SELECTION_5GHZ:
+ printf("Wi-Fi band to scan: 5GHz\n");
+ break;
+ case WIFI_MANAGER_BAND_SELECTION_6GHZ:
+ printf("Wi-Fi band to scan: 6GHz\n");
+ break;
+ default:
+ printf("Wi-Fi band to scan: Unknown\n");
+ break;
+ }
+
+ return 1;
+}
+
+int wman_test_set_scan_band(wifi_manager_h wifi)
+{
+ int rv;
+ wifi_manager_band_selection_e scan_band;
+
+ printf("Set Wi-Fi band to scan (0: All, 1: 2.4GHz, 2: 5GHz, 3: 6GHz): ");
+ rv = scanf("%u", &scan_band);
+ if (rv <= 0)
+ return -1;
+
+ rv = wifi_manager_set_scan_band(wifi, scan_band);
+ if (rv != WIFI_MANAGER_ERROR_NONE) {
+ printf("Failed to set Wi-Fi band to scan [%s]\n", wman_test_strerror(rv));
+ return -1;
+ }
+
+ return 1;
+}
int wman_test_set_power_save_state(wifi_manager_h wifi);
int wman_test_get_power_save_mode(wifi_manager_h wifi);
int wman_test_set_power_save_mode(wifi_manager_h wifi);
+int wman_test_get_scan_band(wifi_manager_h wifi);
+int wman_test_set_scan_band(wifi_manager_h wifi);
printf("[ - Get Interval of Auto Scan\n");
printf("] - Set Interval of Auto Scan\n");
printf("; - Remove All Wi-Fi configurations\n");
+ printf(". - Get Wi-Fi band for scanning\n");
+ printf("/ - Set Wi-Fi band for scanning\n");
printf(LOG_RED "0 - Exit \n" LOG_END);
printf("ENTER - Show options menu.......\n");
case ';':
rv = wman_test_reset_wifi_configurations(wifi);
break;
+ case '.':
+ rv = wman_test_get_scan_band(wifi);
+ break;
+ case '/':
+ rv = wman_test_set_scan_band(wifi);
+ break;
default:
break;
}