TuyaOS Gateway Device Development API

Gateway equipment, voice control devices, etc.


Post Reply
Kyson
Posts: 230

This article introduces the commonly used API interfaces of the TuyaOS gateway development framework, which can be used as a reference for the API manual. Before starting, please make sure you are familiar with the basic concepts of the TuyaOS gateway development framework.

This article will be classified according to functions. The following are the main functions of the TuyaOS gateway development framework and corresponding API interface descriptions.

Basic interface

Function NameDescription
tuya_load_configLoad JSON configuration file
tuya_get_configGet the handle of the configuration file for obtaining the content of the configuration file
tuya_iot_get_sdk_infoGet SDK information
tuya_iot_get_gw_idGet the device ID of the gateway
tuya_iot_initIoT module initialization, initialize database, MQTT, LAN and other businesses
tuya_iot_set_wf_gw_prod_infoSet product authorization information UUID&AUTHKEY, which is required to be called before the gateway initialization interface tuya_iot_wr_wf_sdk_init
tuya_iot_sdk_pre_initGateway module pre-initialization, which is required to be called before the gateway initialization interface tuya_iot_wr_wf_sdk_init
tuya_iot_wr_wf_sdk_initGateway module initialization, load database, start device management service, start network configuration service, start DevOS, etc.
tuya_iot_sdk_startStart the gateway service, the main function is to schedule device management
tuya_iot_sdk_reg_netstat_cbRegister gateway status callback
tuya_iot_reg_gw_app_cbRegister gateway application callback
tuya_iot_wf_gw_unactiveUnbind the gateway without clearing local data
tuya_iot_wf_gw_resetUnbind the gateway and clear local data
tuya_iot_get_gw_statGet the activation status of the gateway
tuya_iot_dev_join_permitAllow sub-devices to join the gateway

Sub-device management interface

Function NameDescription
tuya_subdev_user_sigle_type_regRegister device management callback
tuya_iot_gw_bind_devBind sub-devices to the Tuya IoT platform
tuya_iot_gw_bind_dev_attrBind sub-devices to the Tuya IoT platform, supporting additional OTA channels
tuya_iot_gw_unbind_devSub-devices are unbound from Tuya IoT platform
tuya_iot_dev_online_stat_updateBypass heartbeat management and force update sub-device online status
tuya_iot_get_dev_online_statusGet the online and offline status of sub-devices
tuya_iot_set_dev_hb_cfgConfigure sub-device heartbeat parameters
tuya_iot_fresh_dev_hbRefresh sub-device heartbeat
tuya_iot_gw_subdevice_updateUpdate the firmware version of sub-devices
tuya_iot_gw_subdevice_update_versionsUpdate the firmware version of sub-devices, supporting additional OTA channels
tuya_iot_get_dev_ifGet specified sub-device information
tuya_iot_dev_traversalTraverse all sub-devices
tuya_iot_get_dp_prop_valueGet the value of the DPID of the specified device
tuya_iot_get_dp_descGet the physical model of the DPID of the specified device

Data Point Management Interface

Function NameDescription
dev_query_dp_json_asyncQuery non-RAW type data points reported, and the report does not perform linkage condition detection.
dev_report_dp_json_asyncActively report non-RAW type data points.
dev_report_dp_raw_syncActively report RAW type data points.
dev_report_dp_stat_syncStatistics report non-RAW type data points.
tuya_iot_reg_dp_report_cbRegister data point reporting callback.
tuya_iot_dev_obj_cmd_sendLocally send non-RAW type data points.
tuya_iot_dev_raw_cmd_sendLocally send RAW type data points.

OTA Interface

Function NameDescription
tuya_iot_upgrade_gwGateway OTA firmware download.
tuya_iot_upgrade_devSub-device OTA firmware download.
tuya_iot_refuse_upgradeRefuse OTA.
tuya_iot_dev_upgd_progress_reptReport OTA progress bar.
tuya_iot_dev_upgd_result_reportReport OTA result, end OTA.

Zigbee Gateway Interface

Function NameDescription
tuya_zigbee_svc_initInitialize the Tuya Zigbee service, and it is required to call it before the gateway initialization interface tuya_iot_wr_wf_sdk_init.
tuya_zigbee_svc_startStart Tuya Zigbee service.
tuya_zigbee_check_and_get_uart_speedCheck whether the Zigbee module is connected.
tuya_zigbee_reg_permit_join_cbRegister callback for allowing/prohibiting Zigbee access.
tuya_zigbee_reg_ncp_got_ver_cbRegister callback for obtaining Zigbee module firmware version.
tuya_zigbee_custom_dev_mgr_initRegister callback for third-party Zigbee sub-device access management.
tuya_zigbee_upgrade_ncpRegister callback for Zigbee module OTA result.
tuya_zigbee_reg_ncp_hard_ops_cbRegister callback for Zigbee module exceptions.
tuya_zigbee_send_dataSend ZCL data.
tuya_zigbee_del_devRemove sub-devices from the Zigbee network.
tuya_zigbee_upgrade_devZigbee sub-device OTA.
tuya_zigbee_set_tx_radio_powerSet the transmission power of the Zigbee module.
tuya_zigbee_rftestRF test during production.
tuya_zigbee_print_debug_infoPrint debugging information. When remotely pulling local logs, it is recommended to call this interface to output Zigbee debugging information.

Bluetooth Gateway Interface

Function NameDescription
tuya_bt_svc_initInitialize the Tuya Bluetooth service. It is required to be called before the gateway initialization interface tuya_iot_wr_wf_sdk_init.
tuya_bt_svc_startStart the Tuya Bluetooth service.
tuya_bt_ncp_check_existCheck if the Bluetooth module is connected.
tuya_bt_rssi_getGet the signal quality.
tuya_bt_ver_getGet the firmware version number of the Bluetooth module.
tuya_bt_ncp_hard_reset_regRegister a callback for Bluetooth module exception.

Offline Construction Interface

Function NameDescription
tuya_engineer_sdk_initInitialize the offline construction SDK. It needs to be called regardless of whether it is in construction mode or normal mode.
tuya_engineer_gw_initInitialize the offline construction gateway module, same as tuya_iot_wr_wf_sdk_init. Call this interface in construction mode and call tuya_iot_wr_wf_sdk_init in normal mode.
tuya_set_engineer_modeSwitch to construction mode.
tuya_get_engineer_modeCheck if it is running in construction mode.

Fault Replacement Interface

Function NameDescription
tuya_gw_replacement_enableEnable the fault replacement function.
tuya_gw_replacement_register_cbRegister the fault replacement callback.
tuya_gw_flt_rpl_get_cfg_fileGet the backup file.
tuya_gw_flt_rpl_put_cfg_filePackage the backup file.
tuya_iot_gw_fault_replace_set_pathSet the fault replacement packaging path.

Linkage Interface

Function NameDescription
scene_linkage_load_all_rule_info_from_diskGet the linkage managed by the gateway, including local linkage and LAN linkage.
scene_linkage_all_rule_info_freeRelease the memory allocated by the scene_linkage_load_all_rule_info_from_disk interface.
scene_linkage_scene_exeExecute the linkage.
Post Reply