diff --git a/tasmota/settings.ino b/tasmota/settings.ino index 18a6f25e8..a40f84aee 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -718,6 +718,10 @@ void SettingsDefaultSet1(void) // Settings.cfg_crc = 0; } +// default Fingerprints in PROGMEM +const uint8_t default_fingerprint1[] PROGMEM = { MQTT_FINGERPRINT1 }; +const uint8_t default_fingerprint2[] PROGMEM = { MQTT_FINGERPRINT2 }; + void SettingsDefaultSet2(void) { memset((char*)&Settings +16, 0x00, sizeof(Settings) -16); @@ -874,10 +878,8 @@ void SettingsDefaultSet2(void) SettingsUpdateText(SET_STATE_TXT2, MQTT_STATUS_ON); SettingsUpdateText(SET_STATE_TXT3, MQTT_CMND_TOGGLE); SettingsUpdateText(SET_STATE_TXT4, MQTT_CMND_HOLD); - static const uint8_t fingerprint1[] PROGMEM = { MQTT_FINGERPRINT1 }; - static const uint8_t fingerprint2[] PROGMEM = { MQTT_FINGERPRINT2 }; - memcpy_P(Settings.mqtt_fingerprint[0], fingerprint1, sizeof(fingerprint1)); - memcpy_P(Settings.mqtt_fingerprint[1], fingerprint2, sizeof(fingerprint2)); + memcpy_P(Settings.mqtt_fingerprint[0], default_fingerprint1, sizeof(default_fingerprint1)); + memcpy_P(Settings.mqtt_fingerprint[1], default_fingerprint2, sizeof(default_fingerprint2)); Settings.tele_period = TELE_PERIOD; Settings.mqttlog_level = MQTT_LOG_LEVEL; diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index 0f41cc2d8..b62f2d12e 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -801,10 +801,14 @@ void CmndMqttFingerprint(void) if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 2)) { char fingerprint[60]; if ((XdrvMailbox.data_len > 0) && (XdrvMailbox.data_len < sizeof(fingerprint))) { - strlcpy(fingerprint, (SC_CLEAR == Shortcut()) ? "" : (SC_DEFAULT == Shortcut()) ? (1 == XdrvMailbox.index) ? MQTT_FINGERPRINT1 : MQTT_FINGERPRINT2 : XdrvMailbox.data, sizeof(fingerprint)); - char *p = fingerprint; - for (uint32_t i = 0; i < 20; i++) { - Settings.mqtt_fingerprint[XdrvMailbox.index -1][i] = strtol(p, &p, 16); + if (SC_DEFAULT == Shortcut()) { + memcpy_P(Settings.mqtt_fingerprint[XdrvMailbox.index -1], (1 == XdrvMailbox.index) ? default_fingerprint1 : default_fingerprint2, sizeof(default_fingerprint1)); + } else { + strlcpy(fingerprint, (SC_CLEAR == Shortcut()) ? "" : XdrvMailbox.data, sizeof(fingerprint)); + char *p = fingerprint; + for (uint32_t i = 0; i < 20; i++) { + Settings.mqtt_fingerprint[XdrvMailbox.index -1][i] = strtol(p, &p, 16); + } } restart_flag = 2; }