![Mediatek Labs LinkIt Connect 7681 Developer'S Manual Download Page 37](http://html1.mh-extra.com/html/mediatek-labs/linkit-connect-7681/linkit-connect-7681_developers-manual_1760804037.webp)
MediaTek LinkIt™ Connect 7681 Developer's Guide
© 2015, 2016 MediaTek Inc.
Page 32 of 65
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
4.5.
Wi-Fi State Machine (Station mode)
When MT7681 is in Station mode it provides a Wi-Fi state machine for the Wi-Fi connection. The
entry function for this state machine is
wifi_state_machine()
.
4.5.1.
States
There are in total 7 states, as shown in Figure 22:
•
WIFI_STATE_INIT
Initializes the Wi-Fi state machine and loads the target AP settings (SSID, Password,
AuthMode, and PMK) which are stored in Flash. If the settings are valid, the machine goes
to state
WIFI_STATE_SCAN
, otherwise it goes to
WIFI_STATE_SMTCNT
.
•
WIFI_STATE_SMTCNT
In this state the MT7681 will listen on Wi-Fi for a Smart Connection packet containing
target AP settings (SSID, Password, AuthMode, and PMK):
o
if a Smart Connection packet is received, the machine goes to
WIFI_STATE_SCAN
.
o
otherwise the machine goes back to
WIFI_STATE_INIT
.
If the AT command
AT#Smnt
is received, MT7681 will go into this state immediately.
•
WIFI_STATE_SCAN
When MT7681 gets target AP settings from
WIFI_STATE_INIT
or
WIFI_STATE_SMTCNT
, it
starts to switch channels and scan for the target AP.
o
if a probe response is received from the target AP, MT7681 will stay in the current
channel and check the AuthMode in the AP’s Probe response frame, and update
AuthMode setting to local. Then go to
WIFI_STATE_AUTH
.
o
if the expected probe response isn’t received within 10 seconds, MT7681 goes back to
WIFI_STATE_INIT
.
•
WIFI_STATE_AUTH
MT7681 sends a Management frame (Auth Request) to the AP, then:
o
if an Auth Response is received with the status code
0
(Auth successful), MT7681 goes
to
WIFI_STATE_ASSOC
.
o
if an Auth Response is received with status code not equal to
0
, a Deauth frame is
received from the target AP, or an Auth Response frame isn’t received within 300ms
after retrying 5 times, MT7681 goes to
WIFI_STATE_INIT
.
There are sub-states for the authentication process:
o
Sub-State =
0
, MT7681 is preparing to send Auth Request.
o
Sub-State =
1
, MT7681 is waiting for Auth Response.