Wi-Fi Direct
55
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
WLAN
device name is compound of the URN and two random characters. Users can set only the URN; the
random characters are internally generated. Default = mysimplelink_XX (xx = random two characters).
This configuration is persistent according to the system-persistent configuration.
Example:
_u8 device_name[] =
"Simple_WiFi_Direct"
;
_i16 Status;
Status = sl_NetAppSet (SL_NETAPP_DEVICE_ID,SL_NETAPP_DEVICE_URN, strlen(device_name), (_u8 *)
device_name);
if
( Status )
{
/* error */
}
•
Set Device Type
The following macro is used to set the Wi-Fi Direct device type. The device type is published under
P2P I.E. The device type is part of the Wi-Fi Direct discovery parameters, and is used to better
recognize the device. The maximum length is 17 characters. Default = 1-0050F204-1. This
configuration is persistent according to the system-persistent configuration.
Example:
_i16 Status;
_u8
str[17];
_u16
len = strlen(device_type);
memset(str, 0, 17);
memcpy(str, device_type, len);
Status
= sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, SL_WLAN_P2P_OPT_DEV_TYPE, len, str);
if
( Status )
{
/* error */
}
•
Set Listen and Operational Channels
The listen channel is used for the discovery state and the value can be 1, 6, or 11. The device stays in
this channel when waiting for Wi-Fi Direct probes requests. The operation channel is only used by the
GO device. The GO device moves to this channel after the negotiation phase. The default listen
channel is randomly assigned between channels 1, 6, or 11. This configuration is persistent according
to the system-persistent configuration. The regulatory domain class should be 81 in 2.4 G.
An example for setting the listen channel to 11 and the operational channel to 6 follows:
_u8 channels [4];
_i16 Status;
channels [0] = (unsigned char)11;
/* listen channel */
channels [1] = (unsigned char)81;
/* listen regulatory class */
channels [2] = (unsigned char)6;
/* operational channel */
channels [3] = (unsigned char)81;
/* operational regulatory class */
Status = sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, SL_WLAN_P2P_OPT_CHANNEL_N_REGS,4,channels);
if
( Status )
{
/* error */
}
4.5.3.2
Set Wi-Fi Direct Policy
The Wi-Fi Direct connection policy divides into two major configurations:
•
Wi-Fi Direct Intent Value
This value indicates in which Wi-Fi Direct mode the device acts (CLIENT, GO, or other). This
configuration is done by using the macro SL_WLAN_P2P_POLICY. Three defines can be used when
setting the intent:
1. SL_WLAN_P2P_ROLE_CLIENT (intent 0): Indicates that the device is forced to be CLIENT.