Reduce code size for fingerprint

This commit is contained in:
Stephan Hadinger 2020-10-18 20:06:27 +02:00
parent 74c519a60d
commit b525e5c720
3 changed files with 8 additions and 15 deletions

View File

@ -97,8 +97,8 @@
#define MQTT_USE true // [SetOption3] Select default MQTT use (false = Off, true = On)
#define MQTT_HOST "" // [MqttHost]
#define MQTT_FINGERPRINT1 "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" // [MqttFingerprint1] (auto-learn)
#define MQTT_FINGERPRINT2 "DA 39 A3 EE 5E 6B 4B 0D 32 55 BF EF 95 60 18 90 AF D8 07 09" // [MqttFingerprint2] (invalid)
#define MQTT_FINGERPRINT1 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 // [MqttFingerprint1] (auto-learn)
#define MQTT_FINGERPRINT2 0xDA,0x39,0xA3,0xEE,0x5E,0x6B,0x4B,0x0D,0x32,0x55,0xBF,0xEF,0x95,0x60,0x18,0x90,0xAF,0xD8,0x07,0x09 // [MqttFingerprint2] (invalid)
#define MQTT_PORT 1883 // [MqttPort] MQTT port (10123 on CloudMQTT)
#define MQTT_USER "DVES_USER" // [MqttUser] MQTT user
#define MQTT_PASS "DVES_PASS" // [MqttPassword] MQTT password

View File

@ -874,17 +874,10 @@ void SettingsDefaultSet2(void)
SettingsUpdateText(SET_STATE_TXT2, MQTT_STATUS_ON);
SettingsUpdateText(SET_STATE_TXT3, MQTT_CMND_TOGGLE);
SettingsUpdateText(SET_STATE_TXT4, MQTT_CMND_HOLD);
char fingerprint[64];
strncpy_P(fingerprint, PSTR(MQTT_FINGERPRINT1), sizeof(fingerprint));
char *p = fingerprint;
for (uint32_t i = 0; i < 20; i++) {
Settings.mqtt_fingerprint[0][i] = strtol(p, &p, 16);
}
strncpy_P(fingerprint, PSTR(MQTT_FINGERPRINT2), sizeof(fingerprint));
p = fingerprint;
for (uint32_t i = 0; i < 20; i++) {
Settings.mqtt_fingerprint[1][i] = strtol(p, &p, 16);
}
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));
Settings.tele_period = TELE_PERIOD;
Settings.mqttlog_level = MQTT_LOG_LEVEL;

View File

@ -112,10 +112,10 @@ String EthernetMacAddress(void);
#ifndef MQTT_FINGERPRINT1
// Set an all-zeros default fingerprint to activate auto-learning on first connection (AWS IoT)
#define MQTT_FINGERPRINT1 "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
#define MQTT_FINGERPRINT1 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 // [MqttFingerprint1] (auto-learn)
#endif
#ifndef MQTT_FINGERPRINT2 // SHA1('')
#define MQTT_FINGERPRINT2 "DA 39 A3 EE 5E 6B 4B 0D 32 55 BF EF 95 60 18 90 AF D8 07 09"
#define MQTT_FINGERPRINT2 0xDA,0x39,0xA3,0xEE,0x5E,0x6B,0x4B,0x0D,0x32,0x55,0xBF,0xEF,0x95,0x60,0x18,0x90,0xAF,0xD8,0x07,0x09 // [MqttFingerprint2] (invalid)
#endif
#ifndef WS2812_LEDS