khoih-prog / AsyncMQTT_Generic

Arduino Arduino Library for ESP8266, ESP32, Portenta_H7, STM32 and RP2040W asynchronous MQTT client implementation. This library, ported to support ESP32, WT32_ETH01 (ESP32 + LAN8720), ESP8266, Portenta_H7 (Ethernet or WiFi) and STM32 (LAN8742A or LAN8720 Ethernet), Teensy 4.1 using QNEthernet, RASPBERRY_PI_PICO_W with CYW43439 WiFi. Currently supporting TLS/SSL for ESP32 only
MIT License
62 stars 10 forks source link

mqtt connection with clientid, username and password #6

Closed darkcurrent closed 2 years ago

darkcurrent commented 2 years ago

Hello, this is a very cool library. But I am little bit confused about how to set clientid, username and password for mqtt connection. Could you help me please?

khoih-prog commented 2 years ago

Hi,

Thanks for using the library and your nice words.

Normally, the username / password are required only by certain MQTT Broker. clientID is generated automatically by the library using MAC address, ESP chipID, etc.

If those are required, follow these steps

  1. For username / password, you can use function setCredentials(username, password) as defined in

https://github.com/khoih-prog/AsyncMQTT_Generic/blob/9bc9c19c5cc55b960b002f14b7fc252a30e1d855/src/AsyncMqttClient_Generic_Impl.h#L253-L259

  1. For clientID, use function setClientId(clientId) as defined in

https://github.com/khoih-prog/AsyncMQTT_Generic/blob/9bc9c19c5cc55b960b002f14b7fc252a30e1d855/src/AsyncMqttClient_Generic_Impl.h#L224-L229

If not using setClientId(), the clientID will be auto-created


As this is not a bug of the library, I'm closing the issue now and suggest next time, post on Discussions or Arduino Forum to get help.

Good Luck,

NotrinoResearch commented 2 years ago

Hi,

Thanks for using the library and your nice words.

Normally, the username / password are required only by certain MQTT Broker. clientID is generated automatically by the library using MAC address, ESP chipID, etc.

If those are required, follow these steps

  1. For username / password, you can use function setCredentials(username, password) as defined in

https://github.com/khoih-prog/AsyncMQTT_Generic/blob/9bc9c19c5cc55b960b002f14b7fc252a30e1d855/src/AsyncMqttClient_Generic_Impl.h#L253-L259

  1. For clientID, use function setClientId(clientId) as defined in

https://github.com/khoih-prog/AsyncMQTT_Generic/blob/9bc9c19c5cc55b960b002f14b7fc252a30e1d855/src/AsyncMqttClient_Generic_Impl.h#L224-L229

If not using setClientId(), the clientID will be auto-created

As this is not a bug of the library, I'm closing the issue now and suggest next time, post on Discussions or Arduino Forum to get help.

Good Luck,

Thank you.