MCU SDK Test for Wi-Fi Gateway

Last Updated on : 2024-05-14 08:00:15download

When you use the gateway MCU SDK to connect to Tuya’s gateway Wi-Fi module, you must conduct production tests before the embedded application development is completed and the finished product is produced.

Purpose

The production test is intended to check whether the gateway module works properly, whether the radio frequency works properly, and whether the module can be networked. You can also use the production test to check whether the serial communication between the MCU and the gateway module is normal and whether the data is sent and received as expected.

Process

After the MCU and the gateway are powered on and the production test conditions are triggered, the MCU sends a command to instruct the gateway to scan the specified router. The gateway will scan the wireless hotspot named tuya_mdev_test, and then return the result to the MCU. The MCU parses the returned result to determine whether the production test is passed. This process can be repeated.

MCU SDK Test for Wi-Fi Gateway

MCU code implementation

The MCU code implements the conditions that trigger the production test, completes the SDK for the production test process, and displays the production test results. It is recommended to add prompts at important nodes in the production test process to facilitate the operation. For example,

  • When the production test is triggered successfully, a short buzzing sound is generated.
  • When the device is working as expected, the indicator is always on.
  • After the production test command is sent, no response is returned. In this case, the indicator flickers quickly.
  • After the production test result is received, the indicator is always on if the production test is passed and flickers slowly if the test fails.

Trigger the production test

In most cases, you can trigger the production test by button operations. For example, press and hold the power button for three seconds. It can also be triggered in other ways. We recommend that common operations are not used to trigger the production test. Otherwise, this type of operation during the normal use of the product might trigger the production test.

  1. Complete the production test process code in the SDK.

    1. In the protocol.h file in the SDK package, run the macro WIFI_TEST_ENABLE.
    2. After completing the production test trigger conditions, call the mcu_start_wifitest() function in the mcu_api.c file. The MCU sends the command of scanning the specified router to the gateway, and the gateway will scan the tuya_mdev_test hotspot.
    3. In the protocol.h file in the SDK package, configure the wifi_test_result function.
  2. Show production test results.

    When you configure the wifi_test_result function, you can add processing functions such as LED, buzzer, and display screen to display the production test results. They must be easy to use, and the process is as simple as possible.

Build a production test environment

Prepare a router (a computer or mobile phone) to create a hotspot, set the hotspot name to tuya_mdev_test. The name is written by the firmware and cannot be changed. The frequency is 2.4 GHz.

Production line operation

Determine whether the product is qualified according to the method of entering the production test developed by the MCU and the display of the results.

The operation process of the production line is shown as follows.

MCU SDK Test for Wi-Fi Gateway