# mco_iot_replicator_clear_class

Delete data only from the specified class that have been transmitted and acknowledged by the peer.

### For an overview see page ARF Applications in C

### Prototype

        MCO_RET mco_iot_replicator_clear_class(mco_iot_replicator_h repl,
                                mco_iot_agent_id_t agent_id,
                                uint2 class_code);

### Arguments

repl | The replicator object
agent_id | The `device_id` to clear or `one of the following constants:`
`MCO_IOT_ALL_AGENTS` | Synchronize all connected devices
`MCO_IOT_SERVER_AGENT_ID` | Denotes the server node
`MCO_IOT_ALL_UP_AGENTS` | All directly or indirectly connected nodes with a lower level value
`MCO_IOT_ALL_DOWN_AGENTS` | All directly or indirectly connected nodes with a higher level value
class_code | The class code (obtainable from the generated `<database_name>.h` header file)

### Description

The function deletes data only from the specified class that has been transmitted and acknowledged by the peer; where `agent_id` is the id of a specific agent or `MCO_IOT_ALL_AGENTS`.

### Return Codes

MCO_S_OK | Data successfully cleared
MCO_E_IOT_INVALID_HANDLE | Invalid replicator handle `repl`
MCO_E_IOT_NOT_INITIALIZED | The IoT runtime was not initialized or the database does not declare IoT in the schema
MCO_E_IOT_WRONG_AGENT_ID | The `agent_id` is not valid
MCO_E_ILLEGAL_PARAM | Incompatible parameter values (e.g. agent_id=`MCO_IOT_SERVER_AGENT_ID` cannot be used on the server, or an invalid `class_code` was used)
MCO_E_SESLIMIT | Or other `connect()` errors if the function can't create a database connection
`mco_trans_start()` errors | Error starting a transaction
``mco_trans_commit()`` errors | Error committing a transaction
other errors | Other errors can happen when accessing database to delete unnecessary data

### Example

        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));
        }

### Files

Header file:
mcoiot.h
Source file:
mcoiotrepl.c
Library:
libmcoiotrepl.a