From: Niraj Kumar Goit Date: Thu, 21 May 2020 16:09:20 +0000 (+0530) Subject: Added API to get IEEE 802.11 connection mode. X-Git-Tag: submit/tizen/20200609.003709^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abbd3e72b056591cffb5eebb618e7caaa5d1e5e0;p=platform%2Fcore%2Fapi%2Fwifi-manager.git Added API to get IEEE 802.11 connection mode. API wifi_manager_ap_get_connection_mode() will be used to get IEEE 802.11 connection mode supported by an AP. Change-Id: I909b6e8a6380a4378de70f7ddb4aec6e9db99c81 Signed-off-by: Niraj Kumar Goit --- diff --git a/include/network_config.h b/include/network_config.h index 5fa53e2..5b007b2 100755 --- a/include/network_config.h +++ b/include/network_config.h @@ -46,6 +46,8 @@ extern "C" { ["enabled", "disabled", "preferred"]*/ #define NET_IPV6_MAX_PREFIX_LEN 128 /** Maximum length of IPv6 Prefix */ +#define NET_MAX_PROTOCOL_LEN 18 /** Maximum length of Wi-Fi Protocol Type */ + typedef enum { NET_ADDR_IPV4 = 0x0, /** IPV4 Address type */ NET_ADDR_IPV6 = 0x1, /** IPV6 Address type */ diff --git a/include/network_interface.h b/include/network_interface.h index 42965c8..355295e 100755 --- a/include/network_interface.h +++ b/include/network_interface.h @@ -206,6 +206,7 @@ typedef struct { GSList *vsie_list; /** List of Vendor Specific Information Element of AP*/ int assoc_status_code; /** Supplicant WiFi Association Status Code */ char country_code[NET_WLAN_COUNTRY_CODE_LEN]; /** Country code received from AP */ + char operation_mode[NET_MAX_PROTOCOL_LEN+1]; /** WI-FI Network Protocol Type (802.11a/b/g/n/ac/ax) */ unsigned int connection_mode; /** Connection mode (IEEE 802.11b/g/n/a/ac) */ GSList *bssid_list; /** List if BSSID, strength and frequency of AP **/ gboolean ap_hidden_status; /** Hidden Status of connected AP */ diff --git a/include/wifi-manager-extension.h b/include/wifi-manager-extension.h index a039d68..d02216d 100755 --- a/include/wifi-manager-extension.h +++ b/include/wifi-manager-extension.h @@ -54,6 +54,7 @@ typedef enum { WIFI_MANAGER_CONNECTION_MODE_80211_N, /**< IEEE 802.11n 2.4/5 Ghz */ WIFI_MANAGER_CONNECTION_MODE_80211_A, /**< IEEE 802.11a 5 Ghz */ WIFI_MANAGER_CONNECTION_MODE_80211_AC, /**< IEEE 802.11ac 5 Ghz */ + WIFI_MANAGER_CONNECTION_MODE_80211_AX, /**< IEEE 802.11ax 5 Ghz */ } wifi_manager_connection_mode_e; /** @@ -470,6 +471,19 @@ int wifi_manager_deinitialize_cs(int tid, wifi_manager_h wifi); int wifi_manager_get_connection_mode(wifi_manager_h wifi, wifi_manager_connection_mode_e *mode); +/** + * @brief Gets the IEEE 802.11 connection mode supported by AP. + * @since_tizen 6.0 + * @param[in] ap The access point handle + * @param[out] mode The Wi-Fi connection mode. + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation Failed + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_manager_ap_get_connection_mode(wifi_manager_ap_h ap, wifi_manager_connection_mode_e *mode); + /** * @} */ diff --git a/src/network_interface.c b/src/network_interface.c index 3e813d2..2fb9b2a 100755 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -941,7 +941,10 @@ static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_s* Prof } else if (g_strcmp0(key, "Frequency") == 0) { ProfInfo->frequency = (unsigned int)g_variant_get_uint16(var); - + } else if (g_strcmp0(key, "Protocol") == 0) { + value = g_variant_get_string(var, NULL); + if (value != NULL) + g_strlcpy(ProfInfo->operation_mode, value, NET_MAX_PROTOCOL_LEN+1); } else if (g_strcmp0(key, "ConnMode") == 0) { ProfInfo->connection_mode = (unsigned int)g_variant_get_uint16(var); diff --git a/src/wifi_ap.c b/src/wifi_ap.c index c4b7276..367e39c 100755 --- a/src/wifi_ap.c +++ b/src/wifi_ap.c @@ -307,6 +307,23 @@ wifi_manager_error_e __wifi_convert_to_ap_error_state(net_error_state_type_e err return ap_error_state; } +wifi_manager_connection_mode_e __ap_convert_string_to_connection_mode(char *mode) +{ + if (g_strcmp0(mode, "802.11b") == 0) + return WIFI_MANAGER_CONNECTION_MODE_80211_B; + else if (g_strcmp0(mode, "802.11g") == 0) + return WIFI_MANAGER_CONNECTION_MODE_80211_G; + else if (g_strcmp0(mode, "802.11n") == 0) + return WIFI_MANAGER_CONNECTION_MODE_80211_N; + else if (g_strcmp0(mode, "802.11a") == 0) + return WIFI_MANAGER_CONNECTION_MODE_80211_A; + else if (g_strcmp0(mode, "802.11ac") == 0) + return WIFI_MANAGER_CONNECTION_MODE_80211_AC; + else if (g_strcmp0(mode, "802.11ax") == 0) + return WIFI_MANAGER_CONNECTION_MODE_80211_AX; + else + return WIFI_MANAGER_CONNECTION_MODE_UNKNOWN; +} //LCOV_EXCL_STOP EXPORT_API int wifi_manager_ap_create(wifi_manager_h wifi, @@ -2618,3 +2635,27 @@ EXPORT_API int wifi_manager_ap_get_error_state(wifi_manager_ap_h ap, wifi_manage return WIFI_MANAGER_ERROR_NONE; } + +EXPORT_API int wifi_manager_ap_get_connection_mode(wifi_manager_ap_h ap, wifi_manager_connection_mode_e *mode) +{ + __NETWORK_CAPI_FUNC_ENTER__; + + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + if (_wifi_check_ap_validity(ap) == false || mode == 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 + } + + net_profile_info_s *profile_info = ap; + if (profile_info->operation_mode[0] != '\0') { + *mode = __ap_convert_string_to_connection_mode(profile_info->operation_mode); + } else { + __NETWORK_CAPI_FUNC_EXIT__; + return WIFI_MANAGER_ERROR_OPERATION_FAILED; + } + + __NETWORK_CAPI_FUNC_EXIT__; + return WIFI_MANAGER_ERROR_NONE; +} diff --git a/test/wifi_manager_test.c b/test/wifi_manager_test.c index c1566cc..c11004a 100755 --- a/test/wifi_manager_test.c +++ b/test/wifi_manager_test.c @@ -1130,6 +1130,7 @@ static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user wifi_manager_assoc_status_code_e status_code; wifi_manager_rssi_level_e rssi_level; bool is_hidden; + wifi_manager_connection_mode_e mode; rv = wifi_manager_ap_get_essid(ap, &ap_name); if (rv != WIFI_MANAGER_ERROR_NONE) { @@ -1161,6 +1162,11 @@ static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user else printf("Fail to get RSSI level\n"); + if (wifi_manager_ap_get_connection_mode(ap, &mode) == WIFI_MANAGER_ERROR_NONE) + printf("Wi-Fi operation mode: %d\n", mode); + else + printf("Fail to get operation mode\n"); + if (wifi_manager_ap_get_frequency(ap, &int_value) == WIFI_MANAGER_ERROR_NONE) printf("Frequency : %d\n", int_value); else