mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-03 03:01:40 +02:00
fix MqTT client ID
This commit is contained in:
parent
a0879cfcbe
commit
b6a41506b6
2 changed files with 4 additions and 4 deletions
|
@ -183,7 +183,7 @@ void app::tickNtpUpdate(void) {
|
|||
bool isOK = mWifi.getNtpTime();
|
||||
if (isOK || mTimestamp != 0) {
|
||||
if (mMqttReconnect && mMqttEnabled) {
|
||||
mMqtt.tickerMinute();
|
||||
mMqtt.tickerSecond();
|
||||
everySec(std::bind(&PubMqttType::tickerSecond, &mMqtt), "mqttS");
|
||||
everyMin(std::bind(&PubMqttType::tickerMinute, &mMqtt), "mqttM");
|
||||
}
|
||||
|
|
|
@ -59,9 +59,8 @@ class PubMqtt {
|
|||
|
||||
if((strlen(mCfgMqtt->user) > 0) && (strlen(mCfgMqtt->pwd) > 0))
|
||||
mClient.setCredentials(mCfgMqtt->user, mCfgMqtt->pwd);
|
||||
char clientId[64];
|
||||
snprintf(clientId, 64, "%s_%s-%s-%s", mDevName, WiFi.macAddress().substring(9,11).c_str(), WiFi.macAddress().substring(12,14).c_str(), WiFi.macAddress().substring(15,17).c_str());
|
||||
mClient.setClientId(clientId);
|
||||
snprintf(mClientId, 24, "%s-%s%s%s", mDevName, WiFi.macAddress().substring(9,11).c_str(), WiFi.macAddress().substring(12,14).c_str(), WiFi.macAddress().substring(15,17).c_str());
|
||||
mClient.setClientId(mClientId);
|
||||
mClient.setServer(mCfgMqtt->broker, mCfgMqtt->port);
|
||||
mClient.setWill(mLwtTopic, QOS_0, true, mqttStr[MQTT_STR_LWT_NOT_CONN]);
|
||||
mClient.onConnect(std::bind(&PubMqtt::onConnect, this, std::placeholders::_1));
|
||||
|
@ -598,6 +597,7 @@ class PubMqtt {
|
|||
// last will topic and payload must be available trough lifetime of 'espMqttClient'
|
||||
char mLwtTopic[MQTT_TOPIC_LEN+5];
|
||||
const char *mDevName, *mVersion;
|
||||
char mClientId[24]; // number of chars is limited to 23 up to v3.1 of MQTT
|
||||
};
|
||||
|
||||
#endif /*__PUB_MQTT_H__*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue