Application Development

Last Updated on : 2022-11-24 09:20:12download

This topic describes the commonly-used functions that can help you develop applications easily with Tuya Beacon SDK.

Report data to the cloud

The application layer calls app_dps_upload to set up data to be reported. The stack layer will packet and encrypt the data and then send it to the buffer. The data packet will be sent after the bal_beacon_txrx(x,3) is called.

Sample code

app_dps_upload (3, 1, 1, 0);

// The device proactively reports data `false` of DP 3. DP 3 is a Boolean type, with a data length of one byte.

Receive data from the cloud

The system calls bal_beacon_txrx(x,3) in loop to scan for advertising packets. The received data will be sent to the Beacon stack for verification and parsing and then fed to the application layer.

The function call of app_dps_download is encapsulated in the SDK. After the Beacon device receives data, the SDK will proactively call app_dps_download. In this function, the device can execute commands and then return the changed DP status.

Get Beacon status

To get the current Beacon network status, the application can call ty_beacon_get_state().

Return value

DEVICE_STATE_NOT_PAIRED;  Not paired
DEVICE_STATE_PAIRING; Being paired
DEVICE_STATE_PAIRED; Paired

Reset device

Call app_light_reset_run() to reset a device. The resting operation corresponds to removing device and clearing data by using the mobile app.

This function will clear the virtual ID information from the SDK.