![Mediatek Labs LinkIt Developer'S Manual Download Page 31](http://html1.mh-extra.com/html/mediatek-labs/linkit/linkit_developers-manual_1760805031.webp)
MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
© 2015 - 2017 MediaTek Inc.
Page 27 of 36
This document contains information that is proprietary to MediaTek Inc. (“MediaTek”) and/or its licensor(s).
Any unauthorized use, reproduction or disclosure of this document in whole or in part is strictly prohibited.
Table 13. Smart Connection APIs
API
Definition
wifi_smart_connection_init(
const uint8_t *key,
const uint8_t key_length,
wifi_smart_connection_callback_t callback)
This function sets a decryption key and registers a
callback function to establish the Smart Connection.
The callback function handles the connection result.
wifi_smart_connection_deinit()
This function de-initializes the smart connection and
releases the allocated resources.
wifi_smart_connection_start(
uint16_t timeout_seconds)
This function starts the Smart Connection. Waiting
for the broadcast message. The timeout specifies
the duration the device listens to the broadcast
message. The Smart Connection is considered as
failed, if timeout is reached.
wifi_smart_connection_get_result(
uint8_t *ssid,
uint8_t *ssid_length,
uint8_t *password,
uint8_t *password_length,
uint8_t *tlv_data,
uint8_t *tlv_data_length)
This function gets the wireless network information
(SSID and password) collected during the Smart
Connection. The type length value (TLV) data is
user-defined data sent from the Smart Connection
mobile application.
wifi_smart_connection_stop()
This function stops the Smart Connection.
2.5.2.
How to use the Smart Connection API
1)
Call the function
wifi_smart_connection_init()
to initialize the Smart Connection and then call the
function
wifi_smart_connection_start()
to start the Smart Connection process.
2)
Define the
wifi_smart_connection_callback_t
callback function to process a Smart Connection
event.
When the WIFI_SMART_CONNECTION_EVENT_INFO_COLLECTED event is received, apply the function
wifi_smart_connection_get_result()
to get the SSID and the password. Then proceed with the
rest of the implementation, such as calling the function
wifi_config_reload_setting()
to connect
to the target AP or to store the received information into flash.
int32_t user_smart_connection(void)
{
if(wifi_smart_connection_init(NULL, 0, smart_connection_event_handler)
< 0){
return -1;
}
wifi_smart_connection_start(0);
return 0;
}
void smart_connection_event_handler(wifi_smart_connection_event_t event,
void *data)
{
uint8_t password[WIFI_LENGTH_PASS 1] = {0};