Callback Functionality

An adapter implementation can use callback functions to log on to the ESP Server, retrieve information related to schemas, and convey state information to the ESP Server.

Callback functions are contained in the esp_server_lib.lib file for Windows installations, and in the libesp_server_lib.so file for Linux and Solaris installations.

These functions are used for both input and output adapters, unless otherwise noted.

API Description
void postEndSync(void* callBackReference); Notifies the adapter implementation that the base data flow has ended. Call this API for output adapters only.
void logMessage(void* callBackReference,int level,const char* message); Logs a message with the adapter implementation. The valid values for the the severity level are:
  • L_EMERG
  • L_ALERT
  • L_CRIT
  • L_ERR
  • L_WARNING
  • L_NOTICE
  • L_INFO
  • L_DEBUG
void postStartSync(void* callBackReference); Notifies the adapter implementation that the base data is about to be sent. Call this API for output adapters only.
void notifyConnState(void* callBackReference, int oldSt, int st); Notifies the ESP Server that the adapter state has changed. The valid values for adapter state are:
  • RS_READY - ready to start.
  • RS_INITIAL - performing start-up activities.
  • RS_CONTINUOUS - ready to continuously receive data.
  • RS_IDLE - timeout.
  • RS_DONE - no more incoming data, ready to exit.
  • RS_DEAD - stopped receiving data, is inactive.
int getColumnCount(void* connectionRowType); Retrieves the number of existing columns of a given row type from the adapter implementation.
const char* getColumnName(void* connectionRowType, int pos); Retrieves a column name using the column's position in the adapter implementation.
void* getTimeContext(void* callBackReference); Retrieves information contained in the TimeContext object from ESP Server.
const char* getStreamName(void* connectionRowType); Retrieves the name of the stream specified by the given ConnectionRowType.
void deactivateOutput(void* callBackReference); Tells a stream to temporarily suspend output data flow.
void activateOutput(void* callBackReference, bool sendBase); Requests the stream to start sending output data. This is indicated by the sendBase flag.
void setAdapterState(void* callBackReference, int state); Sets up a running state for the adapter implementation.
int getAdapterState(void* callBackReference); Retrieves running state information from the adapter implementation.
int getColumnDatatype(void* callBackReference, int pos); Retrieves the type of a field using the field's position in the CallBackReference object.
void addAdapterStatistics(void* adapterStatistics, const char* key, const char* value); Populates the AdapterStatistics object with a custom statistics item in key-value format.