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 Name
Description
tuya_load_config
Load JSON configuration file
tuya_get_config
Get the handle of the configuration file for obtaining the content of the configuration file
tuya_iot_get_sdk_info
Get SDK information
tuya_iot_get_gw_id
Get the device ID of the gateway
tuya_iot_init
IoT module initialization, initialize database, MQTT, LAN and other businesses
tuya_iot_set_wf_gw_prod_info
Set 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_init
Gateway module pre-initialization, which is required to be called before the gateway initialization interface tuya_iot_wr_wf_sdk_init
Start the gateway service, the main function is to schedule device management
tuya_iot_sdk_reg_netstat_cb
Register gateway status callback
tuya_iot_reg_gw_app_cb
Register gateway application callback
tuya_iot_wf_gw_unactive
Unbind the gateway without clearing local data
tuya_iot_wf_gw_reset
Unbind the gateway and clear local data
tuya_iot_get_gw_stat
Get the activation status of the gateway
tuya_iot_dev_join_permit
Allow sub-devices to join the gateway
Sub-device management interface
Function Name
Description
tuya_subdev_user_sigle_type_reg
Register device management callback
tuya_iot_gw_bind_dev
Bind sub-devices to the Tuya IoT platform
tuya_iot_gw_bind_dev_attr
Bind sub-devices to the Tuya IoT platform, supporting additional OTA channels
tuya_iot_gw_unbind_dev
Sub-devices are unbound from Tuya IoT platform
tuya_iot_dev_online_stat_update
Bypass heartbeat management and force update sub-device online status
tuya_iot_get_dev_online_status
Get the online and offline status of sub-devices
tuya_iot_set_dev_hb_cfg
Configure sub-device heartbeat parameters
tuya_iot_fresh_dev_hb
Refresh sub-device heartbeat
tuya_iot_gw_subdevice_update
Update the firmware version of sub-devices
tuya_iot_gw_subdevice_update_versions
Update the firmware version of sub-devices, supporting additional OTA channels
tuya_iot_get_dev_if
Get specified sub-device information
tuya_iot_dev_traversal
Traverse all sub-devices
tuya_iot_get_dp_prop_value
Get the value of the DPID of the specified device
tuya_iot_get_dp_desc
Get the physical model of the DPID of the specified device
Data Point Management Interface
Function Name
Description
dev_query_dp_json_async
Query non-RAW type data points reported, and the report does not perform linkage condition detection.
dev_report_dp_json_async
Actively report non-RAW type data points.
dev_report_dp_raw_sync
Actively report RAW type data points.
dev_report_dp_stat_sync
Statistics report non-RAW type data points.
tuya_iot_reg_dp_report_cb
Register data point reporting callback.
tuya_iot_dev_obj_cmd_send
Locally send non-RAW type data points.
tuya_iot_dev_raw_cmd_send
Locally send RAW type data points.
OTA Interface
Function Name
Description
tuya_iot_upgrade_gw
Gateway OTA firmware download.
tuya_iot_upgrade_dev
Sub-device OTA firmware download.
tuya_iot_refuse_upgrade
Refuse OTA.
tuya_iot_dev_upgd_progress_rept
Report OTA progress bar.
tuya_iot_dev_upgd_result_report
Report OTA result, end OTA.
Zigbee Gateway Interface
Function Name
Description
tuya_zigbee_svc_init
Initialize 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_start
Start Tuya Zigbee service.
tuya_zigbee_check_and_get_uart_speed
Check whether the Zigbee module is connected.
tuya_zigbee_reg_permit_join_cb
Register callback for allowing/prohibiting Zigbee access.
tuya_zigbee_reg_ncp_got_ver_cb
Register callback for obtaining Zigbee module firmware version.
tuya_zigbee_custom_dev_mgr_init
Register callback for third-party Zigbee sub-device access management.
tuya_zigbee_upgrade_ncp
Register callback for Zigbee module OTA result.
tuya_zigbee_reg_ncp_hard_ops_cb
Register callback for Zigbee module exceptions.
tuya_zigbee_send_data
Send ZCL data.
tuya_zigbee_del_dev
Remove sub-devices from the Zigbee network.
tuya_zigbee_upgrade_dev
Zigbee sub-device OTA.
tuya_zigbee_set_tx_radio_power
Set the transmission power of the Zigbee module.
tuya_zigbee_rftest
RF test during production.
tuya_zigbee_print_debug_info
Print debugging information. When remotely pulling local logs, it is recommended to call this interface to output Zigbee debugging information.
Bluetooth Gateway Interface
Function Name
Description
tuya_bt_svc_init
Initialize the Tuya Bluetooth service. It is required to be called before the gateway initialization interface tuya_iot_wr_wf_sdk_init.
tuya_bt_svc_start
Start the Tuya Bluetooth service.
tuya_bt_ncp_check_exist
Check if the Bluetooth module is connected.
tuya_bt_rssi_get
Get the signal quality.
tuya_bt_ver_get
Get the firmware version number of the Bluetooth module.
tuya_bt_ncp_hard_reset_reg
Register a callback for Bluetooth module exception.
Offline Construction Interface
Function Name
Description
tuya_engineer_sdk_init
Initialize the offline construction SDK. It needs to be called regardless of whether it is in construction mode or normal mode.
tuya_engineer_gw_init
Initialize 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_mode
Switch to construction mode.
tuya_get_engineer_mode
Check if it is running in construction mode.
Fault Replacement Interface
Function Name
Description
tuya_gw_replacement_enable
Enable the fault replacement function.
tuya_gw_replacement_register_cb
Register the fault replacement callback.
tuya_gw_flt_rpl_get_cfg_file
Get the backup file.
tuya_gw_flt_rpl_put_cfg_file
Package the backup file.
tuya_iot_gw_fault_replace_set_path
Set the fault replacement packaging path.
Linkage Interface
Function Name
Description
scene_linkage_load_all_rule_info_from_disk
Get the linkage managed by the gateway, including local linkage and LAN linkage.
scene_linkage_all_rule_info_free
Release the memory allocated by the scene_linkage_load_all_rule_info_from_disk interface.