Last Updated on : 2024-11-20 02:13:27download
This topic describes four production test modes during production tests of Tuya Wi-Fi general modules. MCU developers select one or more production test commands as needed. They determine whether the production test succeeded based on the data returned by the Wi-Fi module.
This document will no longer be updated. If you want to learn more about MCU standard protocol, see MCU Standard Protocol. For production testing, refer to Production Testing.
During production, production test commands are used to test Wi-Fi module functions, and communication capability between modules and control panels.
Scan the designated router
In this mode, after receiving 0x0e
command from the MCU, the module scans the designated wireless signal and returns the signal strength value. According to the signal strength, the MCU determines whether the radio frequency (RF) performance of the Wi-Fi module is qualified. In this mode, the production test router is not connected to the internet. This mode features short duration and high production test efficiency. Multiple devices can be tested at the same time.
Connect the designated router
In this mode, through 0x2C
command word, the MCU sends the SSID and password of the production test router to the module. The module is connected to the router, and returns cloud communication status. Thus, the MCU determines whether the production test succeeded according to the returned network status. In this mode, the production test router shall be connected to the internet. Due to the limited carrying capacity of the router, not too many devices can be tested at the same time. Since a cloud connection test is carried out, the production test result is more reliable.
IR functional test
This mode is a separate infrared (IR) functional test. It tests whether IR receiving and transmitting pins work properly. Omit this mode if the relevant function is not used.
Bluetooth functional test This mode is a separate Bluetooth functional test, which detects the Bluetooth scanning results and signal strength percentage. Omit this mode if the relevant function is not used.
The method to trigger the production test can be defined by the MCU. After the module and the MCU have completed initialization data transmission, the MCU sends 0x0e command, and the module scans the designated router SSID of tuya_mdev_test
. The scanning result and signal strength percentage are returned, so the MCU determines whether the production test succeeded or failed according to signal strength.
tuya_mdev_test
. It is recommended that the distance between the router and the device should be about five meters.Prepare one 2.4 GHz wireless router that is connected to the internet, and set the router SSID as tuya_mdev_test
.
Trigger the production test and power on the device under test. The production test can be triggered after the module has completed the power-on initialization transmission. Triggering methods can be defined by developers. It is recommended to trigger the production test with rarely used combination buttons.
According to the connection condition, the developer can send a production test command to the module. The following two connections are supported.
MCU_SDK
is used After triggering of the production test is detected, you can call the mcu_start_wifitest()
function to enable the production test.
MCU_SDK
is not used See commands in the Wi-Fi functional test (scan the designated router) of the Wi-Fi general serial port protocol, and send the 0x0e
command to the module.
For example,
0x55 aa 03 0e 00 00
checksum
Field | Length (byte) | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x0e |
Data length | 2 | 0x0000 |
Data | Data | None |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Receive the returned data, and view the test result.
According to the connection condition (whether Tuya MCU_SDK
is used), you can view the test result.
MCU_SDK
is used
View the test result in the wifi_test_result
function of the protocol.c
file.
void wifi_test_result(unsigned char result,unsigned char rssi)
{
#error "Provide success/failure code of the Wi-Fi functional test, and delete this row on completion"
if(result == 0)
{
//Test failed
if(rssi == 0x00)
{
//The `tuya_mdev_test` router is not found
}
else if(rssi == 0x01)
{
//The module is not authorized
}
}
else
{
//Test succeeded
//RSSI is signal strength (0–100, 0 for the weakest signal, and 100 for the strongest signal
}
}
MCU_SDK
is not used
If you connect a serial port protocol, you can see commands in the Wi-Fi functional test (scan the designated router) of the Wi-Fi general serial port protocol, and view the test result according to the received data.
Note: The module returns
0x55 aa 00 0e 00 02 01 64
checksum. The signal strength is 100, meaning the production test succeeded.
The MCU sends the following command:
Field | Length (byte) | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x0e |
Data length | 2 | 0x0000 |
Data | Data | None |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
The module returns the following command:
Field | Length (byte) | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x0e |
Data length | 2 | 0x0002 |
Data | 2 |
|
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Show the test result. Based on the acquired data, the result can be prompted through voice, display, LED lights, and more.
The method to trigger the production test can be defined by the MCU. After the module has completed power-on initialization transmission, through the 0x2C
command, the MCU sends the SSID and password of the production test router to the module. After receiving pairing information, the Wi-Fi module connects the router to access the cloud, and returns the changes of network status. According to network status changes of the 0x03
command, the MCU determines whether the production test succeeded.
0x03
command (status 3: Wi-Fi has been configured and the router is connected).Prepare one 2.4 GHz wireless router that is connected to the internet, and make sure that network communication works properly.
Power on the device under test, and trigger the production test after the module has completed power-on initialization transmission. Triggering methods can be defined by you. It is recommended to trigger the production test with rarely used combination buttons.
According to the connection condition, the developer can send a production test command to the module. The following two connections are supported.
MCU_SDK
is used
After triggering of the production test is detected, you can call the mcu_start_connect_wifitest()
function to enable the production test. Fill in the SSID and password of the router.
MCU_SDK
is not used (integrate with the serial port protocol)
See commands in the Wi-Fi functional test (connected to the designated router) of the Wi-Fi general serial port protocol, and send the 0x2C
command to the module.
The MCU sends the following command:
Field | Length (byte) | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x2C |
Data length | 2 | xxxx |
Data | Data | {“ssid”:”xxx”,”password”:”xxxxxxxx”} ssid: router name password: router password |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Note: Data is transmitted in the hexadecimal format of ASCII codes.
Receive the returned data, and view the test result. According to the connection condition (whether Tuya MCU_SDK
is used), you can view the test result.
MCU_SDK
is used
View the test result in the wifi_connect_test_result
function of the protocol.c
file.
void wifi_connect_test_result(unsigned char result)
{
//#error "Provide success/failure code of the Wi-Fi functional test, and delete this row on completion"
if(result == 0)
{
// Failed to receive router information. Check whether the router information packet is an intact JSON data packet
}
else
{
// Router information is received successfully. In the production test result, pay attention to the Wi-Fi working status of the `WIFI_STATE_CMD` command
}
}
MCU_SDK
is not used
After the command of connecting the designated router is sent by the MCU and received by the Wi-Fi module, the Wi-Fi module returns the receipt result. The successful result means that serial port data transmission is successful. For the network connection test, pay attention to the data changes of the 0x03
command that is sent by the module during a network connection.
The module returns the following command:
Field | Length (byte) | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x2c |
Data length | 2 | 0x0001 |
Data | 1 |
|
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
For the router connection result, see the command of Reporting device network status in the protocol.
Field | Length (byte) | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x03 |
Data length | 2 | 0x0001 |
Data | 1 | Indicates Wi-Fi working status. 0x00: status 1 0x01: status 2 0x02: status 3 0x03: status 4 0x04: status 5 0x05: status 6 |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Show the test result. Based on the acquired data, the result can be prompted through voice, display, LED lights, and more.
IR receiving and transmitting tests are performed on modules that support IR functions.
Prepare one IR device and IR remote control.
Power on the device under test, and trigger the production test after the module has completed power-on initialization transmission. Triggering methods can be defined by you. It is recommended to trigger the production test with rarely used combination buttons.
According to the connection condition, the developer can send a production test command to the module. The following two connections are supported.
MCU_SDK
is used
After triggering of the production test is detected, you can call the mcu_start_ir_test()
function to enable the production test.
MCU_SDK
is not used
See the commands in Production test of IR receiving and sending of the general serial port protocol of Wi-Fi modules, and send corresponding data to the module.
Note: For example, the module returns
0x55 aa 03 2f 00 00
checksum.
The MCU sends the following command:
Field | Length (byte) | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x2f |
Data length | 2 | 0x0000 |
Data | Data | None |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
According to the connection condition, the developer can send a production test command to the module. The following two connections are supported.
MCU_SDK
is used
View the test result in the ir_tx_rx_test_result
function of the protocol.c
file.
void ir_tx_rx_test_result(unsigned char result,unsigned char rssi)
{
//#error "Implement the success/failure code of the infrared receiving and transmitting production test. Delete this line after completion"
if(result == 0)
{
//Enter the IR receiving and transmitting production test successfully
}
else
{
// Failed to enter the IR receiving and transmitting production test. Check the data packet sent
}
}
MCU_SDK
is not used
You can determine whether the IR production test succeeded or failed according to the received 0x2f
command. If the infrared test device does not return the status for more than 15 seconds, it is determined that the production test has failed.
The module returns the following command:
Field | Length (byte) | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x2f |
Data length | 2 | 0x0001 |
Data | Data | 0x00: Entered the IR receiving and transmitting production test successfully 0x01: Failed to enter the IR receiving and transmitting production test |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
If the IR device under control reacts correctly, the production test succeeded. If the IR device under control does not react correctly, the production test failed.
For more information about Bluetooth functional test mode, see Bluetooth functional test.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback