![Texas Instruments CC3220 Скачать руководство пользователя страница 60](http://html.mh-extra.com/html/texas-instruments/cc3220/cc3220_programmers-manual_1094609060.webp)
Wi-Fi Direct
60
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
WLAN
Status = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE, SL_NETCFG_ADDR_DHCP,0,0);
if
( Status )
{
/* error */
}
/* Set Device Name */
strcpy(my_p2p_device,
"sl_p2p_device"
);
Status = sl_NetAppSet (SL_NETAPP_DEVICE_ID, SL_NETAPP_DEVICE_URN, strlen(my_p2p_device), (_u8 *)
my_p2p_device);
if
( Status )
{
/* error */
}
/* set connection policy Auto-Connect and Fast*/
Status = sl_WlanPolicySet(SL_WLAN_POLICY_CONNECTION, SL_WLAN_CONNECTION_POLICY
(1
/*Auto*/
,1
/*Fast*/
, 0
/*OpenAP*/
,0
/*AnyP2P*/
,0
/*auto provisioning*/
), NULL, 0 );
/* set P2P Policy - intent 0, random backoff */
Status = sl_WlanPolicySet( SL_WLAN_POLICY_P2P, SL_WLAN_P2P_POLICY(SL_WLAN_P2P_ROLE_CLIENT
/*Intent
0 - Client*/
,
SL_WLAN_P2P_NEG_INITIATOR_RAND_BACKOFF
/*Negotiation initiator – random backoff*/
),NULL,0);
SecParams.Type = SL_WLAN_SEC_TYPE_P2P_PBC;
SecParams.Key =
""
;
SecParams.KeyLen = 0;
strcpy(remote_p2p_device,
"Remote_GO_Device_XX"
);
Status = sl_WlanProfileAdd(remote_p2p_device, strlen(remote_p2p_device),bssidEmpty,&SecParams
,NULL ,7,0);
if
( Status )
{
/* error */
}
//restart the device
Status = sl_Stop(100);
if
( Status )
{
/* error */
}
Role = sl_Start(NULL, NULL, NULL);
4.5.5 Events and Errors
The host can receive indication of specific states through events or errors. Asynchronous events can be
sent to the host at any given time with indication of the specific state and specific data for each event. To
listen to these events and determine the needed information, a handler should be implemented in the user
application, and registered under the user.h file. The following events may be received:
•
SL_WLAN_EVENT_P2P_CONNECT
Indicates that a Wi-Fi Direct connection was successfully completed. The device is Wi-Fi Direct
CLIENT and contains the remote device parameters:
–
SSID
–
SSID length
–
BSSID
–
Go device name
–
Go device name length
•
SL_WLAN_EVENT_P2P_DISCONNECT
Indicates that Wi-Fi Direct disconnect is successfully completed. The device is Wi-Fi Direct CLIENT
and contains the remote device parameters:
–
SSID