Files
ANSCMSCORE/anscloud-gateway/include/anscloud/gateway/gateway_agent_c.h

58 lines
2.1 KiB
C
Raw Normal View History

2026-03-28 12:05:34 +11:00
#pragma once
#ifndef ANSCLOUD_GATEWAY_AGENT_C_H
#define ANSCLOUD_GATEWAY_AGENT_C_H
#ifdef ANSCLOUD_GATEWAY_EXPORTS
#define ANSCLOUD_GATEWAY_CAPI __declspec(dllexport)
#else
#define ANSCLOUD_GATEWAY_CAPI __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct AnsGatewayAgent* AnsGatewayAgentHandle;
typedef struct {
const char* host;
int port;
const char* username;
const char* password;
const char* vhost;
int use_tls;
} AnsGatewayBrokerConfig;
typedef struct {
const char* username;
const char* password;
const char* vhost;
} AnsGatewayCredentials;
typedef struct {
AnsGatewayBrokerConfig broker;
AnsGatewayCredentials credentials;
int device_timeout_seconds;
int default_command_timeout_seconds;
int max_pending_commands;
} AnsGatewayConfig;
// Callbacks - all receive JSON strings
typedef void (*AnsGatewayTelemetryCallbackFn)(const char* telemetry_json, void* user_data);
typedef void (*AnsGatewayHeartbeatCallbackFn)(const char* heartbeat_json, void* user_data);
typedef void (*AnsGatewayEventCallbackFn)(const char* event_json, void* user_data);
typedef void (*AnsGatewayDeviceStatusCallbackFn)(const char* device_id, const char* status, void* user_data);
typedef void (*AnsGatewayConnectionCallbackFn)(int connected, void* user_data);
typedef void (*AnsGatewayErrorCallbackFn)(const char* error, void* user_data);
//=============================================================================
// Lifecycle
//=============================================================================
ANSCLOUD_GATEWAY_CAPI AnsGatewayAgentHandle ansgateway_create(void);
ANSCLOUD_GATEWAY_CAPI void ansgateway_destroy(AnsGatewayAgentHandle handle);
ANSCLOUD_GATEWAY_CAPI int ansgateway_configure(AnsGatewayAgentHandle handle, const AnsGatewayConfig* config);
ANSCLOUD_GATEWAY_CAPI int ansgateway_start(AnsGatewayAgentHandle handle);
ANSCLOUD_GATEWAY_CAPI void ansgateway_stop(AnsGatewayAgentHandle handle);
ANSCLOUD_GATEWAY_CAPI int ansgateway_is_running(AnsGatewayAgentHandle handle);
ANSCLOUD_GATEWAY_CAPI int ansgateway_is_connected(AnsGatewayAgentHandle handle);