![Texas Instruments CC3220 Скачать руководство пользователя страница 41](http://html.mh-extra.com/html/texas-instruments/cc3220/cc3220_programmers-manual_1094609041.webp)
Station (STA)
41
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
WLAN
4.3.3 Connection
Connection to a WLAN network is one of the basic capabilities of the SimpleLink Wi-Fi device, and it is the
first step required before initializing socket communication. The SimpleLink Wi-Fi device supports two
methods of establishing a connection: manual connection and preferred networks.
Each of the following methods is combined with a predefined connection policy which instructs the
SimpleLink Wi-Fi device on how to act in different states. Indication of connection completion is performed
by an asynchronous event (see
4.3.3.1
Connection Policies
There are different ways to define the connection policy behavior of the device. These policies define how
the device initiates the connection, and helps to maintain a specific connection configuration after reset,
which is appropriate for the desired use case. The WLAN connection policy defines up to four options for
connecting the SimpleLink Wi-Fi device to a given AP.
The four options for the connection policy follow:
•
Auto – The device tries to connect to an AP from the stored profiles based on priority. Up to seven
profiles are supported. On the connection attempt, the device selects the highest priority profile. If
several profiles are within the same priority, the decision is made based on the security type (WPA \
WPA2 > WEP > OPEN). If the security type is also the same, the selection is based on the received
signal strength.
Set the Auto policy with the following macro: SL_WLAN_CONNECTION_POLICY(1,0,0,0)
•
Fast – The device tries to connect to the last connected AP. In this mode, the probe request is not
transmitted before the authentication request, as both the SSID and channel are known from previous
successful connection.
–
If the Auto policy is also enabled (Auto and Fast), then a profile exists and previous successful
connection was performed to this profile. After reset, the device tries to connect to the same profile
with no scan (no probe request transmission). If this connection fails, the device starts scanning
according to stored profile priority.
–
If the Fast policy is enabled independently and a previous successful connection exists, after reset
the device tries to connect to the same AP with no scan (no probe request transmission). If this
connection fails, no further scan is performed.
Set the Auto and Fast policy with the following macro: SL_WLAN_CONNECTION_POLICY(1,1,0,0)
•
AnyP2P – Relevant for Wi-Fi-Direct mode only. The device immediately tries to connect to the first Wi-
Fi direct device available, supporting push-button only.
Set the Auto and AnyP2P with the following macro: SL_WLAN_CONNECTION_POLICY(1,0,1,0)
•
Auto Provisioning – The device automatically starts the provisioning process if 2 seconds have passed
since reset without receiving any command from the host, while no saved profiles exist. Or the device
automatically starts the provisioning process after 2 minutes of disconnection, while saved profiles
exist (for more information, refer to
).
Set the Auto and Auto Provisioning with the following macro:
SL_WLAN_CONNECTION_POLICY(1,0,0,1)
More than one connection policy can be set, for example Auto and Fast and Auto provisioning. The
connection policy enabled by default is Auto and Auto Provisioning. Setting the connection policy takes
effect immediately. For example, if setting the Auto policy and profiles exists, a connection attempt to
the highest priority profile is immediately triggered. This configuration is persistent according to the
system-persistent configuration.
An example of an Auto and Fast and Auto provisioning connection policy follows:
_i16 Status;
Status
= sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_WLAN_CONNECTION_POLICY(1,1,0,1),NULL,0);
if
( Status )
{
/* error */
}