![]() |
Device Data Hub C API
|
Client interface for Device Data Hub API. More...

Go to the source code of this file.
Macros | |
| #define | DH_CONN_DISCONNECTED ((DHConnectionState)0) |
| Client is disconnected from the Device Data Hub. | |
| #define | DH_CONN_CONNECTED ((DHConnectionState)1) |
| Client is connected to the Device Data Hub. | |
| #define | DH_LOG_OFF ((DHLogLevel)0) |
| No logging output. | |
| #define | DH_LOG_CRITICAL ((DHLogLevel)1) |
| Critical errors that may cause application failure. | |
| #define | DH_LOG_ERROR ((DHLogLevel)2) |
| Error conditions that indicate a failure in a specific operation. | |
| #define | DH_LOG_WARNING ((DHLogLevel)3) |
| Warning messages for potentially problematic situations. | |
| #define | DH_LOG_INFO ((DHLogLevel)4) |
| Informational messages about normal operation. | |
| #define | DH_LOG_DEBUG ((DHLogLevel)5) |
| Debug information useful for troubleshooting. | |
| #define | DH_LOG_TRACE ((DHLogLevel)6) |
| Detailed trace information for comprehensive debugging. | |
| #define | DH_LOG_TARGET_CONSOLE ((DHLogTarget)0) |
| Output log messages to console/stdout. | |
| #define | DH_LOG_TARGET_SYSLOG ((DHLogTarget)1) |
| Output log messages to the system logger. | |
Typedefs | |
| typedef uint32_t | DHConnectionState |
| Enumeration of connection states for the Device Data Hub client. More... | |
| typedef uint32_t | DHLogLevel |
| Enumeration of available log levels for the Device Data Hub client. More... | |
| typedef uint32_t | DHLogTarget |
| Enumeration of available log output targets. More... | |
| typedef void(* | DHOnConnectionUpdateCallback) (DHConnectionState update, void *user_data) |
| Connection state update callback function type. More... | |
| typedef struct DHClient_t | DHClient |
| Opaque client handle. | |
Functions | |
| DHClient * | dh_client_create (const char *name, DHError **error) |
| Creates a new client instance. More... | |
| const char * | dh_client_get_name (const DHClient *client) |
| Gets the name of the client. More... | |
| bool | dh_client_set_connection_update_callback (DHClient *client, DHOnConnectionUpdateCallback callback, void *user_data, DHError **error) |
| Sets the connection state update callback. More... | |
| bool | dh_client_connect (DHClient *client, DHError **error) |
| Connects the client synchronously to the Device Data Hub. More... | |
| bool | dh_client_disconnect (DHClient *client, DHError **error) |
| Disconnects the client from the Device Data Hub. More... | |
| void | dh_client_destroy (DHClient *client) |
| Destroys a client instance. More... | |
| DHConnectionState | dh_client_get_connection_state (const DHClient *client) |
| Gets the current connection state. More... | |
| DHTopic * | dh_client_create_topic_from_file (DHClient *client, const char *file_path, DHError **error) |
| Creates a new topic from the definition. More... | |
| DHTopic * | dh_client_create_topic (DHClient *client, const char *topic_def, DHError **error) |
| Creates a new topic from the definition. More... | |
| bool | dh_client_delete_topic (DHClient *client, const char *topic_name, DHError **error) |
| Deletes a topic from the Device Data Hub. More... | |
| DHTopicList * | dh_client_get_topic_list (DHClient *client, DHError **error) |
| Gets a list of available topics. More... | |
| DHTopic * | dh_client_get_topic (DHClient *client, const char *topic_name, DHError **error) |
| Gets a topic by name. More... | |
| DHTopicInstanceList * | dh_client_get_topic_instances (DHClient *client, const char *topic_name, DHError **error) |
| Gets topic instances for a topic. More... | |
| DHWriter * | dh_client_create_writer (DHClient *client, const char *writer_name, const char *topic_name, DHError **error) |
| Creates a writer for a specific topic. More... | |
| DHSubscriber * | dh_client_create_subscriber (DHClient *client, const char *subscriber_name, DHError **error) |
| Creates a topic data subscriber. More... | |
| bool | dh_client_set_logging (DHClient *client, DHLogLevel level, DHLogTarget target, DHError **error) |
| Configures logging for the Device Data Hub client. More... | |
Client interface for Device Data Hub API.
This file provides the primary client interface for connecting to and interacting with the Device Data Hub service. It manages the client lifecycle, connection handling, and creation of writers and subscribers.
| typedef uint32_t DHConnectionState |
Enumeration of connection states for the Device Data Hub client.
Represents the various states that the client's connection to the Device Data Hub can be in, such as disconnected, connected, or in the process of connecting.
| typedef uint32_t DHLogLevel |
Enumeration of available log levels for the Device Data Hub client.
Defines the severity levels for logging messages, ordered from least verbose (OFF) to most verbose (DH_LOG_TRACE). Each level includes all messages from less verbose levels.
| typedef uint32_t DHLogTarget |
Enumeration of available log output targets.
Specifies where log messages should be directed.
| typedef void(* DHOnConnectionUpdateCallback) (DHConnectionState update, void *user_data) |
Connection state update callback function type.
Callback function called when the connection state changes.
| update | The new connection state |
| user_data | User-provided data passed to dh_client_set_connection_update_callback() |
Connects the client synchronously to the Device Data Hub.
This function attempts to establish a connection between the client and the Device Data Hub. The client must have the required access rights to connect. Once connected, the client can perform operations such as publishing data to and subscribing to topics on the Device Data Hub.
| client | The client (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_ALREADY_CONNECTEDDH_ERR_CREDENTIAL_ERRORDH_ERR_AUTHENTICATION_FAILEDDH_ERR_MAX_CLIENTSDH_ERR_MAX_CONNECTIONSDH_ERR_INTERNAL_ERROR Creates a new client instance.
Creates a new Device Data Hub client with the specified name.
| name | The name of the client (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
| DHSubscriber* dh_client_create_subscriber | ( | DHClient * | client, |
| const char * | subscriber_name, | ||
| DHError ** | error | ||
| ) |
Creates a topic data subscriber.
Creates a new data subscriber that can receive data from multiple topics.
| client | The client (must not be NULL) |
| subscriber_name | The name of the topic subscriber (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_INVALID_PARAMSDH_ERR_INTERNAL_ERROR Creates a new topic from the definition.
Creates a new topic on the Device Data Hub using a topic definition string. The format of the definition follows the JSON schema described in the main documentation.
| client | The client (must not be NULL) |
| topic_def | Topic definition in json string (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_INVALID_PARAMSDH_ERR_TOPIC_EXISTSDH_ERR_NOT_CONNECTEDDH_ERR_AUTHORIZATION_FAILEDDH_ERR_MAX_TOPICDH_ERROR_DATA_TOO_BIGDH_ERR_INTERNAL_ERROR | DHTopic* dh_client_create_topic_from_file | ( | DHClient * | client, |
| const char * | file_path, | ||
| DHError ** | error | ||
| ) |
Creates a new topic from the definition.
Creates a new topic on the Device Data Hub using a topic definition string. The format of the definition follows the JSON schema described in the main documentation.
| client | The client (must not be NULL) |
| file_path | Path to a JSON file containing the topic definition (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_INVALID_PARAMSDH_ERR_TOPIC_EXISTSDH_ERR_NOT_CONNECTEDDH_ERR_AUTHORIZATION_FAILEDDH_ERR_MAX_TOPICDH_ERROR_DATA_TOO_BIGDH_ERR_INTERNAL_ERROR | DHWriter* dh_client_create_writer | ( | DHClient * | client, |
| const char * | writer_name, | ||
| const char * | topic_name, | ||
| DHError ** | error | ||
| ) |
Creates a writer for a specific topic.
Creates a new writer and initializes it for the specified topic. The topic must already exist on the Device Data Hub.
| client | The client (must not be NULL) |
| writer_name | The name of the writer (must not be NULL) |
| topic_name | The name of the topic to write to (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_INVALID_PARAMSDH_ERR_INVALID_TOPICDH_ERR_NOT_CONNECTEDDH_ERR_INTERNAL_ERROR Deletes a topic from the Device Data Hub.
Permanently removes a topic and all its data from the Device Data Hub.
| client | The client (must not be NULL) |
| topic_name | The name of the topic to delete (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_INVALID_PARAMSDH_ERR_INVALID_TOPICDH_ERR_NOT_CONNECTEDDH_ERR_AUTHORIZATION_FAILEDDH_ERROR_DATA_TOO_BIGDH_ERR_INTERNAL_ERROR | void dh_client_destroy | ( | DHClient * | client | ) |
Destroys a client instance.
Frees all resources associated with the client. The client will be automatically disconnected if still connected. This function will block until all ongoing callbacks have completed and no further callbacks will be invoked after it returns.
| client | The client to destroy (can be NULL) |
Disconnects the client from the Device Data Hub.
This method terminates the connection between the client and the Device Data Hub. All created writers/subscriptions will be invalidated and won't operate.
| client | The client (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_NOT_CONNECTEDDH_ERR_INTERNAL_ERROR | DHConnectionState dh_client_get_connection_state | ( | const DHClient * | client | ) |
Gets the current connection state.
Returns the detailed connection state of the client.
| client | The client (must not be NULL) |
| const char* dh_client_get_name | ( | const DHClient * | client | ) |
Gets the name of the client.
Returns the name that was specified when the client was created.
| client | The client (must not be NULL) |
Gets a topic by name.
Retrieves a topic for an existing topic on the Device Data Hub.
| client | The client (must not be NULL) |
| topic_name | The name of the topic to retrieve (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_INVALID_PARAMSDH_ERR_INVALID_TOPICDH_ERR_NOT_CONNECTEDDH_ERROR_DATA_TOO_BIGDH_ERR_INTERNAL_ERROR | DHTopicInstanceList* dh_client_get_topic_instances | ( | DHClient * | client, |
| const char * | topic_name, | ||
| DHError ** | error | ||
| ) |
Gets topic instances for a topic.
Retrieves a list of all instances for the specified topic. The returned list must be freed using dh_topic_instance_list_destroy().
| client | The client (must not be NULL) |
| topic_name | The name of the topic (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_INVALID_PARAMSDH_ERR_INVALID_TOPICDH_ERR_NOT_CONNECTEDDH_ERROR_DATA_TOO_BIGDH_ERR_INTERNAL_ERROR | DHTopicList* dh_client_get_topic_list | ( | DHClient * | client, |
| DHError ** | error | ||
| ) |
Gets a list of available topics.
Retrieves a list of all topic names available on the Device Data Hub. The returned list must be freed using dh_topic_list_destroy().
| client | The client (must not be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
Possible error codes:
DH_ERR_NOT_CONNECTEDDH_ERR_INTERNAL_ERROR | bool dh_client_set_connection_update_callback | ( | DHClient * | client, |
| DHOnConnectionUpdateCallback | callback, | ||
| void * | user_data, | ||
| DHError ** | error | ||
| ) |
Sets the connection state update callback.
Registers a callback to receive connection state change notifications.
| client | The client (must not be NULL) |
| callback | Callback function for connection state changes (can be NULL to remove) |
| user_data | User-provided data passed to the callback (can be NULL) |
| error | Output parameter for error details on failure (can be NULL to ignore) |
| bool dh_client_set_logging | ( | DHClient * | client, |
| DHLogLevel | level, | ||
| DHLogTarget | target, | ||
| DHError ** | error | ||
| ) |
Configures logging for the Device Data Hub client.
This method allows dynamic configuration of the logging settings for the Device Data Hub client at runtime.
| client | The client (must not be NULL) |
| level | The log level to set |
| target | The log output target to set |
| error | Output parameter for error details on failure (can be NULL to ignore) |