Mediatek Labs LinkIt Developer's Manual

Development platform for rtos wi-fi

Advertisement

Quick Links

MediaTek LinkIt™ Development
Platform for RTOS Wi-Fi Developer's
Guide
Version:
Release date:
© 2015 - 2017 MediaTek Inc.
This document contains information that is proprietary to MediaTek Inc. ("MediaTek") and/or its licensor(s). MediaTek cannot grant you
permission for any material that is owned by third parties. You may only use or reproduce this document if you have agreed to and been
bound by the applicable license agreement with MediaTek ("License Agreement") and been granted explicit permission within the License
Agreement ("Permitted User"). If you are not a Permitted User, please cease any access or use of this document immediately. Any
unauthorized use, reproduction or disclosure of this document in whole or in part is strictly prohibited. THIS DOCUMENT IS PROVIDED ON AN
"AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF ANY KIND AND SHALL IN NO EVENT BE LIABLE FOR ANY
CLAIMS RELATING TO OR ARISING OUT OF THIS DOCUMENT OR ANY USE OR INABILITY TO USE THEREOF. Specifications contained herein are
subject to change without notice.
1.7
15 September 2017

Advertisement

Table of Contents
loading

Summary of Contents for Mediatek Labs LinkIt

  • Page 1 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Version: Release date: 15 September 2017 © 2015 - 2017 MediaTek Inc. This document contains information that is proprietary to MediaTek Inc. (“MediaTek”) and/or its licensor(s). MediaTek cannot grant you permission for any material that is owned by third parties. You may only use or reproduce this document if you have agreed to and been bound by the applicable license agreement with MediaTek (“License Agreement”) and been granted explicit permission within the License...
  • Page 2 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Document Revision History Revision Date Description 7 March 2016 Initial release 22 April 2016 • Wi-Fi WPS connection support. • Replaced NVRAM with NVDM. • Changed the API naming to register and unregister an event handler, such as replacing the wifi_connection_register_event_notifier() with wifi_connection_register_event_handler().
  • Page 3: Table Of Contents

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Table of Contents Overview ............................... 1 1.1. Supported features ..........................1 1.2. Supported libraries ..........................2 1.3. Software architecture of the Wi-Fi module ..................2 Using the Module ..........................4 2.1.
  • Page 4 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Lists of Tables and Figures Table 1. Supported features of different chipsets ....................1 Table 2. Libraries for the Wi-Fi mode configuration ....................2 Table 3. Configuration functions ..........................4 Table 4. The supported security modes ........................6 Table 5.
  • Page 5: Overview

    MediaTek MT7687, MT7697, MT7686, MT7682 and MT5932 chipsets are based on Wi-Fi System-on-Chip (SOC) with embedded TCP/IP stack for Internet of Things (IoT) devices that can connect to other smart devices or to cloud applications and services directly. MediaTek LinkIt™ software development kit (SDK) provides API and example applications for the Wi-Fi module.
  • Page 6: Supported Libraries

    Software architecture of the Wi-Fi module There are three software layers: Driver, Middleware and Application, as shown in Figure 1. The Wi-Fi module is located in Middleware. For more details, refer to LinkIt for RTOS get started guide. © 2015 - 2017 MediaTek Inc.
  • Page 7 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Figure 1. Software architecture © 2015 - 2017 MediaTek Inc. Page 3 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.
  • Page 8: Using The Module

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Using the Module The Wi-Fi module can only be applied once the settings are configured at system reboot. Apply your settings in the wifi_init() API to initialize the driver in STA or AP mode. To configure the board as a repeater, see section 2.2, “Using the Wi-Fi module in AP mode”.
  • Page 9: The Ap Router Operates In Open Mode

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide • wifi_config_set_ssid() • wifi_config_set_wep_key() • wifi_config_set_wpa_psk_key() The configuration APIs use in-band mechanism for Wi-Fi driver and Wi-Fi firmware communication, thus these APIs must be called after the OS task scheduler has started, to make sure an in-band task is running. The function wifi_config_register_rx_handler() registers wifi_rx_handler() to manage the raw packets.
  • Page 10: The Ap Router Operates In Wpa2Psk Authentication Mode

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide 2.1.2. The AP router operates in WPA2PSK authentication mode 1) In this example, the AP router operates in WPA2PSK authentication mode with AES encryption type, the password is "12345678" and the SSID of the AP router is "REMOTE_AP". Initialize the module in STA mode, as shown below.
  • Page 11: The Ap Router Operates In Open Wep Mode

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide wifi_config_reload_setting(); The STA mode supports various types of security modes, as shown in Table 4. For more information about the authentication mode and encryption group types, refer to wifi_auth_mode_t and wifi_encrypt_type_t types in the Wi-Fi API Reference Manual.
  • Page 12: Two Ap Routers Operate In Wpa2Psk Authentication Mode

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide 2.1.4. Two AP routers operate in WPA2PSK authentication mode 1) In this example, two AP routers (AP1 and AP2) operate in WPA2PSK authentication mode with AES encryption type. The password of each AP is "12345678" and the SSID of both routers is "REMOTE_AP".
  • Page 13: Wi-Fi Connection Support

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide a) Initialize the wifi_config_ext_t structure, as shown below. Set config_ext.sta_auto_connect_present to 1 to enable the presence of config_ext.sta_auto_connect. wifi_config_ext_t config_ext; config_ext.sta_auto_connect_present = 1; config_ext.sta_auto_connect = 1; // Enable the auto connect.
  • Page 14 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide uint8_t status = 0; status = wifi_connection_disconnect_ap(); 3) Register or unregister an event handler. The event handlers to register or unregister events are listed in Table 5. The table shows the supported events generated by the Wi-Fi driver.
  • Page 15 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Event Description from. 0, STA port; 1, AP port.  WIFI_EVENT_IOT_REPORT_BEACON_PROBE • This event is triggered when beacon or probe response is _RESPONSE received during scan process (see the wifi_event_t enumeration).
  • Page 16 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide /* Register event handler */ uint8_t status = 0; int user_event_callback(wifi_event_t event_id, unsigned char *payload, unsigned int len) /* The handler is triggered when the device connects to an AP router*/ int handled = 0;...
  • Page 17: Using The Wi-Fi Module In Ap Mode

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide status = wifi_connection_register_event_handler(WIFI_EVENT_IOT_DISCONNECTED, (wifi_event_handler_t) user_event_callback); status = wifi_connection_register_event_handler(WIFI_EVENT_IOT_PORT_SECURE, (wifi_event_handler_t) user_event_callback); /* Unregister event handler */ status = wifi_connection_unregister_event_handler(WIFI_EVENT_IOT_CONNECTED, (wifi_event_handler_t) user_event_callback); status = wifi_connection_unregister_event_handler(WIFI_EVENT_IOT_SCAN_COMPLETE, (wifi_event_handler_t) user_event_callback); status = wifi_connection_unregister_event_handler(WIFI_EVENT_IOT_DISCONNECTED, (wifi_event_handler_t) user_event_callback); status = wifi_connection_unregister_event_handler(WIFI_EVENT_IOT_PORT_SECURE, (wifi_event_handler_t) user_event_callback);...
  • Page 18 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Table 6. Configuration and connection APIs in the AP mode Description wifi_config_set_opmode() This function sets the Wi-Fi operation mode and it takes effect immediately. wifi_config_set_ssid() This function sets the SSID and SSID length that Wi- Fi driver uses for a specific wireless port.
  • Page 19: Use The Device In Ap Open Mode

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Description wifi_connection_register_event_handler() This function registers the Wi-Fi Event handler. wifi_connection_unregister_event_handler() This function unregisters Wi-Fi Event handler. wifi_connection_disconnect_sta() This function disconnects the connected Wi-Fi station. wifi_connection_get_sta_list() This function gets the Wi-Fi Associated Station List.
  • Page 20: Use The Device In Ap Mode With Wpa2Psk Method

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Call the function wifi_config_set_channel(port, channel) to setup the channel on a given port, as shown below. wifi_config_set_channel(WIFI_PORT_AP, 6); Apply the configuration by calling the function wifi_config_reload_setting(), as shown below. wifi_config_reload_setting(); 2.2.2.
  • Page 21: Use The Device In Ap Mode With Open Wep Method

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide wifi_config_set_channel(WIFI_PORT_AP, 6); Apply the configuration by calling the function wifi_config_reload_setting(), as shown below. wifi_config_reload_setting(); The authentication and encryption method combinations are also available (see Table 4). 2.2.3. Use the device in AP mode with open WEP method 1) In this example, the device is in AP mode and operates on channel 6, the security mode is in open WEP mode with the key index is set to 0, the password is "1234567890"...
  • Page 22: Wi-Fi Connection Support

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Call the function wifi_config_set_ssid(port, ssid_name, strlen(ssid_name)) to set the SSID ("MTK_SOFT_AP") of a given port (WIFI_PORT_AP), as shown below. wifi_config_set_ssid(WIFI_PORT_AP, "MTK_SOFT_AP", strlen("MTK_SOFT_AP")); d) Call the function wifi_config_set_security_mode(port, auth, encrypt) to set the security mode of the AP router, as shown below.
  • Page 23: Using The Wi-Fi Module In A Repeater Mode

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide (unsigned int)(list[i].power_save_mode)); printf("bandwidth=%d\n", (unsigned int)(list[i].bandwidth)); printf("keep_alive=%d\n", (unsigned int)(list[i].keep_alive)); 2) Get the maximum number of stations the AP can support. Call the wifi_connection_get_max_sta_number() function to get the maximum number of stations supported in AP mode and dual mode.
  • Page 24: Using The Static Method

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide • The AP and APCLI should have the same bandwidth in repeater mode. • The AP and APCLI should stay on the same channel as the remote AP. • The repeater mode doesn’t support WPS.
  • Page 25: Using The Dynamic Method

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide config.ap_config.channel = 6; config.ap_config.bandwidth = WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_20MHZ; 3) Apply the settings by calling the wifi_init() function. wifi_init(&config, NULL); 2.3.3. Using the dynamic method Before applying this method, few assumptions to make: •...
  • Page 26: Scan

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide 2.4. Scan Scan modes and scan options are selected when scan function is executed. The modes and options are shown in Table 8 and Table 9. The Wi-Fi module supports scan mode and option combinations in the AP and station modes.
  • Page 27: Scan Apis

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Region ID Channel List CH36-64 active scan, CH100-140 active scan, CH149-165 active scan CH52-64 active scan CH36-64 active scan, CH100-116 active scan, CH132-140 active scan, CH149-165 active scan CH36-48 active scan, CH149-165 active scan...
  • Page 28 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Definition wifi_connection_start_scan(). This function de-initializes the scan table. When the scan is wifi_connection_scan_deinit (void) finished, wifi_connection_scan_deinit() should be called to unload the buffer from the driver. After that, the data in the ap_list can be processed by user applications safely, and then another scan can be initialized by calling wifi_connection_scan_init().
  • Page 29 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Note 1. The scan table g_ap_list is a user-defined array initialized inwifi_connection_scan_init(). It’s required to call wifi_connection_scan_deinit() after the scan process is complete. Otherwise, calling the function wifi_connection_scan_init() again will fail.
  • Page 30: Smart Connection

    SmartConnection, an Android application package (APK) built with the Smart Connection library, so that the IoT device based on the LinkIt development platform can listen and decode the information to connect to the specified wireless network, as shown in Figure 3. The broadcast information is encrypted with a pre-defined key to ensure security.
  • Page 31: How To Use The Smart Connection Api

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Table 13. Smart Connection APIs Definition wifi_smart_connection_init( This function sets a decryption key and registers a callback function to establish the Smart Connection. const uint8_t *key, The callback function handles the connection result.
  • Page 32: Monitor Mode And Rx Filter

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide uint8_t ssid[WIFI_MAX_LENGTH_OF_SSID + 1] = {0}; uint8_t ssid_len = 0; uint8_t password_len = 0; switch (event) case WIFI_SMART_CONNECTION_EVENT_CHANNEL_LOCKED: case WIFI_SMART_CONNECTION_EVENT_TIMEOUT: break; case WIFI_SMART_CONNECTION_EVENT_INFO_COLLECTED: wifi_smart_connection_get_result(ssid, &ssid_len, password, &password_len, NULL, NULL); /* Configure the STA with the received SSID & passward. */ wifi_config_set_ssid(WIFI_PORT_STA, ssid, ssid_len);...
  • Page 33: How To Receive Raw Packets

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Input Parameter Description cannot be 0. WIFI_RX_FILTER_DROP_PROBE_REQ bit 4, drops probe request frame. WIFI_RX_FILTER_DROP_MC_FRAME bit 5, drops multicast frame. WIFI_RX_FILTER_DROP_BC_FRAME bit 6, drops broadcast frame. WIFI_RX_FILTER_RM_FRAME_REPORT_EN bit 12, enables report frames.
  • Page 34: Wps

    A device seeking to join a wireless network is called Enrollee. A device with the authority to issue and revoke access to a network is called Registrar. The LinkIt SDK provides APIs to modify default device configuration before triggering the WPS and new event handler to support credential callbacks. To set the WPS, apply the following steps.
  • Page 35: Using The Apis

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide Table 15. WPS APIs Function Description wifi_wps_config_set_device_info() This function sets the device information for WPS. Call this function before triggering WPS connection. wifi_wps_config_get_device_info() This function gets the device information for WPS.
  • Page 36 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide char * model_name = "MTK Wireless Device Test"; char * model_number = "MTK7687 Test"; char * serial_number = "87654321"; os_memset(&input_devinfo, 0, sizeof(input_devinfo)); //copy device_name if (strlen(device_name) < WIFI_WPS_DEVICE_NAME_LENGTH) os_memcpy(input_devinfo.device_name, device_name,strlen(device_name)); else { LOG_E(minisupp, "device_name length is too long\n");...
  • Page 37 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide An example implementation is shown below. int32_t wps_get_auto_connection_status_example() bool auto_conn = false; return wifi_wps_config_get_auto_connection(&auto_conn); 2.7.1.2. Register or unregister Wi-Fi WPS event handler To register Wi-Fi WPS credential handler: 1) Call wifi_connection_register_event_handler().
  • Page 38: Wi-Fi Wps Connection Support

    MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide 2.7.2. Wi-Fi WPS connection support Trigger Wi-Fi WPS connection using PBC (see section 2.7.2.1, "WPS PBC method") or PIN (see section 2.7.2.2, "WPS PIN method") method. Call the function wifi_wps_unregister_credential_handler(), to unregister the credential handler, as described in section 2.7.1.2, “Register or unregister Wi-Fi WPS event handler”.
  • Page 39 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide 2.7.2.2. WPS PIN method There are three cases when using the WPS PIN method to connect to the Wi-Fi network: • The access point as a Registrar. • The access point as an Enrollee.
  • Page 40 MediaTek LinkIt™ Development Platform for RTOS Wi-Fi Developer's Guide return wifi_wps_connection_by_pin( WIFI_PORT_STA, bssid, pin); Another approach to get the PIN code is to call the API described in section 2.7.2.3, "WPS get the PIN code". An example implementation is shown below.

Table of Contents