IFREEQ Docs
  • Introduction
  • Update Log
  • General Knowledge
    • About IoT
    • Electricity
      • Plug & socket types around the world
        • Power plug & outlet Types A & B
        • Power plug & outlet Type C
        • Power plug & outlet Type D
        • Power plug & outlet Type E
        • Power plug & outlet Type F (Schuko)
        • Power plug & outlet Type G
        • Power plug & outlet Type H
        • Power plug & outlet Type I
        • Power plug & outlet Type J
        • Power plug & outlet Type K
        • Power plug & outlet Type L
        • Power plug & outlet Type M
        • Power plug & outlet Type N
        • Power plug & outlet Type O
      • Full list: Plug, socket & voltage by country
      • Map showing the spread of the different plug types worldwide
      • Useful information for travellers
      • History of domestic electricity
        • Why isn’t there a universal standard electric plug?
        • Why isn’t there a standard voltage around the world?
      • Three-phase electric power (industrial applications only)
    • Certifications
    • Home Automation Brand
    • Home Automation Catalog
    • Industry Term
    • Network Term
    • The Third-party Control
      • AliGenie
      • Amazon Alexa
        • FAQs About Amazon Alexa
      • DuerOS
        • FAQs About DuerOS
      • Google Assistant
        • FAQs About Google Assistant
      • Home Assistant
        • FAQs About Home Assistant
      • HomeKit
        • FAQs About Homekit
      • IFTTT
      • Xiao AI
      • Yandex Alice
        • FAQs About Yandex Alice
  • Developer
    • Introduction
      • What is Tuya Smart?
      • What does Tuya do?
      • Tuya Smart Cloud Platform Overview
      • Advantages
      • Terms
      • Limits
    • Quick Start
    • Configure in Platform
      • Create Products
      • Function Definition
        • Overview
        • Standard Functions
        • Custom Functions
        • Cloud Functions
      • Design App UI
      • Configure Hardware
      • Cloud Configuration
        • Introduction
        • Upgrade Firmwares
        • Set up Multilingual UI
        • Manage Alarms
        • Configure Network for Devices
        • Enable Toggles on App
        • Automate the Smart Devices
      • Mass Production
    • Device Development
      • Access Mode MCU
        • MCU Access Guide
        • Wi-Fi General Solution
          • Wi-Fi Module MCU Development Overview
          • Hardware Design Reference Wi-Fi
          • Software Reference Wi-Fi
            • Tuya Cloud Universal Serial Port Access Protocol
            • Overview of migrating Tuya's MCU SDK
        • Wi-Fi Power Off Fast Connect Device Solution
          • Overview
        • Zigbee General Solution
          • Overview
          • Software development
            • Tuya Zigbee module UART communication protocol
          • Hardware Design
        • BLE General Solution
          • BLE Module MCU Development Overview
          • BLE Hardware Design
        • NB-IoT General Solution
          • NB-IoT Development Guide
          • Introduction to NB Module - NM1
      • Access Mode SoC
        • SoC Development Overview
        • Lighting
          • Guidance
          • Design
          • Test
        • Electrician
          • Guidance
          • Design
          • Test
      • Access Mode Link
        • Wi-Fi Chip SDK
          • Tuya Wi-Fi SDK Reference
          • Development Environment Setup When Using Tuya Wi-Fi SDK
        • BLE Chip SDK
          • TUYA BLE SDK User Guide
        • Zigbee Chip SDK
          • TUYA Zigbee SDK Document
      • Cloud Mode
        • Wi-Fi&BT Dual Mode Module
        • Wi-Fi Module
        • Bluetooth Module
        • Zigbee Module
        • Sub-G Module
      • Tuya Development Boards
      • Access Mode Simmulator
        • Module Debugging Assistant Instruction
      • Embedded License
        • Embedded open source license
    • Smart Product Solution
      • Gateway
        • MCU Access
        • Link SDK Access
        • PCB Details
      • HouseHold
        • Cleaner Robot
        • Air Conditioner
      • IPC
      • Lock
        • BLE Lock
        • Wi-Fi Lock
        • Zigbee Lock
      • Remote Control
      • Voice Product
        • Domestic Voice Speaker Solution
        • Domestic Voice Infrared SoC Solution
        • Overseas Voice Solution
        • Design Reference Materials - Alexa Module
        • Design Reference Materials - Domestic Voice Module
    • Firmware
      • S8E
  • FAQs
    • Device Development
      • Cloud Module
        • Wi-Fi Module
        • Zigbee Module
        • BLE Module
        • GPRS Module
        • NB-IoT Module
        • Dual-mode Module
        • Other Module Issues
      • Access Mode SoC
      • MCU Access Mode
        • Wi-Fi General Solution
        • Zigbee General Solution
        • BLE General Solution
          • BLE Single-point Solution
          • BLE Mesh General Solution
          • Other Issues of BLE Solution
        • NB-IoT General Solution
        • Other Issues of MCU Access Mode
      • Module SDK Development
        • BLE Chip SDK(single point)
        • Linux General SDK
        • NB-IoT Chip SDK
        • Wi-Fi Chip SDK
        • Others about Module SDK
      • Other Issues of Device Development
    • Smart Product Solution
      • Electrical
        • Outlet
        • Scenario Switch
        • Switch
      • Lighting
        • Wi-Fi Lighting
        • Zigbee Lighting
        • Bluetooth Lighting
        • Other Issues of Lighting
      • Lock
        • BLE Lock
        • NB-IoT Lock
        • Wi-Fi Lock
        • Zigbee Lock
        • Other Issues of Lock
      • Sensor
      • Gateway
        • BLE Gateway
        • Wireless Gateway
        • Zigbee Gateway
        • Other Issues of Gateway
      • IPC
      • Infrared Products
        • Infrared remote control
        • Infrared Capability Introduction
        • Infrared Code Library
      • Sweeper
      • Household Appliances
      • Pet Supplier
      • BLE Mesh Typical Solution
        • BLE Mesh Lighting Solution
        • BLE Mesh Electrical Solution
        • BLE Mesh Sensor Solution
        • BLE Mesh General Solution
    • Products
      • Electric
        • Smart Switch
        • Smart Plug
        • Curtain Controller
      • Lighting
      • Security
        • E202/203 Smart Lock
    • More
  • Links
    • ifreeq.cn
    • ifreeq.com
    • AIoT Expo
    • Official Store
Powered by GitBook
On this page
  • SDK Document version
  • SDK summarize
  • SDK download
  • SDK Directory Structure
  • SDK Overall process
  • appendix

Was this helpful?

  1. Developer
  2. Device Development
  3. Access Mode Link
  4. Zigbee Chip SDK

TUYA Zigbee SDK Document

SDK Document version

version

Preparation / Revision Instructions

Revised by

Revision date

Remarks

1.0.0

Create document

Liang Deng / Peng Zhang

2020-03-26

SDK summarize

Tuya Zigbee EFR32 SDK is used to develop Zigbee 3.0 standard products. This SDK is abstracted again based on the Silicon Labs SDK ,The complex Zigbee technical details are shielded, which is convenient for developers to get started quickly. The SDK mainly includes three parts: hardware interface, network interface and tool interface,And provide some types of sample code to demonstrate the use of various interfaces and the basic development specifications of Zigbee device access to the Tuya system.

SDK download

https://github.com/TuyaInc/tuya_zigbee_sdk

SDK Directory Structure

    ├── app
    │   ├── build-all.py
    │   ├── light
    │   ├── sensor
    │   ├── smart_plug
    │   └── switch
    ├── doc
    │   ├── datasheet
    │   ├── SPEC
    │   ├── docking standard
    │   └── development manual
    ├── include
    │      ├── hal_adc.h
    │      ├── hal_battery.h
    │      ├── hal_flash.h
    │      ├── hal_gpio.h
    │      ├── hal_i2c.h
    │      ├── hal_pwm.h
    │      ├── hal_spi.h
    │      ├── hal_systick_timer.h
    │      ├── hal_timer.h
    │      ├── hal_uart.h
    │      ├── tuya_app_timer.h
    │      ├── tuya_mcu_os.h
    │      ├── tuya_mf_test.h
    │      ├── tuya_oem_kit.h
    │      ├── tuya_tools.h
    │      ├── tuya_zigbee_modules.h
    │      ├── tuya_zigbee_sdk.h
    │      ├── tuya_zigbee_stack.h
    │      ├── type_def.h
    │      ├── zigbee_attr.h
    │      ├── zigbee_cmd.h
    │      ├── zigbee_dev_template.h
    │      ├── zigbee_modules.h
    │      └── zigbee_raw_cmd_api.h
    ├── lib
    │   ├── gcc_lib
    │   └── iar_lib
    ├── sdk
    │   ├── platform
    │   └── tool
    └── tools
        ├── gcc-arm-none-eabi-9-2019-q4-major
        ├── gcc-arm-none-eabi-9-2019-q4-major.tar.bz2
        ├── gcc_boot
        └── iar_tools

Directory Introduction

Directory

Explanation

app

The entry path of the application project, which contains example codes of various categories

doc

Zigbee related files

include

SDK interface file

lib

SDK library files are divided into IAR version library and GCC version library

sdk

Some tools and link scripts

tools

Related tools and scripts used in compilation

SDK Overall process

User-implemented function interface

dev_power_on_init()

/**
 * @note (MUST) This is the first function after the hardware starts.
 * The CPU and base clock are initialized before calling this function.
 * You need to implement the creation of Zigbee devices and 
 * determine the parameters of Zigbee device behavior.
 * Include device roles(router, end device), device networking(join), 
 * rejoin parameters, and more. Refer to the TUYA Zigbee SDK demo for details.
 * @param none
 * @return none
 */
void dev_power_on_init(void);

Instructions

Zigbee SDK will call this function according to the system flowchart,Users need to at least create Zigbee devices,network parameter setting。

Sample code snippet

void dev_power_on_init(void)
{
    join_config_t cfg;
    zg_dev_config_t zg_dev_config;
    
    /**
    Register Zigbee Basic,Including information such as endpoint, cluster, attributes, etc.
    */
    dev_register_zg_ep_infor((dev_description_t *)g_dev_des, EP_SUMS);

    memset(&zg_dev_config, 0, sizeof(zg_dev_config_t));
    zg_dev_config.dev_type = ZG_ROUTER;
    dev_register_zg_dev_config(&zg_dev_config);

    memset(&cfg, 0, sizeof(cfg));
    cfg.auto_join_power_on_flag = TRUE;
    cfg.auto_join_remote_leave_flag = TRUE;
    cfg.join_timeout = ZIGBEE_JOIN_MAX_TIMEOUT;
    dev_zg_join_config(&cfg);

    //TODO: others task
    return;
}

dev_system_on_init()

/**
 * @note (MUST) This is the first function after system startup. 
 * Before calling this function, Zigbee stack and some basic 
 * components have been started. You can use all API except individual ones. 
 * API limits refer to the API limits description table
 * @param none
 * @return none
 */
void dev_system_on_init(void);

Instructions Zigbee SDK will call this function according to the system flowchart,Users can realize Zigbee attribute operation, hardware initialization, software timing processing and other initialization. Sample code snippet

static void __uart_rx_callback(uint8_t *data, uint16_t len)
{
    //TODO: Serial port receiving and processing
}

static void __dev_evt_callback(uint8_t evt)
{
    switch(evt) {
        case EVT_LOCK_CANCEL: {
            //TODO: Custom processing
            break;
        }
        
        default: {
            break;
        }
    }
}

void dev_system_on_init(void)
{
    user_uart_config_t *p_default_cfg = mf_test_uart_config();
    user_uart_config_t uart_cfg;

    memcpy(&uart_cfg, p_default_cfg, sizeof(user_uart_config_t));
    uart_cfg.func = __uart_rx_callback;
    user_uart_init(&uart_cfg);


    dev_timer_start_with_callback(EVT_LOCK_CANCEL, 1000, __dev_evt_callback);

    dev_change_power(11, 19);
    return;
}

nwk_state_changed_callback()

/**
 * @note (MUST) This function is invoked when the network state changes.
 * Handling network-related matters at this function is recommended.
 * @param[in] {state} Refer to NET_EVT_T for more detal.
 * @return none
 */
void nwk_state_changed_callback(NET_EVT_T state);

Instructions Zigbee SDK will call this function according to the system flowchart,Users can implement Zigbee network status processing. Sample code snippet

void nwk_state_changed_callback(NET_EVT_T state)
{
    switch(state) {
        case NET_POWER_ON_LEAVE: {
            //TODO: No network status after power on
            break;
        }
        case NET_JOIN_START: {
            //TODO: Start networking
            break;
        }
        case NET_JOIN_TIMEOUT: {
            //TODO: Start networking
            break;
        }
        case NET_POWER_ON_ONLINE: {
            //TODO: Power up has network status
            break;
        }
        case NET_JOIN_OK: {
            //TODO: Successful networking
            break;
        }
        case NET_REJOIN_OK: {
            //TODO: Reconnect successful
            break;
        }
        case NET_LOST: {
            //TODO: Lost with parent
            break;
        }
        case NET_REMOTE_LEAVE: {
            //TODO: Remote off-net notification
            break;
        }
        case NET_LOCAL_LEAVE: {
            //TODO: Local off-net notification            break;
        }
        case NET_MF_TEST_LEAVE: {
            //TODO: Production Test Off-Grid Notification
            break;
        }
        default: {
            break;
        }
    }
}

Quick development guide

The SDK development kit contains documentation and examples, and the use of and attribute sample code is the only rule of quick start. It is recommended to compile, run, and network with the sample code first, and then try to modify the code to achieve personalized functions.

Example description

Directory

Explanation

light

Projects including Zigbee lamps, including lamp switching and brightness adjustment functions

sensor

The project including Zigbee door sensor, including door sensor opening, closing and battery power reporting function

smart_plug

Including the Zigbee socket project, including the opening and closing function of the socket

switch

Including Zigbee relay switch project, including relay on and off functions

Document description

Document directory

Explanation

datasheet

Zigbee chip data sheet

SPEC

Contains Zigbee Alliance Standard Reference Manual

Development Manual

All documents used for development

API call restrictions

</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_timer_start</strong></span></td>
 <td class="confluenceTd"><strong>Start a delayed execution event,If the event has set an event handler function,</strong><br /><strong>The subsequent call does not need to set the event handler function every time
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_timer_get_valid_flag</strong></span></td>
 <td class="confluenceTd"><strong>Determine whether an event is valid (that is, the event has not been reached)
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_timer_get_remaining_time</strong></span></td>
 <td class="confluenceTd"><strong>Get how many ms remain before an event is executed
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="3" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>zigbeeDevice creation</strong></span><br /><span style="color: rgb(0,128,0);"><strong> basic configuration</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_register_zg_ep_infor</strong></span></td>
 <td class="confluenceTd"><strong>Register a complete zigbee device, including an endpoint describing the zigbee device,</strong><br /><strong>cluster,attributes  etc. </strong></td>
 <td class="confluenceTd"><strong>Can only be called in dev_power_on_init</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_register_zg_dev_config</strong></span></td>
 <td class="confluenceTd"><strong>Configure the device role of zigbee, whether it is routing or end device and join, rejoin parameters</strong></td>
 <td class="confluenceTd"><strong>Can only be called in dev_power_on_init</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_zg_join_config</strong></span></td>
 <td class="confluenceTd"><strong>Configure networking policies for power-on and remote deletion</strong></td>
 <td class="confluenceTd"><strong>Can only be called in dev_power_on_init</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="2" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>Network operation</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_zigbee_join_start</strong></span></td>
 <td class="confluenceTd"><strong>Exit the network and enter the network</strong></td>
 Call after<td class="confluenceTd"><strong>dev_system_on_init ,It will involve the handling of events and network status</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_zigbee_join_stop</strong></span></td>
 <td class="confluenceTd"><strong>Stop networking early</strong></td>
 Call after<td class="confluenceTd"><strong>dev_system_on_init ,It will involve the handling of events and network status</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="6" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>zigbee 3.0 related</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>zg_report_table_init</strong></span></td>
 <td class="confluenceTd"><strong>Configure the default report table</strong></td>
 <td class="confluenceTd"><strong>Can only be called in dev_power_on_init, Called after dev_register_zg_ep_infor</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>ext_plugin_identify_client_enable</strong></span></td>
 <td class="confluenceTd"><strong>zigbee 3.0 used,Open the identify client service</strong></td>
 <td class="confluenceTd"><strong>Can only be called in dev_power_on_init, Called after dev_register_zg_ep_infor</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>ext_plugin_identify_server_enable</strong></span></td>
 <td class="confluenceTd"><strong>zigbee 3.0 used,Open the identify  service
 <td class="confluenceTd"><strong>Can only be called in dev_power_on_init, Called after dev_register_zg_ep_infor</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>ext_plugin_green_power_client_enable</strong></span></td>
 <td class="confluenceTd"><strong>zigbee 3.0 used,Start green power client service</strong></td>
 <td class="confluenceTd"><strong>Can only be called in dev_power_on_init, Called after dev_register_zg_ep_info</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>ext_plugin_reporting_enable</strong></span></td>
 <td class="confluenceTd"><strong>zigbee 3.0 used,Open reporting service
 <td class="confluenceTd"><strong>Can only be called in dev_power_on_init, Called after dev_register_zg_ep_infor </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>ext_plugin_register_cmd_handle</strong></span></td>
 <td class="confluenceTd"><strong>Register cluster command processing</strong></td>
 <td class="confluenceTd"><strong>Can only be called in dev_power_on_init</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="3" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>电池采集相关</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>hal_battery_config</strong></span></td>
 <td class="confluenceTd"><strong>Configuration of battery collection function</strong></td>
 <td class="confluenceTd"><strong>Need to be called after dev_system_on_init </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>hal_battery_set_battery_type</strong></span></td>
 <td class="confluenceTd"><strong>Dynamically configure battery type and whether the device wakes up frequently,</strong><br /><strong>SDK According to these parameters, the internal collection strategy will be made internally</strong></td>
 <td class="confluenceTd"><strong>call afer hal_battery_config </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>hal_battery_report_policy_config</strong></span></td>
 <td class="confluenceTd"><strong>Battery special strategy configuration</strong></td>
 <td class="confluenceTd"><strong> call after hal_battery_config </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="7" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>flash 操作</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>flash_block_raw_write</strong></span></td>
 <td class="confluenceTd"><strong>Write flash in blocks,One block is 250 bytes</strong></td>
 <td rowspan="4" class="confluenceTd"><strong>Currently only the big flash version of lib is available该函数,目前只有门锁在用</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>flash_block_raw_read</strong></span></td>
 <td class="confluenceTd"><strong>Read flash by block,One block is 250 bytes</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>flash_addr_raw_write</strong></span></td>
 <td class="confluenceTd"><strong>Write flash according to virtual address</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>flash_addr_raw_read</strong></span></td>
 <td class="confluenceTd"><strong>Write flash according to virtual address</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>user_flash_data_write</strong></span></td>
 <td class="confluenceTd"><strong>Application flash write,Leave 250 bytes of bottom flash area for APP development</strong></td>
 <td rowspan="2" class="confluenceTd"><strong>Call after dev_system_on_init 
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>user_flash_data_read</strong></span></td>
 <td class="confluenceTd"><strong>Application flash write,Leave 250 bytes of bottom flash area for APP development</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="3" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>Off-grid self-recovery network</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>nwk_disable_self_recovery_once</strong></span></td>
 <td class="confluenceTd"><strong>Disable the self-recovery function</strong></td>
 <td rowspan="3" class="confluenceTd"><strong>call after dev_system_on_init </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>nwk_enable_self_recovery_once</strong></span></td>
 <td class="confluenceTd"><strong>Enable self-recovery</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>nwk_self_recovery_manual</strong></span></td>
 <td class="confluenceTd"><strong>Self-recovery immediately</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="4" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>Get all kinds of information</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>zigbee_get_net_info</strong></span></td>
 <td class="confluenceTd"><strong>Obtain device networking parameter information</strong></td>
 <td class="confluenceTd"><strong>call after dev_system_on_init </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>zg_get_join_type</strong></span></td>
 <td class="confluenceTd"><strong>Acquisition networking method: centralized, distributed, not networking</strong></td>
 <td class="confluenceTd"><strong>call after dev_system_on_init </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>zg_get_join_gw_type</strong></span></td>
 <td class="confluenceTd"><strong>Obtain networking gateways: Tuya gateway, other gateways, non-gateway (unnetworked / distributed)</strong></td>
 <td class="confluenceTd"><strong>call after dev_system_on_init </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>zg_is_zll_net</strong></span></td>
 <td class="confluenceTd"><strong>Query whether it is ZLL networking</strong></td>
 <td class="confluenceTd"><strong>Call after dev_system_on_init , zll lib dedicated
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="3" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>General configuration</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_heartbeat_set</strong></span></td>
 <td class="confluenceTd"><strong>Heartbeat configuration</strong></td>
 <td class="confluenceTd"><strong>Call after  dev_system_on_init </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_change_power</strong></span></td>
 <td class="confluenceTd"><strong>Configure transmit power</strong></td>
 <td class="confluenceTd"><strong>Call afterdev_system_on_init  </strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>disable_gw_change_power</strong></span></td>
 <td class="confluenceTd"><strong>Disable the gateway to change the transmit power</strong></td>
 <td class="confluenceTd"><strong>Called in dev_power_on_init</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="4" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>poll 相关</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>zg_poll_interval_change</strong></span></td>
 <td class="confluenceTd"><strong>Change poll interval</strong></td>
 <td rowspan="4" class="confluenceTd"><strong>Called in dev_register_zg_dev_config</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>zg_poll_start</strong></span></td>
 <td class="confluenceTd"><strong>The call will always be poll</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>zg_poll_end</strong></span></td>
 <td class="confluenceTd"><strong>Stop generating new polls,Stop after sending the remaining polls</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>zg_poll_clear</strong></span></td>
 <td class="confluenceTd"><strong>Stop poll now ,</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
 <td class="confluenceTd"><br /></td>
</tr>
<tr>
 <td rowspan="3" class="confluenceTd"><span style="color: rgb(0,128,0);"><strong>属性,endpoint</strong></span></td>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_set_endpoint_alias</strong></span></td>
 <td class="confluenceTd"><strong>Append an alias to an endpoint ,Mainly solves the compatibility problem of endpoint processing when docking with other gateways and Tuya gateways</strong><br /><strong></strong></td>
 <td class="confluenceTd"><strong>Called after dev_register_zg_ep_infor</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_endpint_enable_disable</strong></span></td>
 <td class="confluenceTd"><strong>Dynamically disable and enable an endpoint,After disabling an endpoint,</strong><br /><strong>Remote and local cannot access the endpoint</strong></td>
 <td class="confluenceTd"><strong>call after dev_system_on_init ,It will involve the handling of events</strong></td>
</tr>
<tr>
 <td class="confluenceTd"><span style="color: rgb(0,0,255);"><strong>dev_attr_recovery</strong></span></td>
 <td class="confluenceTd"><strong>Do not use it for the time being, the PID will be restored to the default value instead of the PID value of the production test</strong></td>
 <td class="confluenceTd"><br /></td>
</tr>

Call after Call after

Functional category

Function name

Features

Restrictions

hardware

user_uart_init

Single serial port configuration, including serial port hardware parameters and serial port data receiving callback function, The receiving function is already a function after receiving queue processing,n ot interrupting the environment

dev_system_on_init ,Don't call it in dev_power_on_init , It will be conflicted with the serial port production test

gpio_raw_init

gpio Original initialization

If it is multiplexed with serial port IO, it needs to be called after dev_system_on_init and after. If there is no multiplexing, there is no limit to call

gpio_int_register

gpio Interrupt initialization

If it is multiplexed with serial port IO, it needs to be called after dev_system_on_init and after. If there is no multiplexing, there is no calling limit

Software delay event

dev_timer_stop

Stop a delayed execution event early

dev_system_on_init ,Don't call it in dev_power_on_init, Calling too early will cause an exception,The event frame has not been initialized。If called in an interrupt, At least ensure that the interrupt is generated after dev_system_on_init </ strong> </ td>

dev_timer_start_with_callback

Start a delayed execution event and set the event processing function

appendix

Glossary

noun

Explanation

IoT platform

iot.tuya.com

Zigbee SDK

Based on Silicon branch Zigbee protocol stack after cutting、Optimized packaged Tuya’s Zigbee SDK

Attribute

Attribute (属性)Is a data value reflecting the physical quantity or state

Cluster

Cluster (群集)Is a cluster containing one or more attributes

EndPoint

EndPoint (端点)It is the entrance of the application layer of the protocol stack, that is, the entrance address, and it can also understand where the application object exists. It is a group of clusters defined for the realization of a device description.

Device Id

The serial number defined for each device in Zigbee

Weak current equipment

Refers to battery-powered equipment,A device called sleep end device in the Zigbee protocol

Powerful equipment

Refers to a device that uses mains electricity or is powered from a mains voltage-stabilized power supply, which is called a router in the Zigbee protocol

PID

product ID,Each product created on the Tuya IoT platform will generate a unique product number, which is associated with the product specific function points, APP control panel, shipping information, etc.

SOC

system on chip,The hardware itself has no MCU, and the control program is written into the network module

SDK

Software Development Kit,A software development kit, a collection of related documents, examples, and tools to assist in the development of a certain type of software. In order to encourage developers to use their systems or languages, many SDKs are provided free of charge, as are Tuya's

Firmware

Firmware is a program written in EROM (Erasable Read Only Memory) or EEPROM (Electrically Erasable Programmable Read Only Memory). Firmware refers to the device "driver" stored inside the device. Through the firmware, the operating system can implement the operation of a specific machine according to the standard device driver. For example, the optical drive and the recorder have internal firmware. Firmware is the software that serves as the most basic and lowest level of a system

OTA

It means firmware upgrade, we support OTA

PreviousZigbee Chip SDKNextCloud Mode

Last updated 4 years ago

Was this helpful?

TUYA Zigbee SDK Document