@@ -146,6 +146,19 @@ sparkplug_publisher_t* sparkplug_publisher_create(const char* broker_url, const
146146 */
147147void sparkplug_publisher_destroy (sparkplug_publisher_t * pub);
148148
149+ /* *
150+ * @brief Sets MQTT username and password for authentication.
151+ *
152+ * @param pub Publisher handle
153+ * @param username MQTT username (may be NULL to unset)
154+ * @param password MQTT password (may be NULL to unset)
155+ * @return 0 on success, -1 on failure
156+ *
157+ * @note Must be called before sparkplug_publisher_connect().
158+ */
159+ int sparkplug_publisher_set_credentials (sparkplug_publisher_t * pub, const char * username,
160+ const char * password);
161+
149162/* *
150163 * @brief Connects the publisher to the MQTT broker.
151164 *
@@ -386,6 +399,19 @@ sparkplug_host_application_t* sparkplug_host_application_create(const char* brok
386399 */
387400void sparkplug_host_application_destroy (sparkplug_host_application_t * host);
388401
402+ /* *
403+ * @brief Sets MQTT username and password for authentication.
404+ *
405+ * @param host Host Application handle
406+ * @param username MQTT username (may be NULL to unset)
407+ * @param password MQTT password (may be NULL to unset)
408+ * @return 0 on success, -1 on failure
409+ *
410+ * @note Must be called before sparkplug_host_application_connect().
411+ */
412+ int sparkplug_host_application_set_credentials (sparkplug_host_application_t * host,
413+ const char * username, const char * password);
414+
389415/* *
390416 * @brief Connects the Host Application to the MQTT broker.
391417 *
@@ -500,6 +526,19 @@ sparkplug_subscriber_t* sparkplug_subscriber_create(const char* broker_url, cons
500526 */
501527void sparkplug_subscriber_destroy (sparkplug_subscriber_t * sub);
502528
529+ /* *
530+ * @brief Sets MQTT username and password for authentication.
531+ *
532+ * @param sub Subscriber handle
533+ * @param username MQTT username (may be NULL to unset)
534+ * @param password MQTT password (may be NULL to unset)
535+ * @return 0 on success, -1 on failure
536+ *
537+ * @note Must be called before sparkplug_subscriber_connect().
538+ */
539+ int sparkplug_subscriber_set_credentials (sparkplug_subscriber_t * sub, const char * username,
540+ const char * password);
541+
503542/* *
504543 * @brief Connects the subscriber to the MQTT broker.
505544 *
0 commit comments