Generic Services

Last Updated on : 2023-07-27 03:49:50download

This topic describes generic capabilities supported by TuyaOS-based Zigbee devices. Typical capabilities include the time service, device heartbeat, and exception log.

Time service

Zigbee sub-devices request time from a gateway and get the time including the year, month, day, hour, minute, and second.

The TuyaOS development framework provides the following function for you to get the current Coordinated Universal Time (UTC) time. The year 2000 is used as a baseline for UTC calculation.

int tal_current_time_get(VOID_T);/*return utc time*/

Device heartbeat

Zigbee router devices (ZRDs) and Zigbee end devices (ZEDs) can have device heartbeat enabled to indicate their online status in the cloud. TuyaOS makes devices proactively report their device version or battery level to maintain the heartbeat connection.

Tuya-enabled gateways regularly query the attributes of ZRDs to check whether they stay online. Therefore, ZRDs do not need to proactively report device status.

The following example shows how to enable device heartbeat for TuyaOS-based low power devices:

tal_heartbeat_type_set(HEARTBEAT_BATTERY_VOLTAGE);/*set heart type*/
tal_heartbeat_period_set(5 * 60 * 1000);/*set heart period*/
tal_heartbeat_start();/*start heartbeat service*/

Exception log

Keep logs of exceptions and special operations, such as restart and local reset for devices. These logs contain the time when the exceptions or special operations have occurred. After power on or successful pairing, devices will report these logs to the respective gateways for further analytics of historical behaviors.

Devices will delete the exception logs that are successfully reported.

Exception logs are reported in the private attribute FFDF of the Basic cluster. The following figure shows the captured packet.

Generic Services

Support and help

If you have any problems with TuyaOS development, you can post your questions in the Tuya Developer Forum.