From 82e8e4c24a86dc0c10e8624d2aec8baf514fd6a0 Mon Sep 17 00:00:00 2001 From: taesub kim Date: Tue, 19 Dec 2017 20:05:49 +0900 Subject: [PATCH] Added APIs to set/get enable or disable of passpoint Change-Id: Ib41979110d6ceeceec7e605a6b7de6d233060abb Signed-off-by: Taesub Kim --- include/wifi-manager-extension.h | 55 +++++++++++++++++++++++++++++++++------- include/wifi_internal.h | 2 ++ src/wifi_internal.c | 26 +++++++++++++++++++ src/wifi_manager.c | 40 +++++++++++++++++++++++++++++ test/wifi_manager_test.c | 53 ++++++++++++++++++++++++++++++++++++-- 5 files changed, 165 insertions(+), 11 deletions(-) diff --git a/include/wifi-manager-extension.h b/include/wifi-manager-extension.h index 19db076..cc561f1 100755 --- a/include/wifi-manager-extension.h +++ b/include/wifi-manager-extension.h @@ -63,11 +63,12 @@ typedef enum { * @param[in] autoscan true to enable and false to disable * * @return 0 on success, otherwise negative error value - * @retval #WIFI_ERROR_NONE Successful - * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation - * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #WIFI_ERROR_OPERATION_FAILED Operation failed - * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported * @pre This API needs wifi_initialize() before use. */ int wifi_manager_set_autoscan(wifi_manager_h wifi, bool autoscan); @@ -96,10 +97,11 @@ int wifi_manager_get_autoscan(wifi_manager_h wifi, bool *autoscan); * @param[in] mode The auto scan mode * * @return 0 on success, otherwise negative error value - * @retval #WIFI_ERROR_NONE Successful - * @retval #WIFI_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation - * @retval #WIFI_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_MANAGER_ERROR_NONE Successful + * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported * @pre This API needs wifi_initialize() before use. */ int wifi_manager_set_autoscan_mode(wifi_manager_h wifi, @@ -132,6 +134,7 @@ int wifi_manager_get_autoscan_mode(wifi_manager_h wifi, * @retval #WIFI_MANAGER_ERROR_NONE Successful * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported */ int wifi_manager_flush_bss(wifi_manager_h wifi); @@ -146,6 +149,7 @@ int wifi_manager_flush_bss(wifi_manager_h wifi); * @retval #WIFI_MANAGER_ERROR_NONE Successful * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported */ int wifi_manager_set_auto_connect(wifi_manager_h wifi, int connect_mode); @@ -160,10 +164,41 @@ int wifi_manager_set_auto_connect(wifi_manager_h wifi, int connect_mode); * @retval #WIFI_MANAGER_ERROR_NONE Successful * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported */ int wifi_manager_get_auto_connect(wifi_manager_h wifi, int *connect_mode); /** + * @brief Enables or disables passpoint. + * @since_tizen 5.0 + * + * @param[in] wifi The Wi-Fi handle + * @param[in] passpoint true to enable and false to disable + * + * @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_INVALID_OPERATION Invalid operation + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_manager_set_passpoint(wifi_manager_h wifi, int passpoint); + +/** + * @brief Gets the passpoint state. + * @since_tizen 5.0 + * + * @param[in] wifi The Wi-Fi handle + * @param[out] passpoint The passpoint state(enable or disable) + * + * @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_INVALID_OPERATION Invalid operation + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_manager_get_passpoint(wifi_manager_h wifi, int *passpoint); + +/** * @brief Sets enables or disables auto-connection of the AP. * @details If an AP is connected, then connection information will be stored. * By default, the stored AP can be connected automatically when it found, until disabling auto-connection. @@ -178,6 +213,7 @@ int wifi_manager_get_auto_connect(wifi_manager_h wifi, int *connect_mode); * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported * @pre This API needs wifi_manager_initialize() and wifi_manager_activate() before use. */ int wifi_manager_ap_set_auto_connect(wifi_manager_ap_h ap, bool autoconnect); @@ -197,6 +233,7 @@ int wifi_manager_ap_set_auto_connect(wifi_manager_ap_h ap, bool autoconnect); * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WIFI_MANAGER_ERROR_OPERATION_FAILED Operation failed * @retval #WIFI_MANAGER_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED Not supported * @pre This API needs wifi_manager_initialize() and wifi_manager_activate() before use. */ int wifi_manager_ap_get_auto_connect(wifi_manager_ap_h ap, bool *autoconnect); diff --git a/include/wifi_internal.h b/include/wifi_internal.h index fa0cc7e..eb7d2d0 100755 --- a/include/wifi_internal.h +++ b/include/wifi_internal.h @@ -293,6 +293,8 @@ int _wifi_set_autoscan(bool autoscan); int _wifi_set_background_scan_mode(wifi_manager_autoscan_mode_e mode); int _wifi_get_autoscan(bool *autoscan); int _wifi_get_autoscanmode(wifi_manager_autoscan_mode_e *autoscanmode); +int _wifi_get_passpoint(int *passpoint); +int _wifi_set_passpoint(int passpoint); int _wifi_get_module_state(wifi_manager_module_state_e *state); void _wifi_module_state_changed_cb(keynode_t *node, void *user_data); diff --git a/src/wifi_internal.c b/src/wifi_internal.c index f515d54..8aaa76c 100755 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -2904,6 +2904,32 @@ int _wifi_get_autoscanmode(wifi_manager_autoscan_mode_e *autoscanmode) return WIFI_MANAGER_ERROR_NONE; } +int _wifi_set_passpoint(int passpoint) +{ + int rv; + + rv = net_wifi_set_passpoint(passpoint); + + if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to set passpoint"); + } + + return rv; +} + +int _wifi_get_passpoint(int *passpoint) +{ + int rv; + + rv = net_wifi_get_passpoint(passpoint); + + if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get passpoint state"); + } + + return rv; +} + int _wifi_get_ip_conflict_period(unsigned int* initial_time) { int rv; diff --git a/src/wifi_manager.c b/src/wifi_manager.c index 32372f0..9bc1449 100755 --- a/src/wifi_manager.c +++ b/src/wifi_manager.c @@ -1212,6 +1212,46 @@ EXPORT_API int wifi_manager_get_autoscan_mode(wifi_manager_h wifi, __NETWORK_CAPI_FUNC_EXIT__; return _wifi_get_autoscanmode(mode); } + +EXPORT_API int wifi_manager_set_passpoint(wifi_manager_h wifi, int passpoint) +{ + __NETWORK_CAPI_FUNC_ENTER__; + + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + int rv; + + if (!(__wifi_check_handle_validity(wifi))) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + __NETWORK_CAPI_FUNC_EXIT__; + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; + } + + rv = _wifi_set_passpoint(passpoint); + + __NETWORK_CAPI_FUNC_EXIT__; + return rv; +} + +EXPORT_API int wifi_manager_get_passpoint(wifi_manager_h wifi, int *passpoint) +{ + __NETWORK_CAPI_FUNC_ENTER__; + + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + int rv; + + if (!(__wifi_check_handle_validity(wifi)) || passpoint == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + __NETWORK_CAPI_FUNC_EXIT__; + return WIFI_MANAGER_ERROR_INVALID_PARAMETER; + } + + rv = _wifi_get_passpoint(passpoint); + + __NETWORK_CAPI_FUNC_EXIT__; + return rv; +} //LCOV_EXCL_STOP EXPORT_API int wifi_manager_set_module_state_changed_cb(wifi_manager_h wifi, diff --git a/test/wifi_manager_test.c b/test/wifi_manager_test.c index d191154..1233b81 100755 --- a/test/wifi_manager_test.c +++ b/test/wifi_manager_test.c @@ -1192,6 +1192,11 @@ static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user else printf("Fail to get WPS supported\n"); + if (wifi_manager_ap_is_passpoint(ap, &bool_value) == WIFI_MANAGER_ERROR_NONE) + printf("Passpoint enabled : %s\n", bool_value ? "TRUE" : "FALSE"); + else + printf("Fail to get passpoint state\n"); + if (sec_type != WIFI_MANAGER_SECURITY_TYPE_EAP) { g_free(ap_name); return false; @@ -2899,6 +2904,42 @@ int test_wifi_manager_get_ap_auto_connect(void) return 1; } +int test_wifi_manager_set_passpoint_enable(void) +{ + int rv; + int enable; + + printf("Enter passpoint on/off(0:off, 1:on) : \n"); + rv = scanf("%d", &enable); + if (rv <= 0) + return -1; + + rv = wifi_manager_set_passpoint(wifi, enable); + + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to set passpoint, rv = %d\n", rv); + } + + printf("Request to set passpoint\n"); + return 1; +} + +int test_wifi_manager_get_passpoint_state(void) +{ + int rv; + int enabled; + + rv = wifi_manager_get_passpoint(wifi, &enabled); + + if (rv != WIFI_MANAGER_ERROR_NONE) { + printf("Fail to get passpoint state, rv = %d\n", rv); + return 1; + } + + printf("current passpoint sate(0:off, 1:on) = [%d]\n", enabled); + return 1; +} + int main(int argc, char **argv) { GMainLoop *mainloop; @@ -2983,7 +3024,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("F - Set IP conflict detection mode\n"); printf("G - Get IP conflict detection mode\n"); printf("H - Get IP conflict state\n"); -/* Extension API */ +/* Extension APIs */ printf(LOG_BLUE "[Extension API]\n" LOG_END); printf("I - Set Enable or Disable Auto Scan\n"); printf("J - Set Mode of Auto Scan\n"); @@ -2998,6 +3039,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("S - Get the IP conflict detection period\n"); printf("T - Netlink Scan\n"); printf("U - Netlink Specific Scan\n"); + printf("V - Get passpoint state\n"); + printf("W - Set passpoint on/off\n"); printf(LOG_RED "0 - Exit \n" LOG_END); printf("ENTER - Show options menu.......\n"); @@ -3134,7 +3177,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) case 'H': rv = test_wifi_manager_get_ip_conflict_state(); break; -/* Extension API */ +/* Extension APIs */ case 'I': rv = test_wifi_manager_set_autoscan_state(); break; @@ -3174,6 +3217,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) case 'U': rv = test_wifi_manager_netlink_scan_specific_ap(); break; + case 'V': + rv = test_wifi_manager_get_passpoint_state(); + break; + case 'W': + rv = test_wifi_manager_set_passpoint_enable(); + break; default: break; } -- 2.7.4