tuanpmt / esp_mqtt

MQTT client library for ESP8266
http://tuanpm.net/post/esp_mqtt/
MIT License
1.15k stars 401 forks source link

Documentation mqtt client id #132

Closed hannes-angst closed 7 years ago

hannes-angst commented 7 years ago

== This is just a reminder to update documentation ==

To login to a mqtt server, you provide a client id, user name, and password.

The client id needs to be unique. If not, clients using the same client id will login in, log out, forever.

I learned that the hard way ;(

Tested: mosquitto mqtt server.

 char *clientId = (char*) os_zalloc(64);
 os_sprintf(clientId, "%s%08X", MQTT_CLIENT_ID, system_get_chip_id());
 MQTT_InitClient(&mqttClient, clientId, user, pass, MQTT_KEEPALIVE, MQTT_CLEAN_SESSION);
 os_free(clientId);