Last Updated on : 2024-01-18 09:00:06download
During the manufacturing process, conducting a comprehensive inspection and testing of the end product helps ensure compliance with specified standards and requirements, thereby enhancing quality control.
This topic describes scanning for the specified beacon and the corresponding APIs. The implementation code is not provided. The test items may vary depending on the product features, so implement the code according to your needs.
The device scans for the specified testing beacon after power on.
After the device detects the target beacon, it will automatically execute the predefined testing steps. The testing actions may vary depending on the beacons.
The beacons and testing actions are defined according to your requirements.
Testers observe the device’s actions to determine the test results. No host software is required to conduct the test, making it easier to operate.
The device will not enter the testing process, scan for the specified beacon, or connect to the specified router in any of the following scenarios.
The device works continuously for 15 minutes after being activated.
The pairing mode is set to GWCM_OLD
, which does not support the two testing features mentioned above. For more information, see Definition of Pairing Mode.
If the pairing mode is set to power-on pairing and the device has already obtained the Wi-Fi credentials, the available modes are:
GWCM_OLD_PROD
GWCM_LOW_POWER_AUTOCFG
GWCM_SPCL_AUTOCFG
If the pairing mode is set to non-power-on pairing and the device is in pairing mode, the available modes are:
GWCM_SPCL_MODE
GWCM_LOW_POWER
prod_test.h
tuya_devos_utils.h
There are two approaches to achieving end product testing:
With the example, implement and manage the code yourself.
Implement the entire testing process, from scanning to test actions on your own. The framework provides basic APIs such as Wi-Fi scanning as well as the example code for entering the testing process. It gives you the flexibility to alter the code.
Use the framework’s APIs.
Call the APIs provided by the framework for end product testing. The framework implements processes such as determining scanning conditions and scanning for specified signals. You only need to handle messaging after the target beacon is scanned. This approach is simple but has limitations for customization.
Open tuya_iot_config.h
and check if the following macro is defined.
#define ENABLE_PRODUCT_AUTOTEST 1
Register the information about end product testing.
Call the beacon scanning API.
Register pairing mode, beacon list, testing commands, and result callbacks.
// Beacon scanning testing. The list of testing beacons.
typedef struct {
char ssid[32 + 1];
signed char rssi;
} prodtest_ssid_info_t;
// Beacon scanning testing. The information returned when a specified beacon is found.
// flag: Indicates whether the device has been authorized.
// info: The list of discovered beacons.
// info_count: The number of discovered beacons.
typedef OPERATE_RET(*prodtest_app_cb_t)(int flag, \
prodtest_ssid_info_t *info, \
uint8_t info_count);
typedef struct {
GW_WF_CFG_MTHD_SEL gwcm_mode; // Pairing mode
uint8_t ssid_count; // Beacon scanning testing. The number of custom testing beacons.
const char **ssid_list; // Beacon scanning testing. The list of custom testing beacons.
prodtest_app_cb_t app_cb; // Beacon scanning testing. The information returned when a specified beacon is found.
MF_USER_PRODUCT_TEST_CB product_cb; // Host-based LAN testing. The application command callback.
char *file_name; // Host-based LAN testing. The firmware identifier, which is APP_BIN_NAME.
char *file_ver; // Host-based LAN testing. The firmware version, which is USER_SW_VER.
} prodtest_app_cfg_t;
/**
* @brief The configuration required to register the end product testing feature.
*
* @param[in] app_cfg: The application pairing mode.
*
* @return OPERATE_RET
*
*/
int prodtest_app_register(const prodtest_app_cfg_t *app_cfg);
The beacon must be on channel 6.
If tuya_mdev_test4
is detected, the device will automatically enter the host-based LAN test and stop scanning beacons. For beacon scanning, your custom SSID cannot be set to tuya_mdev_test4
.
/**
* @brief Scan for the testing beacon and connect to tuya_mdev_test4.
* The device will first check if the testing mode is open before scanning for the testing beacon. It will proceed with the testing process only if all prerequisites are met.
* For more information about the prerequisites, see Shut Down Testing Mode in this topic.
*
* @param[in] timeout: The scanning timeout, in milliseconds.
* If no testing signal is detected within the timeout period, the device will not undergo a test.
* If you set this parameter to 0, the default value of 500 ms will be applied.
*
* @return TRUE: Enter the testing mode. FALSE: Not enter the testing mode.
*
*/
bool prodtest_ssid_scan(uint32_t timeout);
After downloading the Networked Product Development Framework, you can find the example code for all features in the tuyaos_demo_examples
folder under the apps
directory. See the code in service_product_test
. For the usage of the example code, see TuyaOS Example Collection.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback