更新时间:2023-09-20 09:09:38下载pdf
子设备移除 是将设备从云端移除的功能,本文将详细介绍 子设备移除 用法。
子设备移除 有两种实现方式:
通过手机 App 移除:
应用需要调用 tuya_subdev_user_sigle_type_reg
接口注册设备管理回调,并实现 dev_del
和 dev_reset
的回调接口。
通过应用主动移除:
应用需要调用 tuya_iot_gw_unbind_dev
。
/**
* @brief sub-device 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
}TY_GW_SUBDEV_MGR_CBS_S;
/**
* @brief unbind a sub-device from the gateway, which will be blocked in the process.
*
* @param id sub-device id
* @return OPERATE_RET OPRT_OK is success
*/
OPERATE_RET tuya_iot_gw_unbind_dev(IN CONST CHAR_T *id);
若应用需要本地移除子设备,则需要调用以上 tuya_iot_gw_unbind_dev
接口通知云端解绑子设备。移除成功将返回 OPRT_OK
。
/**
* @brief The callback to invoke when to delete a device.
* @param[in] dev_id : The device ID
* @param[in] type : The delete mode
*/
STATIC VOID __dev_del_cb(CONST CHAR_T *dev_id, CONST GW_DELDEV_TYPE type)
{
/**
* TODO:
* type == GWDEV_DELTYPE_MQTT: MQTT(real time)
* type == GWDEV_DELTYPE_SYNC: device not in the cloud, need delete.
*/
}
/**
* @brief The callback to invoke when to reset a device.
* @param[in] dev_id : The device ID
* @param[in] type : The reset mode
*/
STATIC VOID __dev_reset_cb(CONST CHAR_T *dev_id, DEV_RESET_TYPE_E type)
{
/**
* TODO
* type == DEV_REMOTE_RESET_FACTORY: App remote
* type == DEV_RESET_DATA_FACTORY: need clear local data when bind
*/
}
TY_GW_SUBDEV_MGR_CBS_S dev_mgr_cbs = {
.dev_del = __dev_del_cb,
.dev_reset = __dev_reset_cb,
};
tuya_subdev_user_sigle_type_reg( &dev_mgr_cbs , DEV_ATTACH_MOD_1 );
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈