Sub-Device Standard Group

Last Updated on : 2023-09-06 10:18:45download

Standard group enables the user to manage sub-devices of the same type in bulk.


A device group allows the user to instruct devices of the same type to execute the same type of actions in bulk.

How it works

AppCloudSDKApplicationSub-deviceCreate group and device listDevice list responseSelect devices and requestCreate a group and return group IDGroup create within some devicesGroup create within some devices'dev_grp' callbackSend group informationACKSuccessReport resultSuccess or failureAppCloudSDKApplicationSub-device

How to

  • Implement the processing of DTT_SCT_MNC in dtt_tp for the object-type sub-device.
  • Implement the callback for dev_grp_info in device management.
  • Call tuya_subdev_user_sigle_type_reg to register the sub-device management interface.

Data structure

 * @brief subdevice management callback
typedef struct __ty_gw_subdev_mgr_cbs_s {
    GW_PERMIT_ADD_DEV_CB                dev_add;            // permit joining callback, see GW_PERMIT_ADD_DEV_CB
    GW_DEV_DEL_CB                       dev_del;            // remove callback, see GW_DEV_DEL_CB
    DEV_RESET_IFM_CB                    dev_reset;          // reset callback, see DEV_RESET_IFM_CB
    GW_BIND_DEV_INFORM_CB               dev_bind;           // bind result callback, see GW_BIND_DEV_INFORM_CB

    DEV_OBJ_DP_CMD_CB                   dp_cmd_obj;         // obj DP command, see DEV_OBJ_DP_CMD_CB
    DEV_RAW_DP_CMD_CB                   dp_cmd_raw;         // raw DP command, see DEV_RAW_DP_CMD_CB
    DEV_DP_QUERY_CB                     dp_query;           // DP query, see DEV_DP_QUERY_CB

    DEV_HEARTBEAT_SEND_CB               dev_hb;             // heartbeat query callback, see DEV_HEARTBEAT_SEND_CB
    DEV_UG_INFORM_CB                    dev_upgrade;        // upgrade callback, see DEV_UG_INFORM_CB
    GW_DEV_WAKEUP_CB                    dev_wakeup;         // low power device wakeup callback, see GW_DEV_WAKEUP_CB
    GW_DEV_GRP_INFM_CB                  dev_grp_info;       // group control callback, see GW_DEV_GRP_INFM_CB
    GW_DEV_SCENE_INFM_CB                dev_sce_info;       // scene control callback, see GW_DEV_SCENE_INFM_CB

    GW_DEV_SIGMESH_TOPO_UPDAET_CB       bt_topo_update;     // Bluetooth LE device added callback, see GW_DEV_SIGMESH_TOPO_UPDAET_CB
    GW_DEV_SIGMESH_DEV_CACHE_DEL_CB     bt_cache_del;       // Bluetooth LE device removed callback, see GW_DEV_SIGMESH_DEV_CACHE_DEL_CB
    GW_DEV_SIGMESH_CONN_CB              bt_conn;            // Bluetooth LE device event callback, see GW_DEV_SIGMESH_CONN_CB

    DEV_ONLINE_STAT_SEND_CB             dev_online;         // online state changed callback, see DEV_ONLINE_STAT_SEND_CB

API description

Register sub-device interfaces

  * @brief register callback with protocol type
  * @param[in] p_user_dev_node_cbs callback, see TY_GW_SUBDEV_MGR_CBS_S
  * @param[in] user_dev_type       custom protocol type, range from 10 to 19
  * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
OPERATE_RET tuya_subdev_user_sigle_type_reg(TY_GW_SUBDEV_MGR_CBS_S *p_user_dev_node_cbs, BYTE_T user_dev_type);

The sub-device registers interface functions. You need to implement the callback for dev_grp_info. If you need other functions, implement the callback accordingly.


STATIC VOID __dev_cmd_obj_cb(CONST TY_RECV_OBJ_DP_S *cmd)
    if(DTT_SCT_MNC == cmd->dtt_tp){
        if(dp->obj_dp->dps_cnt > LG_SCE_EP_MAX_NUM){
            PR_ERR("dps cnt err dps_cnt:%d",dp->obj_dp->dps_cnt);
            return OPRT_COM_ERROR;

    PR_DEBUG("action:%d dev_id:%s grp_id:%s",action,dev_id,grp_id);
    if( action == GRP_ADD ){
        // add group
    } else if( action == GRP_DEL ){
        // delete group
    } else {
        PR_ERR("value err");
        return OPRT_INVALID_PARM;

    return OPRT_OK;

TY_GW_SUBDEV_MGR_CBS_S dev_cbs = {
        .dp_cmd_obj         = __dev_cmd_obj_cb,
        .dev_grp_info       = __gw_grp_cb

tuya_subdev_user_sigle_type_reg( &dev_cbs , DEV_ATTACH_MOD_1 );