*/
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. */
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;
*/
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;
/**
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)
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
* @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
* @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.
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);
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",
{
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;
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);
return WIFI_DIRECT_ERROR_NONE;
}
+/* DPRECATED */
int wifi_direct_set_ssid(const char *ssid)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
return WIFI_DIRECT_ERROR_NONE;
}
-
-
int wifi_direct_get_ssid(char **ssid)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
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)
{
}
-
-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();
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 =
}
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)
{
else
{
WFD_CLIENT_LOG(WFD_LOG_LOW,
- "wifi_direct_deactivate_persistent_group() SUCCESS \n");
+ "wifi_direct_set_persistent_group_enabled() SUCCESS \n");
}
}
else
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;
}
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
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
-}
+}
int wifi_direct_foreach_persistent_groups(wifi_direct_persistent_group_cb callback, void* user_data)
{