English
English
简体中文
Register
Log In
English
English
简体中文
Register
Log In
Language
English
English
简体中文
Register
Log In

Zigbee Sub-device Custom DP Access Specification

Last Updated on2024-02-22 09:09:06

DP Basic Concepts

DP (Data Point) is an abstract way to describe a device object's function point. DP operations represent changing the device's state through predetermined functional characteristics, such as using a switch DP to change a device's on and off state. Tuya defines DPs within 100 as Tuya standard DPs, and 101-255 as your custom DPs.

DP Basic Types

The common types of DP include Boolean, numeric, enumeration, character, bitmap, and transparent (Raw) types.

Purpose of Custom DPs

Terminal devices can carry out personalized function development by creating custom DPs when accessing the Tuya cloud.

Standardized Access Process

  • 1. Add a private transparent cluster0xEF00.
    #define PRIVATE_ATTR_LIST \
    {0x0000, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_TOKEN_FAST|ATTR_MASK_SINGLETON), 0, (UINT8_T*)0x00 }, /* current positiong lift percentage*/\
    {0xFFFD, ATTR_INT16U_ATTRIBUTE_TYPE, 2, (ATTR_MASK_READABLE), 0, (UINT8_T *)0x0002},
    const TAL_ATTR_T g_private_attr_list[] = {
    PRIVATE_ATTR_LIST};
    #define DEF_CLUSTER_PRIVATE_CLUSTER_ID(a) \
    { CLUSTER_PRIVATE_TUYA_CLUSTER_ID, (TAL_ATTR_T *)&((a)[0]), GET_ARRAY_LEN((a)) },
    CONST TAL_CLUSTER_T app_server_cluster_list[] = {
    DEF_CLUSTER_PRIVATE_CLUSTER_ID(g_private_attr_list)
    2. Modify the capability values in the JSON file. Inapps/xxx_demo/appconfig.json, modify"manufacture_name":"_TZ3210_".
    {
    "firmwareInfo": {
    "description": "this is a demon project",
    "dev_role":"sleep_end_dev",
    "module_name":"ZT3L",
    "chip_id":"TLSR8258F1KET",
    "image_type":"0xD3A3",
    "manufacture_id":"0x1141",
    "model_id":"TS0202",
    "pid": "",
    "manufacture_name": "_TZ3210_"
    }
    }
    The dev_role item can be selected according to the type of device created, such as router or sleep_end_dev. The script will connect to different libraries based on different configurations.
  • The above pid item can be filled with the product pid created on the Tuya IoT Development Platform.
    3. DP transparent transmission business requires the cooperation of the panel. It should be noted that the functions in the Tuya panel correspond one-to-one with the DPs. You can define some private DPs, but if the function of a private DP is the same as that of a Tuya standard DP, when the panel issues a function, it issues the standard DP.
    During development, you can use the debugging panel.
  • 4. Transparent transmission reception and sending. Tuya has defined the commands for module and gateway interaction:
    • Gateway issues DP to the module:0x04
    • Module responds to gateway issued DP:0x05
    • Module actively reports DP to the gateway:0x06
    Reception Entry
    TAL_MSG_RET_E tal_zcl_specific_msg_recv_callback(TAL_ZCL_MSG_T *msg)
    switch(msg->cluster)
    case 0xEF00{
    switch(msg->command){
    case 0x04 :{
    air_data_response(msg->dst_ep,
    msg->len, &(msg->playload[0]), 0x05, QOS_1)
    }
    }
    }
    ...
    Device Response Reply
    air_data_response(uint8_t ep, uint8_t len uint8_t *data, uint8_t command_id TAL_SEND_QOS_E qos ){
    tal_system_memset(&send_data, 0, SIZEOF(TAL_ZG_SEND_DATA_T));
    send_data.qos = qos;
    send_data.delay_time = 0;
    send_data.zcl_id = 0x68;
    send_data.direction = ZG_ZCL_DATA_SERVER_TO_CLIENT;
    send_data.frame_type = ZG_ZCL_FRAME_TYPE_SPEC_TO_CLUSTER;
    send_data.command_id = command_id;/*respose cmd 0x05 */
    send_data.addr.mode = SEND_MODE_DEV;
    send_data.addr.type.dev.cluster_id = 0xEF00;
    send_data.addr.type.dev.src_ep = ep;
    send_data.data.private.len = len;
    memcpy((send_data.data.private.data), data, len);
    tal_zg_clear_send_data(ZG_CLEAR_ALL_ZCL_ID, &send_data.zcl_id);
    tal_zg_send_data(&send_data, NULL, 2000);
    }
    Device Active Reporting
    tal_system_memset(&send_data, 0, SIZEOF(TAL_ZG_SEND_DATA_T));
    send_data.qos = QOS_1;
    send_data.delay_time = 0;
    send_data.zcl_id = 0x68;
    send_data.direction = ZG_ZCL_DATA_SERVER_TO_CLIENT;
    send_data.frame_type = ZG_ZCL_FRAME_TYPE_SPEC_TO_CLUSTER;
    send_data.command_id = 0x06;/*report cmd*/
    send_data.addr.mode = SEND_MODE_DEV;
    send_data.addr.type.dev.dst_addr = TUYA_GATEWAY_ADDRESS;
    send_data.addr.type.dev.dst_ep = 0x01;
    send_data.addr.type.dev.src_ep = TUYA_PRIMARY_ENDPOINT;
    send
  • Click for services and help

    Help Center