From: hyunuktak Date: Wed, 16 Dec 2015 04:45:54 +0000 (+0900) Subject: [ACR]Add new APIs for TDLS X-Git-Tag: submit/tizen/20160108.030209~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F36%2F54536%2F6;p=platform%2Fcore%2Fapi%2Fwifi.git [ACR]Add new APIs for TDLS Change-Id: I53f948f216ec181ae89db346ce59775f279ec44c Signed-off-by: hyunuktak --- diff --git a/include/wifi.h b/include/wifi.h index 5c26608..09d9946 100755 --- a/include/wifi.h +++ b/include/wifi.h @@ -2072,8 +2072,101 @@ int wifi_config_get_eap_subject_match(wifi_config_h config, char** subject_match int wifi_config_set_eap_subject_match(wifi_config_h config, const char* subject_match); /** -* @} -*/ + * @} + */ + +/** + * @addtogroup CAPI_NETWORK_WIFI_TDLS + * @{ + */ + +/** + * @brief Enumeration for the state of the Wi-Fi TDLS. + * @since_tizen 3.0 + */ +typedef enum +{ + WIFI_TDLS_STATE_DISCONNECTED = 0, /**< Wi-Fi TDLS is Disconnected */ + WIFI_TDLS_STATE_CONNECTED = 1, /**< Wi-Fi TDLS is Connected */ +} wifi_tdls_state_e; + +/** + * @brief Called when the WiFi TDLS state is changed. + * @since_tizen 3.0 + * + * @param[in] state The TDLS state + * @param[in] peer_mac_addr MAC address of the TDLS peer + * @param[in] user_data The user data passed from the callback registration function + * @see wifi_tdls_set_state_changed_cb() + * @see wifi_tdls_unset_state_changed_cb() + */ +typedef void(*wifi_tdls_state_changed_cb)(wifi_tdls_state_e state, char* peer_mac_addr, void* user_data); + +/** + * @brief Disconnects the connected peer. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set + * + * @param[in] ap The MAC address of the connected peer + * + * @return @c 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_NOT_SUPPORTED Not supported + */ +int wifi_tdls_disconnect(const char* peer_mac_addr); + +/** + * @brief Gets Peer Mac address of Connected peer. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * + * @remarks The @a peer_mac_addr should be freed using free(). + * @param[out] peer_mac_addr The MAC address of the connected peer + * + * @return @c 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_NO_CONNECTION No active TDLS Connection + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_tdls_get_connected_peer(char** peer_mac_addr); + +/** + * @brief Registers the callback called when TDLS state is changed. + * @since_tizen 3.0 + * + * @param[in] callback The callback function to be called + * @param[in] user_data The user data passed to the callback function + * + * @return @c 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_NOT_SUPPORTED Not supported + */ +int wifi_tdls_set_state_changed_cb(wifi_tdls_state_changed_cb callback, void* user_data); + +/** + * @brief Unregisters the callback called when TDLS state is changed. + * @since_tizen 3.0 + * + * @return @c 0 on success, otherwise negative error value + * @retval #WIFI_ERROR_NONE Successful + * @retval #WIFI_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_tdls_unset_state_changed_cb(void); + +/** + * @} + */ #ifdef __cplusplus } diff --git a/packaging/capi-network-wifi.spec b/packaging/capi-network-wifi.spec index dd569a5..dbe4505 100755 --- a/packaging/capi-network-wifi.spec +++ b/packaging/capi-network-wifi.spec @@ -1,6 +1,6 @@ Name: capi-network-wifi Summary: Network Wi-Fi library in TIZEN C API -Version: 1.0.62 +Version: 1.0.63 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/net_wifi.c b/src/net_wifi.c index 2edfaff..43c9fcc 100755 --- a/src/net_wifi.c +++ b/src/net_wifi.c @@ -545,3 +545,70 @@ EXPORT_API int wifi_unset_rssi_level_changed_cb(void) return WIFI_ERROR_NONE; } + +EXPORT_API int wifi_tdls_disconnect(const char* peer_mac_addr) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); + return WIFI_ERROR_INVALID_OPERATION; + } + + if (peer_mac_addr == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_ERROR_INVALID_PARAMETER; + } + + int rv = 0; + rv = net_wifi_tdls_disconnect(peer_mac_addr); + + if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to disconnect tdls"); + return WIFI_ERROR_OPERATION_FAILED; + } + + return WIFI_ERROR_NONE; +} + +EXPORT_API int wifi_tdls_get_connected_peer(char** peer_mac_addr) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + + if (_wifi_is_init() == false) { + WIFI_LOG(WIFI_ERROR, "Not initialized"); + return WIFI_ERROR_INVALID_OPERATION; + } + + if (peer_mac_addr == NULL) { + WIFI_LOG(WIFI_ERROR, "Invalid parameter"); + return WIFI_ERROR_INVALID_PARAMETER; + } + + int rv = 0; + rv = net_wifi_tdls_connected_peer(peer_mac_addr); + + if (rv != NET_ERR_NONE) { + WIFI_LOG(WIFI_ERROR, "Failed to get connected peer"); + return WIFI_ERROR_OPERATION_FAILED; + } + + if (g_strcmp0(*peer_mac_addr, "00.00.00.00.00.00") == 0) { + g_free(*peer_mac_addr); + return WIFI_ERROR_NO_CONNECTION; + } + + return WIFI_ERROR_NONE; +} + +EXPORT_API int wifi_tdls_set_state_changed_cb(wifi_tdls_state_changed_cb callback, void* user_data) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + return WIFI_ERROR_NONE; +} + +EXPORT_API int wifi_tdls_unset_state_changed_cb(void) +{ + CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); + return WIFI_ERROR_NONE; +} diff --git a/test/wifi_test.c b/test/wifi_test.c index 04a966a..dacf27e 100755 --- a/test/wifi_test.c +++ b/test/wifi_test.c @@ -1528,6 +1528,46 @@ int test_set_eap_configuration(void) return 1; } +int test_wifi_tdls_disconnect(void) +{ + int rv = 0; + + char * peer_mac = NULL; + printf("Enter Mac_address: "); + if(scanf(" %ms", &peer_mac) < 1) + return -1; + + if (strlen(peer_mac) > 17) + { + printf("Wrong Mac_address\n"); + return -1; + } + + rv = wifi_tdls_disconnect(peer_mac); + if (rv != WIFI_ERROR_NONE) { + printf("test_wifi_tdls_disconnect() is failed [%s]\n", __test_convert_error_to_string(rv)); + g_free(peer_mac); + return -1; + } + g_free(peer_mac); + return 1; +} + +int test_wifi_tdls_get_connected_peer(void) +{ + int rv = 0; + char *mac_addr = NULL; + + rv = wifi_tdls_get_connected_peer(&mac_addr); + if (rv != WIFI_ERROR_NONE) { + printf("wifi_tdls_get_connected_peer() is failed [%s]\n", __test_convert_error_to_string(rv)); + return -1; + } + printf("Peer Mac address is [%s]\n",mac_addr); + g_free(mac_addr); + return 1; +} + int main(int argc, char **argv) { GMainLoop *mainloop; @@ -1589,6 +1629,10 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("m - Save configuration\n"); printf("n - Set configuration proxy and hidden\n"); printf("o - Set EAP configuration\n"); + printf("p - TDLS TearDown\n"); + printf("q - TDLS Set Connected Callback\n"); + printf("r - TDLS Set Disconnected Callback\n"); + printf("s - TDLS Get Connected Peer\n"); printf("0 - Exit \n"); printf("ENTER - Show options menu.......\n"); @@ -1667,6 +1711,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) case 'o': rv = test_set_eap_configuration(); break; + case 'p': + rv = test_wifi_tdls_disconnect(); + break; + case 'r': + rv = test_wifi_tdls_get_connected_peer(); + break; default: break;