Methods
sapiConnect¶
Establishes a connection to a KX Sensors system. The function is blocking and will not return until the connection attempt is completed.
Signature:
KxsHandle sapiConnect(SAPIConfig *config, KxsResponse *response);
Parameters:
config: Configuration details for connection.response: Optional structure for receiving status.
Returns:
KxsHandle: Handle to the client connection.
sapiDisconnect¶
Disconnects from KX Sensors and stops active subscriptions.
Signature:
void sapiDisconnect(KxsHandle handle);
Parameters:
handle: Handle to the KXS connection.
sapiExecute¶
Executes an API call on the server.
Signature:
bool sapiExecute(KxsHandle handle, char *apiName, K request, K header, bool deserializeResponse, SAPIRetryPolicy *retryPolicy, KxsResponse *response);
Parameters:
handle: Client handle.apiName: Name of the API.request: Request data.header: Header augmentation.deserializeResponse: Deserialize response if true.retryPolicy: Retry policy.response: Optional result status.
Returns:
bool: Success indicator.
sapiPublish¶
Publishes data to KX Sensors.
Signature:
bool sapiPublish(TopicHandle handle, short msgType, K data, K header, SAPIRetryPolicy *retryPolicy, KxsResponse *response);
Parameters:
handle: Topic handle.msgType: Message type.data: Data to publish.header: Header augmentation.retryPolicy: Retry policy.response: Optional result status.
Returns:
bool: Success indicator.
sapiRegisterPublisher¶
Registers a publisher for a specific topic.
Signature:
TopicHandle sapiRegisterPublisher(KxsHandle handle, char *topicName, KxsResponse *response);
Parameters:
handle: Client handle.topicName: Topic name.response: Optional result status.
Returns:
TopicHandle: Handle for the registered topic.
sapiUnregisterPublisher¶
Unregisters a topic publisher.
Signature:
bool sapiUnregisterPublisher(KxsHandle handle, TopicHandle topicHandle, KxsResponse *response);
Parameters:
handle: Client handle.topicHandle: Topic handle.response: Optional result status.
Returns:
bool: Success indicator.
sapiSetLogLevels¶
Configures logging levels used by SAPI.
Signature:
void sapiSetLogLevels(short traceLevel, short debugLevel, short infoLevel, short warnLevel, short errorLevel, short fatalLevel);
Parameters:
traceLevel: Level for TRACE logs.debugLevel: Level for DEBUG logs.infoLevel: Level for INFO logs.warnLevel: Level for WARN logs.errorLevel: Level for ERROR logs.fatalLevel: Level for FATAL logs.
sapiRegisterLogHandler¶
Registers a global logging handler.
Signature:
void sapiRegisterLogHandler(LogHandler callback);
Parameters:
callback: Logging callback.
sapiEventHandler¶
Retrieves the event handler for the SAPI connection.
Signature:
SAPIEvents *sapiEventHandler(KxsHandle handle);
Parameters:
handle: Client handle.
Returns:
SAPIEvents*: Event handler structure.
sapiGetTcpEndpoint¶
Retrieves TCP endpoint details.
Signature:
bool sapiGetTcpEndpoint(KxsHandle handle, char *sb, int len);
Parameters:
handle: Client handle.sb: Buffer to store endpoint details.len: Buffer length.
Returns:
bool: Success indicator.
sapiFreeKxsResponse¶
Frees a KxsResponse object.
Signature:
void sapiFreeKxsResponse(KxsResponse *response);
Parameters:
response: Response object to free.
sapiFreeSAPIConfig¶
Frees a SAPIConfig object.
Signature:
void sapiFreeSAPIConfig(SAPIConfig *config);
Parameters:
config: Configuration object to free.