Last Updated on : 2024-11-20 08:51:40download
This topic describes how to perform production tests on your Bluetooth SDK-based products to check for authorization, soldering defects, and Bluetooth signal strength.
In production, you need to flash Tuya’s license to the module for authorization. You can use Tuya’s production tool or buy licenses and use custom protocols and interfaces to manage authorization and perform testing.
You buy licenses and flash them to modules. Tuya Bluetooth SDK does not manage the license information, and instead, you use custom protocols and interfaces to manage authorization and perform testing. In this case, configure the SDK as follows.
#define TUYA_BLE_DEVICE_AUTH_SELF_MANAGEMENT 0
The application should specify the required parameters in the SDK initialization process. For more information, see Port SDK. The login key
, VID
, and bound flag
sent from the SDK must be saved to the non-volatile (NV) memory.
If you have a full-fledged production management system and proprietary host and protocols, you can use this solution to manage license flashing and authorization information.
You use Tuya’s production tool to perform license flashing and production tests. Tuya Bluetooth SDK manages the license information and provides the capability of production testing. In this case, configure the SDK as follows.
#define TUYA_BLE_DEVICE_AUTH_SELF_MANAGEMENT 1
When you use Tuya’s production tool to flash licenses to modules, make sure use_ext_license_key
and device_id_len
are set to 0
in the SDK initialization process. For more information about initialization, see API.
Tuya provides module functionality testing and end product functionality testing.
Tuya Bluetooth SDK implements the protocols for module functionality testing. The commands used for GPIO functionality tests, RSSI tests, as well as additional testing items for end product testing are intended to be implemented by you.
The source file tuya_ble_app_production_test.c
in the SDK contains the related interfaces, which is defined by TUYA_BLE_WEAK
. Your applications can define these functions in other source files and reference them in the configuration file.
Module functionality testing includes authorization verification, GPIO functionality tests, and Bluetooth RSSI tests.
Tuya Bluetooth SDK has integrated with the flashing and authorization features. You can use Tuya’s production tool to flash licenses to modules for authorization, and the SDK will take care of the authorization data.
#define TUYA_BLE_DEVICE_AUTH_SELF_MANAGEMENT 1
The SDK also provides interfaces for the GPIO functionality test and Bluetooth RSSI test, which are intended to be implemented by you based on your product features and chipset platform.
Detect PCBA soldering defects such as pseudo soldering and solder skips. Define the testing process as needed. tuya_ble_app_production_test.c
contains the reserved interface for GPIO functionality test, as shown below.
__TUYA_BLE_WEAK tuya_ble_status_t tuya_ble_prod_gpio_test(void)
{
return TUYA_BLE_SUCCESS;
}
Do not directly edit this function. You need to implement it in other places.
After you turn on the GPIO test on the test tool, the host will notify the device to start the test. The pre-defined program on the device will run the test and return the result. The test tool will display the result.
Check the Bluetooth signal strength to see if it is within an acceptable range. Prepare a Bluetooth beacon to send advertising packets. You can set packet contents as you like.
tuya_ble_app_production_test.c
contains the reserved interface for RSSI test, as shown below.
__TUYA_BLE_WEAK tuya_ble_status_t tuya_ble_prod_beacon_scan_start(void)
{
return TUYA_BLE_SUCCESS;
}
__TUYA_BLE_WEAK tuya_ble_status_t tuya_ble_prod_beacon_scan_stop(void)
{
return TUYA_BLE_SUCCESS;
}
__TUYA_BLE_WEAK tuya_ble_status_t tuya_ble_prod_beacon_get_rssi_avg(int8_t *rssi)
{
*rssi = -20;
return TUYA_BLE_SUCCESS;
}
The three functions above are implemented by you. Do not directly edit this function. You need to implement it in other places.
tuya_ble_prod_beacon_scan_start
: Initiate scanning and get the RSSI value.
tuya_ble_prod_beacon_scan_stop
: Stop scanning and calculate the average of all RSSI values.
tuya_ble_prod_beacon_get_rssi_avg
: Return the average RSSI.
Assume you create custom_app_product_test.c
and custom_app_product_test.h
and code incustom_app_product_test.c
.
tuya_ble_status_t tuya_ble_prod_beacon_scan_start(void)
{
//
return TUYA_BLE_SUCCESS;
}
tuya_ble_status_t tuya_ble_prod_beacon_scan_stop(void)
{
//
return TUYA_BLE_SUCCESS;
}
tuya_ble_status_t tuya_ble_prod_beacon_get_rssi_avg(int8_t *rssi)
{
//
*rssi = -30;
return TUYA_BLE_SUCCESS;
}
tuya_ble_status_t tuya_ble_prod_gpio_test(void)
{
// Add GPIO test code here
return TUYA_BLE_SUCCESS;
}
Add the declaration of TUYA_BLE_WEAK
in custom_app_product_test.h
rather than in the above snippets.
#ifndef CUSTOM_APP_PRODUCT_TEST_H_
#define CUSTOM_APP_PRODUCT_TEST_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "tuya_ble_type.h"
tuya_ble_status_t tuya_ble_prod_beacon_scan_start(void);
tuya_ble_status_t tuya_ble_prod_beacon_scan_stop(void);
tuya_ble_status_t tuya_ble_prod_beacon_get_rssi_avg(int8_t *rssi);
tuya_ble_status_t tuya_ble_prod_gpio_test(void);
void tuya_ble_custom_app_production_test_process(uint8_t channel,uint8_t *p_in_data,uint16_t in_len);
#ifdef __cplusplus
}
#endif
#endif //
Add the following macro definition in your config
file.
#define CUSTOMIZED_TUYA_BLE_APP_PRODUCT_TEST_HEADER_FILE "custom_app_product_test.h"
The SDK also provides a custom interface to allow you to define custom testing items based on Tuya’s protocol and test tool.
tuya_ble_app_production_test.c
contains the reserved interface for custom testing items, as shown below.
__TUYA_BLE_WEAK void tuya_ble_custom_app_production_test_process(uint8_t channel,uint8_t *p_in_data,uint16_t in_len)
{
uint16_t cmd = 0;
uint8_t *data_buffer = NULL;
uint16_t data_len = ((p_in_data[4]<<8) + p_in_data[5]);
if((p_in_data[6] != 3)||(data_len<3))
return;
cmd = (p_in_data[7]<<8) + p_in_data[8];
data_len -= 3;
if(data_len>0)
{
data_buffer = p_in_data+9;
}
switch(cmd)
{
default:
break;
};
}
Custom testing items must be defined based on the protocol for end product functionality testing. Contact your project manager and request the tool. Or you can develop a tool.
To use this tool, you need to create a Bluetooth product on the Tuya Developer Platform and upload your firmware to get the license. For more information about downloading the test tool, see Production Test Tools.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback