![Mediatek Labs LinkIt Connect 7681 Скачать руководство пользователя страница 43](http://html1.mh-extra.com/html/mediatek-labs/linkit-connect-7681/linkit-connect-7681_developers-manual_1760804043.webp)
MediaTek LinkIt™ Connect 7681 Developer's Guide
© 2015, 2016 MediaTek Inc.
Page 38 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.
When the user taps
Start
, the app runs to
JNI_StartSmartConnection()
that calls
StartSmartConnection
to begin broadcasting. The code for this is shown below:
File: IoTManage_jni.cpp
static jint JNI_StartSmartConnection(JNIEnv *env, jobject thiz, jstring
nSSID, jstring nPassword, jbyte nAuth)
{
int iRst = 0;
const char *pSSID = NULL;
const char *pPassword = NULL;
pSSID = env->GetStringUTFChars(nSSID, 0);
pPassword = env->GetStringUTFChars(nPassword, 0);
iRst = StartSmartConnection(pSSID, pPassword, (char)nAuth);
if (iRst != 0)
{
HWTEST_LOGD("StartSmartConnection error.");
}
HWTEST_LOGD("Leave JNI_StartSmartConnection.");
return iRst;
}
When the device containing the MT7681 is turned on, it will enter Smart Connection mode, receive
the broadcast packets and attempt to connect to the defined AP.
During this process the MT7681 writes a log to UART, here is an example:
==> Recovery Mode /*start to running recovery/Calibration image*/
<== Recovery Mode /* end to running recovery/Calibration image*/
(-) /* start to running station image*/
SM=0, Sub=0 /* Change to “WIFI_STATE_INIT” */
SM=1, Sub=0 /* Change to “WIFI_STATE_SMTCNT” */
[WTask]5001 /*--output timer log period to notice system alive--*/
SM=2, Sub=0 /* Change to “WIFI_STATE_SCAN” */
SM=3, Sub=0 /* Change to “WIFI_STATE_AUTH”, is going to send Auth
Request*/
Auth with:ssid = RalinkAP, auth mode = 0, /*--output the target AP’s
information “SSID, AuthMode”-- */
SM=3, Sub=1 /* Change to “WIFI_STATE_AUTH” is waiting Auth
Response*/
SM=4, Sub=0 /* Change to “WIFI_STATE_ASSOC”, is going to send Assoc
Request*/
SM=4, Sub=1 /* Change to “WIFI_STATE_ASSOC”, is waiting Assoc
Response */
[WTask]10005
SM=6, Sub=0 /* Change to “WIFI_STATE_CONNED”, start to get IP*/
[WTask]15006
Got IP:192.168.2.12/* Got IP from target AP*/
[WTask]20009
When MT7681 completes the Smart Connection process (it has connected to the target AP and
obtained an IP address), it will store the configuration to Flash. Then, when MT7681 restarts it will
load the setting from Flash and directly go to Scan state, instead of Smart Connection state.