# TUYA Zigbee SDK Document

### SDK Document version <a href="#title-0-sdk-20document-20version" id="title-0-sdk-20document-20version"></a>

| version | Preparation / Revision Instructions | Revised by              | Revision date | Remarks |
| ------- | ----------------------------------- | ----------------------- | ------------- | ------- |
| 1.0.0   | Create document                     | Liang Deng / Peng Zhang | 2020-03-26    |         |

### SDK summarize <a href="#title-1-sdk-20summarize" id="title-1-sdk-20summarize"></a>

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 <a href="#title-2-sdk-20download" id="title-2-sdk-20download"></a>

<https://github.com/TuyaInc/tuya\\_zigbee\\_sdk>

### SDK Directory Structure <a href="#title-3-sdk-20directory-20structure" id="title-3-sdk-20directory-20structure"></a>

```
    ├── 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 <a href="#title-4-sdk-20overall-20process" id="title-4-sdk-20overall-20process"></a>

![TUYA Zigbee SDK Document](https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/goat/20200401/f4c57d374c2f462798aba312b308275f.png)

#### User-implemented function interface <a href="#title-5-user-implemented-20function-20interface" id="title-5-user-implemented-20function-20interface"></a>

**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 <a href="#title-6-quick-20development-20guide" id="title-6-quick-20development-20guide"></a>

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**                                                      | <p><strong>Single serial port configuration, including serial port hardware parameters and serial port data receiving callback function，</strong><br><strong>The receiving function is already a function after receiving queue processing，n ot interrupting the environment</strong></p> | <p><strong>dev\_system\_on\_init ，Don't call it in dev\_power\_on\_init ，</strong><br><strong>It will be conflicted with the serial port production test</strong></p>                                                                                                                                                                       |
| **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**                                                                                                                                                                                                                                                  | <p><strong>dev\_system\_on\_init ，Don't call it in dev\_power\_on\_init，</strong><br><strong>Calling too early will cause an exception，The event frame has not been initialized。If called in an interrupt，</strong><br><strong>At least ensure that the interrupt is generated after dev\_system\_on\_init \</ strong> \</ td></strong></p> |
| **dev\_timer\_start\_with\_callback** | **Start a delayed execution event and set the event processing function** |                                                                                                                                                                                                                                                                                           |                                                                                                                                                                                                                                                                                                                                             |

### appendix <a href="#title-7-appendix" id="title-7-appendix"></a>

#### Glossary <a href="#title-8-glossary" id="title-8-glossary"></a>

| 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                                                                                                                                                                                                                                                                                                                                                                                                                                                             |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ifreeq.com/developer/device-development/access-mode-link/zigbee-chip-sdk/tuya-zigbee-sdk-document.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
