mco_iot_replicator_clear

Delete data 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(mco_iot_replicator_h repl, 
                        mco_iot_agent_id_t agent_id);
 

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

Description

The function deletes data 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)
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

     
    // onAck callback
    int iot_on_ack(mco_iot_connection_h iotc, const iot_ack_t *ack, void *context)
    {
        // Remove unnecessary data on receiving positive ACK
        if (ack->error_code == MCO_S_OK) 
        {
            mco_iot_replicator_h repl = (mco_iot_replicator_h) context;
            mco_iot_agent_id_t agent_id = mco_iot_conn_get_agent_id(iotc);
            mco_iot_replicator_clear(repl, agent_id);
        }
        return IOT_CALLBACK_OK;
    }
     

Files

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