mco_iot_replicator_clear_class
该函数仅从已由对等方传输并确认的指定类中删除数据。
其中 agent_id
是特定 agent 的识别符或 MCO_IOT_ALL_AGENTS
。
MCO_RET mco_iot_replicator_clear_class(
mco_iot_replicator_h repl,
mco_iot_agent_id_t agent_id,
uint2 class_code
);
有关概述,请参阅主动复制结构页面。
参数
repl
mco_iot_replicator_h
复制器对象。
agent_id
mco_iot_agent_id_t
要清除的device_id或以下常量之一:
- MCO_IOT_ALL_AGENTS:同步所有连接的设备。
- MCO_IOT_SERVER_AGENT_ID:表示服务器节点。
- MCO_IOT_ALL_UP_AGENTS:所有直接或间接连接的具有较低级别值的节点。
- MCO_IOT_ALL_DOWN_AGENTS:所有直接或间接连接的具有更高级别值的节点。
class_code
uint2
类代码(可从生成的<database_name>.h
头文件中获得)
返回
MCO_S_OK
数据已成功清除。
MCO_E_IOT_INVALID_HANDLE
无效的复制器句柄 repl
。
MCO_E_IOT_NOT_INITIALIZED
物联网运行时未初始化,或者数据库模式中未声明物联网。
MCO_E_IOT_WRONG_AGENT_ID
agent_id
无效。
MCO_E_ILLEGAL_PARAM
参数值不兼容。
MCO_E_SESLIMIT
如果该函数无法创建数据库连接,则会出现其他 connect()
错误。
mco_trans_start()
错误
启动事务时出错。
mco_trans_commit()
错误
提交事务时出错。
其他错误
在访问数据库以序列化更改时可能会发生其他错误。
示例
void Clear_Classes(mco_iot_replicator_h iot_replicator)
{
uint2 TempSensor_code = 1;
uint2 WindSensor_code = 2;
rc = mco_iot_replicator_sync(iot_replicator, MCO_IOT_ALL_AGENTS, MCO_IOT_SYNC_BOTH | MCO_IOT_SYNC_WAIT);
CHECK(mco_iot_replicator_clear_class(iot_replicator, MCO_IOT_SERVER_AGENT_ID, TempSensor_code));
CHECK(mco_iot_replicator_clear_class(iot_replicator, MCO_IOT_SERVER_AGENT_ID, WindSensor_code));
}
文件
- 头文件:
mcoiot.h
- 源文件:
mcoiotrepl.c
- 库:
libmcoiotrepl.a