From 56812f5d01571901ba4ea1286624ddb909f2074b Mon Sep 17 00:00:00 2001 From: Kim Gibyoung Date: Tue, 11 Dec 2012 18:20:50 +0900 Subject: [PATCH] Implementation of some APIs Change-Id: I341e16fb1e4674daebd15bc7ca8618ebfe354bca --- debian/changelog | 9 ++ include/wifi-direct-internal.h | 12 +- include/wifi-direct.h | 79 ++++++---- packaging/libwifi-direct.spec | 2 +- src/wifi-direct-client-proxy.c | 333 ++++++++++++++++++++++++++++------------- 5 files changed, 303 insertions(+), 132 deletions(-) diff --git a/debian/changelog b/debian/changelog index 833667a..9a30649 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +libwifi-direct (0.3.1) unstable; urgency=low + + * Implementation of wifi_direct_get_device_name / wifi_direct_set_device_name + * Implementation of persistent mode + * Git : rsa/framework/connectivity/libwifi-direct + * Tag : libwifi-direct_0.3.1 + + -- Gibyoung Kim Tue, 11 Dec 2012 17:52:11 +0900 + libwifi-direct (0.3.0) unstable; urgency=low * Update from private diff --git a/include/wifi-direct-internal.h b/include/wifi-direct-internal.h index db04472..5114d35 100644 --- a/include/wifi-direct-internal.h +++ b/include/wifi-direct-internal.h @@ -58,6 +58,7 @@ typedef unsigned int ipv4_addr_t; #define IPSTR "%d.%d.%d.%d" #define WIFI_DIRECT_MAX_SSID_LEN 32 +#define WIFI_DIRECT_MAX_DEVICE_NAME_LEN 32 #define WIFI_DIRECT_WPS_PIN_LEN 8 #define WIFI_DIRECT_MAC_ADDRESS_INFO_FILE "/opt/etc/.mac.info" @@ -116,7 +117,9 @@ typedef enum WIFI_DIRECT_CMD_IS_PERSISTENT_GROUP, WIFI_DIRECT_CMD_GET_PERSISTENT_GROUP_INFO, WIFI_DIRECT_CMD_REMOVE_PERSISTENT_GROUP, - + WIFI_DIRECT_CMD_GET_DEVICE_NAME, + WIFI_DIRECT_CMD_SET_DEVICE_NAME, + WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL, WIFI_DIRECT_CMD_MAX @@ -158,7 +161,7 @@ typedef enum */ typedef struct { - char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1]; + char device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN + 1]; int channel; wifi_direct_wps_type_e wps_config; int max_clients; @@ -178,7 +181,7 @@ typedef struct typedef struct { bool is_group_owner; - char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1]; + char device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN + 1]; unsigned char mac_address[6]; int channel; bool is_connected; @@ -198,7 +201,7 @@ typedef struct */ typedef struct { - char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1]; + char device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN + 1]; unsigned char ip_address[4]; unsigned char mac_address[6]; unsigned char intf_mac_address[6]; @@ -210,6 +213,7 @@ typedef struct typedef struct { + int network_id; char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1]; unsigned char go_mac_address[6]; } wfd_persistent_group_info_s; diff --git a/include/wifi-direct.h b/include/wifi-direct.h index 90f3514..fc9a0c1 100644 --- a/include/wifi-direct.h +++ b/include/wifi-direct.h @@ -213,7 +213,7 @@ typedef enum { */ typedef struct { - char* ssid; /** Null-terminated device friendly name. */ + char* device_name; /** Null-terminated device friendly name. */ char *mac_address; /** Device's P2P Device Address */ char* interface_address; /** Device's P2P Interface Address. Valid only if device is a P2P GO. */ int channel; /** Channel the device is listening on. */ @@ -224,6 +224,7 @@ typedef struct wifi_direct_secondary_device_type_e secondary_device_type; /** Sub category of device */ int supported_wps_types; /** The list of supported WPS type. \n The OR operation on #wifi_direct_wps_type_e can be used like #WIFI_DIRECT_WPS_TYPE_PBC | #WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY */ + char* ssid; /**< Service set identifier - DEPRECATED */ } wifi_direct_discovered_peer_info_s; @@ -233,13 +234,14 @@ typedef struct */ typedef struct { - char* ssid; /** Device friendly name. */ + char* device_name; /** Device friendly name. */ char* ip_address; /**< The IP address */ char* mac_address; /** Device's P2P Device Address */ char* interface_address; /** Device's P2P Interface Address */ bool p2p_supported; /* whether peer is a P2P device */ wifi_direct_primary_device_type_e primary_device_type; /* primary category of device */ int channel; /* Operating channel */ + char* ssid; /**< Service set identifier - DEPRECATED */ } wifi_direct_connected_peer_info_s; /** @@ -1633,6 +1635,43 @@ int wifi_direct_is_autonomous_group(bool * is_autonomous_group); int wifi_direct_set_ssid(const char *ssid); +/** + * @brief Sets the friendly name of local device. + * @details This device name is shown to other devices during device discovery. + * @remarks The name set by you is only valid during activated state. + * After Wi-Fi Direct is deactivated, this name will be as the phone name. + * @param[in] device_name The name to local device + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_DIRECT_ERROR_NONE Successful + * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed + * @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitteds + * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized + * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy + * @pre Wi-Fi Direct must be activated by wifi_direct_activate(). + * @see wifi_direct_activate() + * @see wifi_direct_get_device_name() + */ +int wifi_direct_set_device_name(const char* device_name); + +/** + * @brief Gets the name of local device. + * @remarks @a device_name must be released with free() by you. + * @param[out] device_name The name to local device + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_DIRECT_ERROR_NONE Successful + * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed + * @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized + * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy + * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize(). + * @see wifi_direct_initialize() + * @see wifi_direct_set_device_name() + */ +int wifi_direct_get_device_name(char** device_name); + /*****************************************************************************************/ /* wifi_direct_get_ssid API function prototype * int wifi_direct_get_ssid(char** ssid) @@ -2472,9 +2511,10 @@ int wifi_direct_set_autoconnection_mode(bool mode); int wifi_direct_is_autoconnection_mode(bool* mode); - -/** -* @brief Activates the persistent group. +/** +* @brief Enables the persistent group. +* @details If @a enabled is true, then P2P persisten group will be used when creating a group and establishing a connection. +* @param[in] enabled The status of persistent group: (@c true = enabled, @c false = disabled) * @retval #WIFI_DIRECT_ERROR_NONE Successful * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed * @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed @@ -2483,29 +2523,13 @@ int wifi_direct_is_autoconnection_mode(bool* mode); * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize(). * @see wifi_direct_initialize() -* @see wifi_direct_deactivate_persistent_group() -* @see wifi_direct_is_persistent_group_activated() +* @see wifi_direct_is_persistent_group_enabled() */ -int wifi_direct_activate_persistent_group(void); +int wifi_direct_set_persistent_group_enabled(bool enabled); /** -* @brief Deactivates the persistent group. -* @retval #WIFI_DIRECT_ERROR_NONE Successful -* @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed -* @retval #WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed -* @retval #WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted -* @retval #WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized -* @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy -* @pre The persistent group of Wi-Fi Direct service must be initialized by wifi_direct_initialize(). -* @see wifi_direct_initialize() -* @see wifi_direct_activate_persistent_group() -* @see wifi_direct_is_persistent_group_activated() -*/ -int wifi_direct_deactivate_persistent_group(void); - -/** -* @brief Checks whether the persistent group is activated or not. -* @param[in] activated The status of persistent group: (@c true = activated, @c false = deactivated) +* @brief Checks whether the persistent group is enabled or disabled. +* @param[out] enabled The status of persistent group: (@c true = enabled, @c false = disabled) * @retval #WIFI_DIRECT_ERROR_NONE Successful * @retval #WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed @@ -2515,9 +2539,10 @@ int wifi_direct_deactivate_persistent_group(void); * @retval #WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy * @pre Wi-Fi Direct service must be initialized by wifi_direct_initialize(). * @see wifi_direct_initialize() -* @see wifi_direct_activate_persistent_group() +* @see wifi_direct_set_persistent_group_enabled() */ -int wifi_direct_is_persistent_group_activated(bool* activated); +int wifi_direct_is_persistent_group_enabled(bool* enabled); + /** * @brief Called when you get the persistent groups repeatedly. diff --git a/packaging/libwifi-direct.spec b/packaging/libwifi-direct.spec index e51118f..306ebe4 100755 --- a/packaging/libwifi-direct.spec +++ b/packaging/libwifi-direct.spec @@ -1,6 +1,6 @@ Name: libwifi-direct Summary: wifi direct library (Shared Library) -Version: 0.3.0 +Version: 0.3.1 Release: 1 Group: TO_BE_FILLED License: Apache-2.0 diff --git a/src/wifi-direct-client-proxy.c b/src/wifi-direct-client-proxy.c index 5d6870b..5c5a2cf 100644 --- a/src/wifi-direct-client-proxy.c +++ b/src/wifi-direct-client-proxy.c @@ -657,7 +657,7 @@ void __wfd_client_print_entry_list(wfd_discovery_entry_s * list, int num) WFD_CLIENT_LOG(WFD_LOG_LOW, "== Peer index : %d ==\n", i); WFD_CLIENT_LOG(WFD_LOG_LOW, "is Group Owner ? %s\n", list[i].is_group_owner ? "YES" : "NO"); - WFD_CLIENT_LOG(WFD_LOG_LOW, "SSID : %s\n", list[i].ssid); + WFD_CLIENT_LOG(WFD_LOG_LOW, "device_name : %s\n", list[i].device_name); WFD_CLIENT_LOG(WFD_LOG_LOW, "MAC address : " MACSTR "\n", MAC2STR(list[i].mac_address)); WFD_CLIENT_LOG(WFD_LOG_LOW, "wps cfg method : %x\n", list[i].wps_cfg_methods); @@ -674,7 +674,7 @@ void __wfd_client_print_connected_peer_info(wfd_connected_peer_info_s * list, in for (i = 0; i < num; i++) { WFD_CLIENT_LOG(WFD_LOG_LOW, "== Peer index : %d ==\n", i); - WFD_CLIENT_LOG(WFD_LOG_LOW, "ssid : %s\n", list[i].ssid); + WFD_CLIENT_LOG(WFD_LOG_LOW, "device_name : %s\n", list[i].device_name); WFD_CLIENT_LOG(WFD_LOG_LOW, "Device MAC : " MACSTR "\n", MAC2STR(list[i].mac_address)); WFD_CLIENT_LOG(WFD_LOG_LOW, "Interface MAC : " MACSTR "\n", @@ -1661,7 +1661,7 @@ int wifi_direct_foreach_discovered_peers(wifi_direct_discovered_peer_cb callback { peer_list = (wifi_direct_discovered_peer_info_s *) calloc(1, sizeof(wifi_direct_discovered_peer_info_s)); peer_list->is_group_owner = buff[i].is_group_owner; - peer_list->ssid = strdup(buff[i].ssid); + peer_list->device_name = strdup(buff[i].device_name); peer_list->mac_address = (char *) calloc(1, 18); snprintf(peer_list->mac_address, 18, MACSTR, MAC2STR(buff[i].mac_address)); peer_list->channel = buff[i].channel; @@ -2215,7 +2215,7 @@ int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb callback, for (i = 0; i < num; i++) { peer_list = (wifi_direct_connected_peer_info_s *) calloc(1, sizeof(wifi_direct_connected_peer_info_s)); - peer_list->ssid = strdup(buff[i].ssid); + peer_list->device_name = strdup(buff[i].device_name); peer_list->ip_address= (char *) calloc(1, 16); snprintf(peer_list->ip_address, 16, IPSTR, IP2STR(buff[i].ip_address)); peer_list->mac_address = (char *) calloc(1, 18); @@ -4064,6 +4064,7 @@ int wifi_direct_get_wps_type(wifi_direct_wps_type_e* type) return WIFI_DIRECT_ERROR_NONE; } +/* DPRECATED */ int wifi_direct_set_ssid(const char *ssid) { wifi_direct_client_info_s *client_info = __wfd_get_control(); @@ -4171,8 +4172,6 @@ int wifi_direct_set_ssid(const char *ssid) return WIFI_DIRECT_ERROR_NONE; } - - int wifi_direct_get_ssid(char **ssid) { wifi_direct_client_info_s *client_info = __wfd_get_control(); @@ -4279,6 +4278,220 @@ int wifi_direct_get_ssid(char **ssid) return WIFI_DIRECT_ERROR_NONE; } +int wifi_direct_get_device_name(char** device_name) +{ + wifi_direct_client_info_s *client_info = __wfd_get_control(); + + __WFD_CLIENT_FUNC_START__; + + if (NULL == device_name) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [device_name]!\n"); + __WFD_CLIENT_FUNC_END__; + return WIFI_DIRECT_ERROR_INVALID_PARAMETER; + } + + if ((client_info->is_registered == false) + || (client_info->client_id == WFD_INVALID_ID)) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n"); + __WFD_CLIENT_FUNC_END__; + return WIFI_DIRECT_ERROR_NOT_INITIALIZED; + } + + wifi_direct_client_request_s req; + wifi_direct_client_response_s rsp; + char la_device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN + 1] = { 0, }; + + int status = WIFI_DIRECT_ERROR_NONE; + + memset(&req, 0, sizeof(wifi_direct_client_request_s)); + memset(&rsp, 0, sizeof(wifi_direct_client_response_s)); + + req.cmd = WIFI_DIRECT_CMD_GET_DEVICE_NAME; + req.client_id = client_info->client_id; + + status = + __wfd_client_send_request(client_info->sync_sockfd, &req, + sizeof(wifi_direct_client_request_s)); + if (status != WIFI_DIRECT_ERROR_NONE) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, + "Error!!! writing to socket, Errno = %s\n", + strerror(errno)); + WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n", + __wfd_print_error(status)); + client_info->sync_sockfd = -1; + __wfd_reset_control(); + __WFD_CLIENT_FUNC_END__; + return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED; + } + + if ((status = + __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp, + sizeof(wifi_direct_client_response_s))) <= 0) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, + "Error!!! reading socket, status = %d errno = %s\n", + status, strerror(errno)); + client_info->sync_sockfd = -1; + __wfd_reset_control(); + __WFD_CLIENT_FUNC_END__; + return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED; + } + else + { + if (rsp.cmd == WIFI_DIRECT_CMD_GET_DEVICE_NAME) + { + if (rsp.result != WIFI_DIRECT_ERROR_NONE) + { + WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! Result received = %d \n", + rsp.result); + WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n", + __wfd_print_error(rsp.result)); + __WFD_CLIENT_FUNC_END__; + return rsp.result; + } + else + { + WFD_CLIENT_LOG(WFD_LOG_LOW, + "wifi_direct_get_device_name() %s SUCCESS \n", + rsp.param2); + strncpy(la_device_name, rsp.param2, WIFI_DIRECT_MAX_DEVICE_NAME_LEN); + + char *temp_device_name = NULL; + temp_device_name = strdup(la_device_name); + if (NULL == temp_device_name) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for device name\n"); + return WIFI_DIRECT_ERROR_OUT_OF_MEMORY; + } + + *device_name = temp_device_name; + } + + } + else + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n", + rsp.cmd); + return WIFI_DIRECT_ERROR_OPERATION_FAILED; + } + } + + __WFD_CLIENT_FUNC_END__; + + return WIFI_DIRECT_ERROR_NONE; +} + + +int wifi_direct_set_device_name(const char *device_name) +{ + wifi_direct_client_info_s *client_info = __wfd_get_control(); + + __WFD_CLIENT_FUNC_START__; + + if ((client_info->is_registered == false) + || (client_info->client_id == WFD_INVALID_ID)) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n"); + __WFD_CLIENT_FUNC_END__; + return WIFI_DIRECT_ERROR_NOT_INITIALIZED; + } + + if (NULL == device_name) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [device_name]!\n"); + __WFD_CLIENT_FUNC_END__; + return WIFI_DIRECT_ERROR_INVALID_PARAMETER; + } + + WFD_CLIENT_LOG(WFD_LOG_ERROR, "device_name = [%s]\n", device_name); + + wifi_direct_client_request_s req; + wifi_direct_client_response_s rsp; + + int status = WIFI_DIRECT_ERROR_NONE; + + memset(&req, 0, sizeof(wifi_direct_client_request_s)); + memset(&rsp, 0, sizeof(wifi_direct_client_response_s)); + + req.cmd = WIFI_DIRECT_CMD_SET_DEVICE_NAME; + req.client_id = client_info->client_id; + + status = + __wfd_client_send_request(client_info->sync_sockfd, &req, + sizeof(wifi_direct_client_request_s)); + if (status != WIFI_DIRECT_ERROR_NONE) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, + "Error!!! writing to socket, Errno = %s\n", + strerror(errno)); + WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n", + __wfd_print_error(status)); + client_info->sync_sockfd = -1; + __wfd_reset_control(); + __WFD_CLIENT_FUNC_END__; + return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED; + } + + WFD_CLIENT_LOG(WFD_LOG_LOW, "writing msg hdr is success!\n"); + + status = + __wfd_client_send_request(client_info->sync_sockfd, device_name, + WIFI_DIRECT_MAX_DEVICE_NAME_LEN); + if (status != WIFI_DIRECT_ERROR_NONE) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, + "Error!!! writing to socket, Errno = %s\n", + strerror(errno)); + WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n", + __wfd_print_error(status)); + client_info->sync_sockfd = -1; + __wfd_reset_control(); + __WFD_CLIENT_FUNC_END__; + return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED; + } + + if ((status = + __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp, + sizeof(wifi_direct_client_response_s))) <= 0) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, + "Error!!! reading socket, status = %d errno = %s\n", + status, strerror(errno)); + client_info->sync_sockfd = -1; + __wfd_reset_control(); + __WFD_CLIENT_FUNC_END__; + return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED; + } + else + { + if (rsp.cmd == WIFI_DIRECT_CMD_SET_DEVICE_NAME) + { + if (rsp.result != WIFI_DIRECT_ERROR_NONE) + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, + "Error!!! Result received = %d \n", rsp.result); + WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n", + __wfd_print_error(rsp.result)); + __WFD_CLIENT_FUNC_END__; + return rsp.result; + } + } + else + { + WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n", + rsp.cmd); + return WIFI_DIRECT_ERROR_OPERATION_FAILED; + } + } + + __WFD_CLIENT_FUNC_END__; + + return WIFI_DIRECT_ERROR_NONE; +} + int wifi_direct_get_network_interface_name(char** name) { @@ -5314,8 +5527,7 @@ int wifi_direct_is_autoconnection_mode(bool* mode) } - -int wifi_direct_activate_persistent_group(void) +int wifi_direct_set_persistent_group_enabled(bool enabled) { wifi_direct_client_info_s *client_info = __wfd_get_control(); @@ -5337,92 +5549,11 @@ int wifi_direct_activate_persistent_group(void) memset(&req, 0, sizeof(wifi_direct_client_request_s)); memset(&rsp, 0, sizeof(wifi_direct_client_response_s)); - req.cmd = WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP; - req.client_id = client_info->client_id; - - status = - __wfd_client_send_request(client_info->sync_sockfd, &req, - sizeof(wifi_direct_client_request_s)); - if (status != WIFI_DIRECT_ERROR_NONE) - { - WFD_CLIENT_LOG(WFD_LOG_ERROR, - "Error!!! writing to socket, Errno = %s\n", - strerror(errno)); - WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n", - __wfd_print_error(status)); - client_info->sync_sockfd = -1; - __wfd_reset_control(); - __WFD_CLIENT_FUNC_END__; - return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED; - } - - if ((status = - __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp, - sizeof(wifi_direct_client_response_s))) <= 0) - { - WFD_CLIENT_LOG(WFD_LOG_ERROR, - "Error!!! reading socket, status = %d errno = %s\n", - status, strerror(errno)); - client_info->sync_sockfd = -1; - __wfd_reset_control(); - __WFD_CLIENT_FUNC_END__; - return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED; - } + if (enabled == true) + req.cmd = WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP; else - { - if (rsp.cmd == WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP) - { - if (rsp.result != WIFI_DIRECT_ERROR_NONE) - { - WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! Result received = %d \n", - rsp.result); - WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n", - __wfd_print_error(rsp.result)); - __WFD_CLIENT_FUNC_END__; - return rsp.result; - } - else - { - WFD_CLIENT_LOG(WFD_LOG_LOW, - "wifi_direct_activate_persistent_group() SUCCESS \n"); - } - } - else - { - WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n", - rsp.cmd); - return WIFI_DIRECT_ERROR_OPERATION_FAILED; - } - } - - __WFD_CLIENT_FUNC_END__; - - return WIFI_DIRECT_ERROR_NONE; -} - -int wifi_direct_deactivate_persistent_group(void) -{ - wifi_direct_client_info_s *client_info = __wfd_get_control(); - - __WFD_CLIENT_FUNC_START__; - - if ((client_info->is_registered == false) - || (client_info->client_id == WFD_INVALID_ID)) - { - WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n"); - __WFD_CLIENT_FUNC_END__; - return WIFI_DIRECT_ERROR_NOT_INITIALIZED; - } - - wifi_direct_client_request_s req; - wifi_direct_client_response_s rsp; + req.cmd = WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP; - int status = WIFI_DIRECT_ERROR_NONE; - - memset(&req, 0, sizeof(wifi_direct_client_request_s)); - memset(&rsp, 0, sizeof(wifi_direct_client_response_s)); - - req.cmd = WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP; req.client_id = client_info->client_id; status = @@ -5455,7 +5586,8 @@ int wifi_direct_deactivate_persistent_group(void) } else { - if (rsp.cmd == WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP) + if (rsp.cmd == WIFI_DIRECT_CMD_ACTIVATE_PERSISTENT_GROUP + || rsp.cmd == WIFI_DIRECT_CMD_DEACTIVATE_PERSISTENT_GROUP) { if (rsp.result != WIFI_DIRECT_ERROR_NONE) { @@ -5469,7 +5601,7 @@ int wifi_direct_deactivate_persistent_group(void) else { WFD_CLIENT_LOG(WFD_LOG_LOW, - "wifi_direct_deactivate_persistent_group() SUCCESS \n"); + "wifi_direct_set_persistent_group_enabled() SUCCESS \n"); } } else @@ -5485,15 +5617,16 @@ int wifi_direct_deactivate_persistent_group(void) return WIFI_DIRECT_ERROR_NONE; } -int wifi_direct_is_persistent_group_activated(bool* activated) + +int wifi_direct_is_persistent_group_enabled(bool* enabled) { wifi_direct_client_info_s *client_info = __wfd_get_control(); __WFD_CLIENT_FUNC_START__; - if (activated == NULL) + if (enabled == NULL) { - WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [activated]!\n"); + WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [enabled]!\n"); __WFD_CLIENT_FUNC_END__; return WIFI_DIRECT_ERROR_INVALID_PARAMETER; } @@ -5561,9 +5694,9 @@ int wifi_direct_is_persistent_group_activated(bool* activated) else { WFD_CLIENT_LOG(WFD_LOG_LOW, - "wifi_direct_is_persistent_group_activated() %s SUCCESS \n", + "wifi_direct_is_persistent_group_enabled() %s SUCCESS \n", rsp.param2); - *activated = (bool) rsp.param1; + *enabled = (bool) rsp.param1; } } else @@ -5577,8 +5710,8 @@ int wifi_direct_is_persistent_group_activated(bool* activated) __WFD_CLIENT_FUNC_END__; return WIFI_DIRECT_ERROR_NONE; -} +} int wifi_direct_foreach_persistent_groups(wifi_direct_persistent_group_cb callback, void* user_data) { -- 2.7.4