[ACR]Add new APIs for TDLS 36/54536/6
authorhyunuktak <hyunuk.tak@samsung.com>
Wed, 16 Dec 2015 04:45:54 +0000 (13:45 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Wed, 23 Dec 2015 07:03:12 +0000 (16:03 +0900)
Change-Id: I53f948f216ec181ae89db346ce59775f279ec44c
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/wifi.h
packaging/capi-network-wifi.spec
src/net_wifi.c
test/wifi_test.c

index 5c26608c5a4a834a97fc089532c070b51cd94c59..09d99461309fad5b22a78305143214205520a404 100755 (executable)
@@ -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
 }
index dd569a5e50580a5e9064524df7e350906e7ba8c7..dbe45052a7b287a523c99042d273e9b1fb6d8736 100755 (executable)
@@ -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
index 2edfaff3f023401cc5cd8e6c39870a02f753894e..43c9fcceedab9e6d076987021ff4e2eef985a699 100755 (executable)
@@ -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;
+}
index 04a966aa386f4ac5efe0d20eaba19b490d5a5823..dacf27e0a87296880df656d8b0079b9410dfe9bc 100755 (executable)
@@ -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;