/*****************************************************************************
* Standard headers
*****************************************************************************/
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
{
int i = 0;
- printf("MAC [%s]\n", p);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "macaddr_atoe : input MAC = [%s]\n", p);
for (;;)
{
case WIFI_DIRECT_CLI_EVENT_GROUP_DESTROY_RSP:
return "WIFI_DIRECT_CLI_EVENT_GROUP_DESTROY_RSP";
break;
+ case WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND:
+ return "WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND";
+ break;
default:
return "WIFI_DIRECT_CLI_EVENT_unknown";
return "WIFI_DIRECT_ERROR_NOT_PERMITTED";
case WIFI_DIRECT_ERROR_INVALID_PARAMETER:
return "WIFI_DIRECT_ERROR_INVALID_PARAMETER";
- case WIFI_DIRECT_ERROR_STRANGE_CLIENT:
- return "WIFI_DIRECT_ERROR_STRANGE_CLIENT";
+ case WIFI_DIRECT_ERROR_NOT_INITIALIZED:
+ return "WIFI_DIRECT_ERROR_NOT_INITIALIZED";
+ case WIFI_DIRECT_ERROR_TOO_MANY_CLIENT:
+ return "WIFI_DIRECT_ERROR_TOO_MANY_CLIENT";
+ case WIFI_DIRECT_ERROR_RESOURCE_BUSY:
+ return "WIFI_DIRECT_ERROR_RESOURCE_BUSY";
case WIFI_DIRECT_ERROR_NONE:
return "WIFI_DIRECT_ERROR_NONE";
default:
WFD_CLIENT_LOG(WFD_LOG_ERROR, "connection_cb is NULL!!\n");
break;
+ // ToDo: Handling IP lease event...
+ case WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND:
+ if (client->ip_assigned_cb != NULL)
+ {
+ char* ifname = NULL;
+ ifname = vconf_get_str(VCONFKEY_IFNAME);
+
+ if (ifname == NULL)
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "vconf (%s) value is NULL!!!\n", VCONFKEY_IFNAME);
+ else
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "VCONFKEY_IFNAME(%s) : %s\n", VCONFKEY_IFNAME, ifname);
+
+ client->ip_assigned_cb(param1,
+ param2,
+ ifname,
+ client->user_data_for_cb_ip_assigned);
+
+ }
+ else
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "ip_assigned_cb is NULL!!\n");
+ break;
+
default:
break;
}
return -1;
}
- WFD_CLIENT_LOG(WFD_LOG_LOW, "@@@@@@@ len = %d @@@@@@@@@@@\n", datalen);
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "@@@@@@@ len = %d @@@@@@@@@@@\n", datalen);
pollfd.fd = sockfd;
pollfd.events = POLLIN | POLLERR | POLLHUP;
pollret = poll(&pollfd, 1, timeout);
- WFD_CLIENT_LOG(WFD_LOG_LOW, "POLL ret = %d, \n", pollret);
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "POLL ret = %d, \n", pollret);
if (pollret > 0)
{
if (pollfd.revents == POLLIN)
{
- WFD_CLIENT_LOG(WFD_LOG_LOW, "POLLIN \n");
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "POLLIN \n");
while (datalen)
{
errno = 0;
retval = read(sockfd, (char *) dataptr, datalen);
- WFD_CLIENT_LOG(WFD_LOG_LOW, "sockfd %d retval %d\n", sockfd,
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "sockfd %d retval %d\n", sockfd,
retval);
if (retval <= 0)
{
}
else if (pollfd.revents & POLLHUP)
{
- WFD_CLIENT_LOG(WFD_LOG_LOW, "POLLHUP\n");
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "POLLHUP\n");
__WFD_CLIENT_FUNC_END__;
return 0;
}
WFD_CLIENT_LOG(WFD_LOG_LOW, "SSID : %s\n", list[i].ssid);
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);
}
WFD_CLIENT_LOG(WFD_LOG_ERROR,
"------------------------------------------\n");
WFD_CLIENT_LOG(WFD_LOG_LOW, "services : %d\n", list[i].services);
WFD_CLIENT_LOG(WFD_LOG_LOW, "is_p2p : %d\n", list[i].is_p2p);
WFD_CLIENT_LOG(WFD_LOG_LOW, "category : %d\n", list[i].category);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "channel : %d\n", list[i].channel);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "IP ["IPSTR"]\n", IP2STR(list[i].ip_address));
}
WFD_CLIENT_LOG(WFD_LOG_ERROR,
"------------------------------------------\n");
WFD_CLIENT_LOG(WFD_LOG_LOW, "Operating channel = [%d]\n", config->channel);
WFD_CLIENT_LOG(WFD_LOG_LOW, "WPS method = [%d, %s]\n", config->wps_config,
(config->wps_config ==
- WIFI_DIRECT_WPS_PUSHBUTTON) ?
- "Pushbutton" : (config-> wps_config == WIFI_DIRECT_WPS_DISPLAY)
+ WIFI_DIRECT_WPS_TYPE_PBC) ?
+ "Pushbutton" : (config-> wps_config == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY)
? "Display" : "Keypad");
WFD_CLIENT_LOG(WFD_LOG_LOW, "Max client = [%d]\n", config->max_clients);
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is not initialized.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
client_info->activation_cb = cb;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is not initialized.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
client_info->activation_cb = NULL;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is not initialized.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
client_info->discover_cb = cb;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is not initialized.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
client_info->discover_cb = NULL;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is not initialized.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
client_info->connection_cb = cb;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is not initialized.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
client_info->connection_cb = NULL;
}
+int wifi_direct_set_client_ip_address_assigned_cb(wifi_direct_client_ip_address_assigned_cb cb, void* user_data)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == cb)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Callback is NULL.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (client_info->is_registered == false)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is not initialized.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ client_info->ip_assigned_cb = cb;
+ client_info->user_data_for_cb_ip_assigned = user_data;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+int wifi_direct_unset_client_ip_address_assigned_cb(void)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (client_info->is_registered == false)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is not initialized.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ client_info->ip_assigned_cb = NULL;
+ client_info->user_data_for_cb_ip_assigned = NULL;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
int wifi_direct_activate(void)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ if (timeout < 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Nagative value. Param [timeout]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
wifi_direct_client_request_s req;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
if (callback == NULL)
peer_list->is_persistent_group_owner = buff[i].is_persistent_go;
peer_list->interface_address = (char *) calloc(1, 18);
snprintf(peer_list->interface_address, 18, MACSTR, MAC2STR(buff[i].intf_mac_address));
+ peer_list->supported_wps_types= buff[i].wps_cfg_methods;
peer_list->primary_device_type = buff[i].category;
peer_list->secondary_device_type = buff[i].subcategory;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
if (mac_address == NULL)
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
if (mac_address == NULL)
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
if (callback == NULL)
{
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->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);
snprintf(peer_list->mac_address, 18, MACSTR, MAC2STR(buff[i].mac_address));
peer_list->interface_address = (char *) calloc(1, 18);
snprintf(peer_list->interface_address, 18, MACSTR, MAC2STR(buff[i].intf_mac_address));
peer_list->p2p_supported = buff[i].is_p2p;
peer_list->primary_device_type = buff[i].category;
-
+ peer_list->channel = buff[i].channel;
+
if (!callback(peer_list, user_data))
break;
}
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
}
-int wifi_direct_get_go_intent(int *intent)
-{
- 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_STRANGE_CLIENT;
- }
-
- 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_GET_GO_INTENT;
- 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_GO_INTENT)
- {
- 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_go_intent() intent[%d] SUCCESS \n",
- rsp.param1);
- *intent = rsp.param1;
- }
- }
- 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_wpa_passphrase(char *passphrase)
+int wifi_direct_set_group_owner_intent(int intent)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
- if (NULL == passphrase)
+ if (intent < 0 || intent > 15)
{
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [passphrase]!\n");
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Invalid Param : intent[%d]\n", intent);
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "passphrase = [%s]\n", passphrase);
-
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
memset(&req, 0, sizeof(wifi_direct_client_request_s));
memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
- req.cmd = WIFI_DIRECT_CMD_SET_WPA;
+ req.cmd = WIFI_DIRECT_CMD_SET_GO_INTENT;
req.client_id = client_info->client_id;
- status =
- __wfd_client_send_request(client_info->sync_sockfd, &req,
+ 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_LOW, "writing msg hdr is success!\n");
status =
- __wfd_client_send_request(client_info->sync_sockfd, passphrase, 64);
+ __wfd_client_send_request(client_info->sync_sockfd, &intent,
+ sizeof(int));
if (status != WIFI_DIRECT_ERROR_NONE)
{
WFD_CLIENT_LOG(WFD_LOG_ERROR,
}
else
{
- if (rsp.cmd == WIFI_DIRECT_CMD_SET_WPA)
+ if (rsp.cmd == WIFI_DIRECT_CMD_SET_GO_INTENT)
{
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_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;
}
-int wifi_direct_activate_pushbutton(void)
+int wifi_direct_get_group_owner_intent(int* intent)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
memset(&req, 0, sizeof(wifi_direct_client_request_s));
memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
- req.cmd = WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON;
+ req.cmd = WIFI_DIRECT_CMD_GET_GO_INTENT;
req.client_id = client_info->client_id;
status =
}
else
{
- if (rsp.cmd == WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON)
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_GO_INTENT)
{
if (rsp.result != WIFI_DIRECT_ERROR_NONE)
{
else
{
WFD_CLIENT_LOG(WFD_LOG_LOW,
- "wifi_direct_activate_pushbutton() SUCCESS \n");
+ "int wifi_direct_get_group_owner_intent() intent[%d] SUCCESS \n",
+ rsp.param1);
+ *intent = rsp.param1;
}
}
else
return WIFI_DIRECT_ERROR_NONE;
}
-
-int wifi_direct_set_wps_pin(char *pin)
+int wifi_direct_set_max_clients(int max)
{
-
wifi_direct_client_info_s *client_info = __wfd_get_control();
__WFD_CLIENT_FUNC_START__;
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
- if (NULL == pin)
- {
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [pin]!\n");
- __WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
- }
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "pin = [%s]\n", pin);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "max client [%d]\n", max);
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
memset(&req, 0, sizeof(wifi_direct_client_request_s));
memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
- req.cmd = WIFI_DIRECT_CMD_SET_WPS_PIN;
+ req.cmd = WIFI_DIRECT_CMD_SET_MAX_CLIENT;
req.client_id = client_info->client_id;
- status =
- __wfd_client_send_request(client_info->sync_sockfd, &req,
+ 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_LOW, "writing msg hdr is success!\n");
status =
- __wfd_client_send_request(client_info->sync_sockfd, pin,
- WIFI_DIRECT_WPS_PIN_LEN);
+ __wfd_client_send_request(client_info->sync_sockfd, &max,
+ sizeof(int));
if (status != WIFI_DIRECT_ERROR_NONE)
{
WFD_CLIENT_LOG(WFD_LOG_ERROR,
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_WPS_PIN)
+ if (rsp.cmd == WIFI_DIRECT_CMD_SET_MAX_CLIENT)
{
if (rsp.result != WIFI_DIRECT_ERROR_NONE)
{
return WIFI_DIRECT_ERROR_NONE;
}
-
-int wifi_direct_get_wps_pin(char **pin)
+int wifi_direct_get_max_clients(int* max)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
- char la_pin[WIFI_DIRECT_WPS_PIN_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_WPS_PIN;
+ req.cmd = WIFI_DIRECT_CMD_GET_MAX_CLIENT;
req.client_id = client_info->client_id;
status =
}
else
{
- if (rsp.cmd == WIFI_DIRECT_CMD_GET_WPS_PIN)
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_MAX_CLIENT)
{
if (rsp.result != WIFI_DIRECT_ERROR_NONE)
{
else
{
WFD_CLIENT_LOG(WFD_LOG_LOW,
- "wifi_direct_get_wps_pin() SUCCESS \n");
- strncpy(la_pin, rsp.param2, WIFI_DIRECT_WPS_PIN_LEN);
-
- char *temp_pin;
- temp_pin = strdup(la_pin);
-
- *pin = temp_pin;
+ "int wifi_direct_get_max_clients() max_client[%d] SUCCESS \n",
+ rsp.param1);
+ *max = rsp.param1;
}
}
else
return WIFI_DIRECT_ERROR_NONE;
}
-
-int wifi_direct_generate_wps_pin(void)
+int wifi_direct_get_own_group_channel(int* channel)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
- int status = WIFI_DIRECT_ERROR_NONE;
+ int ret = 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_GENERATE_WPS_PIN;
+ req.cmd = WIFI_DIRECT_CMD_GET_OWN_GROUP_CHANNEL;
req.client_id = client_info->client_id;
- status =
+ ret =
__wfd_client_send_request(client_info->sync_sockfd, &req,
sizeof(wifi_direct_client_request_s));
- if (status != WIFI_DIRECT_ERROR_NONE)
+ if (ret != 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));
+ __wfd_print_error(ret));
client_info->sync_sockfd = -1;
__wfd_reset_control();
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
}
- if ((status =
+ if ((ret =
__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));
+ "Error!!! reading socket, status = %d errno = %s\n", ret,
+ strerror(errno));
client_info->sync_sockfd = -1;
__wfd_reset_control();
__WFD_CLIENT_FUNC_END__;
}
else
{
- if (rsp.cmd == WIFI_DIRECT_CMD_GENERATE_WPS_PIN)
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_OWN_GROUP_CHANNEL)
{
if (rsp.result != WIFI_DIRECT_ERROR_NONE)
{
}
else
{
- WFD_CLIENT_LOG(WFD_LOG_LOW,
- "wifi_direct_generate_wps_pin() SUCCESS \n");
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "channel = [%d]\n",
+ (int) rsp.param1);
+ *channel = rsp.param1;
}
}
else
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
-}
+}
-int wifi_direct_get_supported_wps_mode(int *wps_mode)
+int wifi_direct_set_wpa_passphrase(char *passphrase)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ if (NULL == passphrase)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [passphrase]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "passphrase = [%s]\n", passphrase);
+
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
- int ret = WIFI_DIRECT_ERROR_NONE;
+ 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_SUPPORTED_WPS_MODE;
+ req.cmd = WIFI_DIRECT_CMD_SET_WPA;
req.client_id = client_info->client_id;
- ret =
+ status =
__wfd_client_send_request(client_info->sync_sockfd, &req,
sizeof(wifi_direct_client_request_s));
- if (ret != WIFI_DIRECT_ERROR_NONE)
+ 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(ret));
+ __wfd_print_error(status));
client_info->sync_sockfd = -1;
__wfd_reset_control();
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
}
- if ((ret =
- __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
- sizeof(wifi_direct_client_response_s))) <= 0)
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "writing msg hdr is success!\n");
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, passphrase, 64);
+ if (status != WIFI_DIRECT_ERROR_NONE)
{
WFD_CLIENT_LOG(WFD_LOG_ERROR,
- "Error!!! reading socket, status = %d errno = %s\n", ret,
+ "Error!!! writing to socket, Errno = %s\n",
strerror(errno));
- client_info->sync_sockfd = -1;
+ 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_SUPPORTED_WPS_MODE)
+ if (rsp.cmd == WIFI_DIRECT_CMD_SET_WPA)
{
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_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_LOW, "Supported wps config = [%d]\n",
- (int) rsp.param1);
- *wps_mode = rsp.param1;
- }
}
else
{
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
-
}
-int wifi_direct_set_ssid(const char *ssid)
+int wifi_direct_activate_pushbutton(void)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
- }
-
- if (NULL == ssid)
- {
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [ssid]!\n");
- __WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "ssid = [%s]\n", ssid);
-
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
memset(&req, 0, sizeof(wifi_direct_client_request_s));
memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
- req.cmd = WIFI_DIRECT_CMD_SET_SSID;
+ req.cmd = WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON;
req.client_id = client_info->client_id;
status =
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, ssid,
- WIFI_DIRECT_MAX_SSID_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)
}
else
{
- if (rsp.cmd == WIFI_DIRECT_CMD_SET_SSID)
+ if (rsp.cmd == WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON)
{
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_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_pushbutton() SUCCESS \n");
+ }
}
else
{
}
-
-int wifi_direct_get_ssid(char **ssid)
+int wifi_direct_set_wps_pin(char *pin)
{
+
wifi_direct_client_info_s *client_info = __wfd_get_control();
__WFD_CLIENT_FUNC_START__;
- if (NULL == ssid)
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
{
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [ssid]!\n");
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
- if ((client_info->is_registered == false)
- || (client_info->client_id == WFD_INVALID_ID))
+ if (NULL == pin)
{
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [pin]!\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "pin = [%s]\n", pin);
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
- char la_ssid[WIFI_DIRECT_MAX_SSID_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_SSID;
+ req.cmd = WIFI_DIRECT_CMD_SET_WPS_PIN;
req.client_id = client_info->client_id;
status =
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, pin,
+ WIFI_DIRECT_WPS_PIN_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_GET_SSID)
+ if (rsp.cmd == WIFI_DIRECT_CMD_SET_WPS_PIN)
{
if (rsp.result != WIFI_DIRECT_ERROR_NONE)
{
__WFD_CLIENT_FUNC_END__;
return rsp.result;
}
- else
- {
- WFD_CLIENT_LOG(WFD_LOG_LOW,
- "wifi_direct_get_ssid() %s SUCCESS \n",
- rsp.param2);
- strncpy(la_ssid, rsp.param2, WIFI_DIRECT_MAX_SSID_LEN);
-
- char *temp_ssid;
- temp_ssid = strdup(la_ssid);
-
- *ssid = temp_ssid;
- }
-
}
else
{
}
-int wifi_direct_get_ip_address(char **ip_address)
+int wifi_direct_get_wps_pin(char **pin)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
__WFD_CLIENT_FUNC_START__;
- if (NULL == ip_address)
- {
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [ip_address]!\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_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
- char la_ip[64] = { 0, };
+ char la_pin[WIFI_DIRECT_WPS_PIN_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_IP_ADDR;
+ req.cmd = WIFI_DIRECT_CMD_GET_WPS_PIN;
req.client_id = client_info->client_id;
status =
}
else
{
- if (rsp.cmd == WIFI_DIRECT_CMD_GET_IP_ADDR)
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_WPS_PIN)
{
if (rsp.result != WIFI_DIRECT_ERROR_NONE)
{
else
{
WFD_CLIENT_LOG(WFD_LOG_LOW,
- "wifi_direct_get_ip_address() SUCCESS \n");
- strncpy(la_ip, rsp.param2, strlen(rsp.param2));
+ "wifi_direct_get_wps_pin() SUCCESS \n");
+ strncpy(la_pin, rsp.param2, WIFI_DIRECT_WPS_PIN_LEN);
- char *temp_ip;
- temp_ip = strdup(la_ip);
+ char *temp_pin;
+ temp_pin = strdup(la_pin);
- *ip_address = temp_ip;
+ *pin = temp_pin;
}
}
else
}
-int wifi_direct_get_mac_address(char **mac_address)
+int wifi_direct_generate_wps_pin(void)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
__WFD_CLIENT_FUNC_START__;
- if (NULL == mac_address)
- {
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [mac_address]!\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_LOW, "Client is NOT registered.\n");
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
- unsigned char la_mac_addr[6] = { 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_MAC;
+ req.cmd = WIFI_DIRECT_CMD_GENERATE_WPS_PIN;
req.client_id = client_info->client_id;
status =
sizeof(wifi_direct_client_request_s));
if (status != WIFI_DIRECT_ERROR_NONE)
{
- WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! writing to socket, Errno = %s\n",
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
strerror(errno));
- WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n",
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
__wfd_print_error(status));
- close(client_info->sync_sockfd);
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
}
__wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
sizeof(wifi_direct_client_response_s))) <= 0)
{
- WFD_CLIENT_LOG(WFD_LOG_LOW,
+ 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_MAC)
+ if (rsp.cmd == WIFI_DIRECT_CMD_GENERATE_WPS_PIN)
{
if (rsp.result != WIFI_DIRECT_ERROR_NONE)
{
else
{
WFD_CLIENT_LOG(WFD_LOG_LOW,
- "wifi_direct_get_mac_addr() SUCCESS \n");
- strncpy((char *) la_mac_addr, (char *) rsp.param2,
- strlen(rsp.param2));
-
- char *temp_mac = NULL;
- temp_mac = (char *) calloc(1, 18);
-
- sprintf(temp_mac, MACSTR, MAC2STR(la_mac_addr));
-
- *mac_address = temp_mac;
-
+ "wifi_direct_generate_wps_pin() SUCCESS \n");
}
}
else
}
-int wifi_direct_get_state(wifi_direct_state_e * state)
+int wifi_direct_get_supported_wps_mode(int *wps_mode)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
__WFD_CLIENT_FUNC_START__;
- if (NULL == state)
- {
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [state]!\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_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;
memset(&req, 0, sizeof(wifi_direct_client_request_s));
memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
- req.cmd = WIFI_DIRECT_CMD_GET_LINK_STATUS;
+ req.cmd = WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE;
req.client_id = client_info->client_id;
ret =
}
else
{
- if (rsp.cmd == WIFI_DIRECT_CMD_GET_LINK_STATUS)
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE)
{
if (rsp.result != WIFI_DIRECT_ERROR_NONE)
{
- WFD_CLIENT_LOG(WFD_LOG_LOW,
- "Error!!! Result received = %d %s\n", rsp.result,
+ 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, "Link Status = %d \n",
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Supported wps config = [%d]\n",
(int) rsp.param1);
- *state = (wifi_direct_state_e) rsp.param1;
+ *wps_mode = rsp.param1;
}
}
else
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_NONE;
+
}
-int wifi_direct_get_config_data(wifi_direct_config_data_s ** config)
+int wifi_direct_foreach_supported_wps_types(wifi_direct_supported_wps_type_cb callback, void* user_data)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
- if (config == NULL)
+ if (callback == NULL)
{
- WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [config]!\n");
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [callback]!\n");
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
}
wifi_direct_client_request_s req;
wifi_direct_client_response_s rsp;
- wfd_config_data_s ls_config;
- int status = WIFI_DIRECT_ERROR_NONE;
+ int ret = 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_CONFIG;
+ req.cmd = WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE;
req.client_id = client_info->client_id;
- status =
+ ret =
__wfd_client_send_request(client_info->sync_sockfd, &req,
sizeof(wifi_direct_client_request_s));
- if (status != WIFI_DIRECT_ERROR_NONE)
+ if (ret != 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));
+ __wfd_print_error(ret));
client_info->sync_sockfd = -1;
__wfd_reset_control();
__WFD_CLIENT_FUNC_END__;
return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
}
- if ((status =
+ if ((ret =
__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));
+ "Error!!! reading socket, status = %d errno = %s\n", ret,
+ strerror(errno));
client_info->sync_sockfd = -1;
__wfd_reset_control();
__WFD_CLIENT_FUNC_END__;
}
else
{
- if (rsp.cmd == WIFI_DIRECT_CMD_GET_CONFIG)
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE)
{
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_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
{
- int status = 0;
-
- WFD_CLIENT_LOG(WFD_LOG_LOW, "Link status = %d \n",
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Supported wps config = [%d]\n",
(int) rsp.param1);
+ int wps_mode;
+ bool result;
+
+ wps_mode = rsp.param1;
- status =
- __wfd_client_read_more_data(client_info->sync_sockfd,
- &ls_config,
- sizeof(wfd_config_data_s));
- if (status != WIFI_DIRECT_ERROR_NONE)
- {
+ if (wps_mode & WIFI_DIRECT_WPS_TYPE_PBC)
+ result = callback(WIFI_DIRECT_WPS_TYPE_PBC, user_data);
+
+ if ((result == true) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY))
+ result = callback(WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY, user_data);
+
+
+ if ((result == true) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD))
+ result = callback(WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD, user_data);
+ }
+ }
+ 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_wps_type(wifi_direct_wps_type_e type)
+{
+ 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 (type == WIFI_DIRECT_WPS_TYPE_PBC
+ || type == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY
+ || type == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Param wps_mode [%d]\n", type);
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Invalid Param [wps_mode]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ 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_CURRENT_WPS_MODE;
+ 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, &type,
+ sizeof(wifi_direct_wps_type_e));
+ 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_CURRENT_WPS_MODE)
+ {
+ 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_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_wps_type(wifi_direct_wps_type_e* type)
+{
+ 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 (type == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [type]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+ wfd_config_data_s ls_config;
+
+ 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_CONFIG;
+ 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_CONFIG)
+ {
+ 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
+ {
+ int status = 0;
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Link status = %d \n",
+ (int) rsp.param1);
+
+ status =
+ __wfd_client_read_more_data(client_info->sync_sockfd,
+ &ls_config,
+ sizeof(wfd_config_data_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "socket read error.\n");
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ __wfd_client_print_config_data(&ls_config);
+
+ *type = ls_config.wps_config;
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_wps_type() 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_set_ssid(const char *ssid)
+{
+ 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 == ssid)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [ssid]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "ssid = [%s]\n", ssid);
+
+ 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_SSID;
+ 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, ssid,
+ WIFI_DIRECT_MAX_SSID_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_SSID)
+ {
+ 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_ssid(char **ssid)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == ssid)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [ssid]!\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_ssid[WIFI_DIRECT_MAX_SSID_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_SSID;
+ 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_SSID)
+ {
+ 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_ssid() %s SUCCESS \n",
+ rsp.param2);
+ strncpy(la_ssid, rsp.param2, WIFI_DIRECT_MAX_SSID_LEN);
+
+ char *temp_ssid = NULL;
+ temp_ssid = strdup(la_ssid);
+ if (NULL == temp_ssid)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for SSID\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *ssid = temp_ssid;
+ }
+
+ }
+ 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)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == name)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [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_state_e status = 0;
+ int result;
+ result = wifi_direct_get_state(&status);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_state() state=[%d], result=[%d]\n", status, result);
+
+ if( status < WIFI_DIRECT_STATE_CONNECTED)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Device is not connected!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+
+ char* get_str = NULL;
+ get_str = vconf_get_str(VCONFKEY_IFNAME);
+
+ if (get_str == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "vconf (%s) value is NULL!!!\n", VCONFKEY_IFNAME);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "VCONFKEY_IFNAME(%s) : %s\n", VCONFKEY_IFNAME, get_str);
+
+ char *temp_ifname = NULL;
+ temp_ifname = strdup(get_str);
+ if (NULL == temp_ifname)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for ifname.\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *name = temp_ifname;
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+
+int wifi_direct_get_ip_address(char **ip_address)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == ip_address)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [ip_address]!\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_state_e state = 0;
+ int result;
+ result = wifi_direct_get_state(&state);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_state() state=[%d], result=[%d]\n", state, result);
+
+ if( state < WIFI_DIRECT_STATE_CONNECTED)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Device is not connected!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+
+ char* get_str = NULL;
+ get_str = vconf_get_str(VCONFKEY_LOCAL_IP);
+
+ if (get_str == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "vconf (%s) value is NULL!!!\n", VCONFKEY_LOCAL_IP);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "VCONFKEY_LOCAL_IP(%s) : %s\n", VCONFKEY_LOCAL_IP, get_str);
+
+ char *temp_ip = NULL;
+ temp_ip = strdup(get_str);
+ if (NULL == temp_ip)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for local ip address.\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *ip_address = temp_ip;
+ }
+
+
+#if 0
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+ char la_ip[64] = { 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_IP_ADDR;
+ 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_IP_ADDR)
+ {
+ 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_ip_address() SUCCESS \n");
+ strncpy(la_ip, rsp.param2, strlen(rsp.param2));
+
+ char *temp_ip = NULL;
+ temp_ip = strdup(la_ip);
+ if (NULL == temp_ip)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for IP address\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *ip_address = temp_ip;
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+#endif
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_subnet_mask(char** subnet_mask)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == subnet_mask)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [subnet_mask]!\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_state_e status = 0;
+ int result;
+ result = wifi_direct_get_state(&status);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_state() state=[%d], result=[%d]\n", status, result);
+
+ if( status < WIFI_DIRECT_STATE_CONNECTED)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Device is not connected!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+
+
+ char* get_str = NULL;
+ get_str = vconf_get_str(VCONFKEY_SUBNET_MASK);
+
+ if (get_str == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "vconf (%s) value is NULL!!!\n", VCONFKEY_SUBNET_MASK);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "VCONFKEY_SUBNET_MASK(%s) : %s\n", VCONFKEY_SUBNET_MASK, get_str);
+
+ char *temp_subnetmask = NULL;
+ temp_subnetmask = strdup(get_str);
+ if (NULL == temp_subnetmask)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for subnet mask.\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *subnet_mask = temp_subnetmask;
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_gateway_address(char** gateway_address)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == gateway_address)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [gateway_address]!\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_state_e status = 0;
+ int result;
+ result = wifi_direct_get_state(&status);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_state() state=[%d], result=[%d]\n", status, result);
+
+ if( status < WIFI_DIRECT_STATE_CONNECTED)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Device is not connected!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+
+ char* get_str = NULL;
+ get_str = vconf_get_str(VCONFKEY_GATEWAY);
+
+ if (get_str == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "vconf (%s) value is NULL!!!\n", VCONFKEY_GATEWAY);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "VCONFKEY_GATEWAY(%s) : %s\n", VCONFKEY_GATEWAY, get_str);
+
+ char *temp_gateway = NULL;
+ temp_gateway = strdup(get_str);
+ if (NULL == temp_gateway)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for gateway address.\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *gateway_address = temp_gateway;
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_mac_address(char **mac_address)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == mac_address)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [mac_address]!\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_LOW, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+#if 0
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+ unsigned char la_mac_addr[6] = { 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_MAC;
+ 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_LOW, "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ close(client_info->sync_sockfd);
+ __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_LOW,
+ "Error!!! reading socket, status = %d errno = %s\n",
+ status, strerror(errno));
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_DEVICE_MAC)
+ {
+ 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_mac_addr() SUCCESS \n");
+ strncpy((char *) la_mac_addr, (char *) rsp.param2,
+ strlen(rsp.param2));
+
+ char *temp_mac = NULL;
+ temp_mac = (char *) calloc(1, 18);
+ if (NULL == temp_mac)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for MAC address\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ sprintf(temp_mac, MACSTR, MAC2STR(la_mac_addr));
+
+ *mac_address = temp_mac;
+
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+
+#else
+ int fd;
+ int n;
+ char mac_info[18];
+ unsigned char la_mac_addr[6];
+
+ memset(mac_info, 0, sizeof(mac_info));
+
+ if( (fd = open(WIFI_DIRECT_MAC_ADDRESS_INFO_FILE, O_RDONLY)) == -1)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "[.mac.info] file open failed.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ n = read(fd, mac_info, 18);
+ if(n < 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "[.mac.info] file read failed.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "mac_address = [%s]\n", mac_info);
+
+ memset(la_mac_addr, 0, sizeof(la_mac_addr));
+ macaddr_atoe(mac_info, la_mac_addr);
+ la_mac_addr[0] = la_mac_addr[0] | 0x02;
+ la_mac_addr[1] = la_mac_addr[1];
+ la_mac_addr[2] = la_mac_addr[2];
+ la_mac_addr[3] = la_mac_addr[3];
+ la_mac_addr[4] = la_mac_addr[4];
+ la_mac_addr[5] = la_mac_addr[5];
+
+ char *temp_mac = NULL;
+ temp_mac = (char *) calloc(1, 18);
+ if (NULL == temp_mac)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for MAC address\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ //strncpy(temp_mac, mac_info, strlen(mac_info));
+ snprintf(temp_mac, 18, MACSTR, MAC2STR(la_mac_addr));
+
+ *mac_address = temp_mac;
+
+#endif
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_state(wifi_direct_state_e * state)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == state)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [state]!\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;
+
+ int ret = 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_LINK_STATUS;
+ req.client_id = client_info->client_id;
+
+ ret =
+ __wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (ret != 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(ret));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((ret =
+ __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", ret,
+ 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_LINK_STATUS)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW,
+ "Error!!! Result received = %d %s\n", rsp.result,
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Link Status = %d \n",
+ (int) rsp.param1);
+ *state = (wifi_direct_state_e) rsp.param1;
+
+ /* for CAPI : there is no WIFI_DIRECT_STATE_GROUP_OWNER type in CAPI */
+ if(*state == WIFI_DIRECT_STATE_GROUP_OWNER)
+ *state = WIFI_DIRECT_STATE_CONNECTED;
+
+ }
+ }
+ 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_is_discoverable(bool* discoverable)
+{
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (discoverable == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [discoverable]!\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;
+
+ 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_IS_DISCOVERABLE;
+ 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_IS_DISCOVERABLE)
+ {
+ 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_is_discoverable() %s SUCCESS \n",
+ rsp.param2);
+ *discoverable = (bool) rsp.param1;
+ }
+ }
+ 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_primary_device_type(wifi_direct_primary_device_type_e* type)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == type)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [type]!\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;
+ }
+
+
+ int result;
+ wifi_direct_config_data_s *config;
+ result = wifi_direct_get_config_data(&config);
+ if(result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to get wifi_direct_get_config_data() result=[%d]\n", result);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Current primary_dev_type [%d]\n", config->primary_dev_type);
+
+ *type = config->primary_dev_type;
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_config_data(wifi_direct_config_data_s ** config)
+{
+ 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 (config == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [config]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+ wfd_config_data_s ls_config;
+
+ 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_CONFIG;
+ 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_CONFIG)
+ {
+ 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
+ {
+ int status = 0;
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Link status = %d \n",
+ (int) rsp.param1);
+
+ status =
+ __wfd_client_read_more_data(client_info->sync_sockfd,
+ &ls_config,
+ sizeof(wfd_config_data_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
WFD_CLIENT_LOG(WFD_LOG_ERROR, "socket read error.\n");
return WIFI_DIRECT_ERROR_OPERATION_FAILED;
}
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
if (config == NULL)
}
+int wifi_direct_set_autoconnection_mode(bool mode)
+{
+ 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;
+
+ 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_AUTOCONNECTION_MODE;
+ 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, &mode,
+ sizeof(bool));
+ 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_AUTOCONNECTION_MODE)
+ {
+ 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_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_p2poem_loglevel(int increase_log_level)
{
wifi_direct_client_info_s *client_info = __wfd_get_control();
{
WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
__WFD_CLIENT_FUNC_END__;
- return WIFI_DIRECT_ERROR_STRANGE_CLIENT;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
}
wifi_direct_client_request_s req;