diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 4d6cb27aa..0071e38d1 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,4 +1,7 @@ -/* 6.5.0.10 20190513 +/* 6.5.0.11 20190517 + * Add command SetOption64 0/1 to switch between "-" or "_" as sensor index separator impacting DS18X20, DHT, BMP and SHT3X sensor names (#5689) + * + * 6.5.0.10 20190513 * Enable ADC0 by default in my_user_config.h (#5671) * Add user configurable ADC0 to Module and Template configuration compatible with current FLAG options (#5671) * Add support for Shelly 1PM Template {"NAME":"Shelly 1PM","GPIO":[56,0,0,0,82,134,0,0,0,0,0,21,0],"FLAG":2,"BASE":18} (#5716) diff --git a/sonoff/settings.h b/sonoff/settings.h index 4c56fe62b..c08c3e041 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -77,7 +77,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t button_switch_force_local : 1;// bit 11 (v6.3.0.16) - SetOption61 - Force local operation when button/switch topic is set uint32_t no_hold_retain : 1; // bit 12 (v6.4.1.19) - SetOption62 - Don't use retain flag on HOLD messages uint32_t no_power_feedback : 1; // bit 13 (v6.5.0.9) - SetOption63 - Don't scan relay power state at restart - uint32_t spare14 : 1; + uint32_t use_underscore : 1; // bit 14 (v6.5.0.12) - SetOption64 - Enable "_" instead of "-" as sensor index separator uint32_t spare15 : 1; uint32_t spare16 : 1; uint32_t spare17 : 1; diff --git a/sonoff/sonoff_version.h b/sonoff/sonoff_version.h index 4dea3a792..ce4413124 100644 --- a/sonoff/sonoff_version.h +++ b/sonoff/sonoff_version.h @@ -20,6 +20,6 @@ #ifndef _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_ -const uint32_t VERSION = 0x0605000A; +const uint32_t VERSION = 0x0605000B; #endif // _SONOFF_VERSION_H_ diff --git a/sonoff/support.ino b/sonoff/support.ino index 953297dbf..317d25065 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -437,6 +437,21 @@ char* NoAlNumToUnderscore(char* dest, const char* source) return dest; } +char IndexSeparator() +{ +/* + // 20 bytes more costly !?! + const char separators[] = { "-_" }; + + return separators[Settings.flag3.use_underscore]; +*/ + if (Settings.flag3.use_underscore) { + return '_'; + } else { + return '-'; + } +} + void SetShortcut(char* str, uint8_t action) { if ('\0' != str[0]) { // There must be at least one character in the buffer diff --git a/sonoff/xsns_05_ds18x20.ino b/sonoff/xsns_05_ds18x20.ino index 7a67f80a9..cee07f1d7 100644 --- a/sonoff/xsns_05_ds18x20.ino +++ b/sonoff/xsns_05_ds18x20.ino @@ -380,7 +380,7 @@ void Ds18x20Name(uint8_t sensor) } GetTextIndexed(ds18x20_types, sizeof(ds18x20_types), index, kDs18x20Types); if (ds18x20_sensors > 1) { - snprintf_P(ds18x20_types, sizeof(ds18x20_types), PSTR("%s-%d"), ds18x20_types, sensor +1); + snprintf_P(ds18x20_types, sizeof(ds18x20_types), PSTR("%s%c%d"), ds18x20_types, IndexSeparator(), sensor +1); } } diff --git a/sonoff/xsns_05_ds18x20_legacy.ino b/sonoff/xsns_05_ds18x20_legacy.ino index d92843393..b31085e8b 100644 --- a/sonoff/xsns_05_ds18x20_legacy.ino +++ b/sonoff/xsns_05_ds18x20_legacy.ino @@ -197,7 +197,7 @@ void Ds18x20Show(bool json) #endif // USE_KNX #ifdef USE_WEBSERVER } else { - snprintf_P(stemp, sizeof(stemp), PSTR("%s-%d"), ds18x20_types, i +1); + snprintf_P(stemp, sizeof(stemp), PSTR("%s%c%d"), ds18x20_types, IndexSeparator(), i +1); WSContentSend_PD(HTTP_SNS_TEMP, stemp, temperature, TempUnit()); #endif // USE_WEBSERVER } diff --git a/sonoff/xsns_06_dht.ino b/sonoff/xsns_06_dht.ino index aecdb18f9..7615dbc6c 100644 --- a/sonoff/xsns_06_dht.ino +++ b/sonoff/xsns_06_dht.ino @@ -187,7 +187,7 @@ void DhtInit(void) Dht[i].lastresult = 0; GetTextIndexed(Dht[i].stype, sizeof(Dht[i].stype), Dht[i].type, kSensorNames); if (dht_sensors > 1) { - snprintf_P(Dht[i].stype, sizeof(Dht[i].stype), PSTR("%s-%02d"), Dht[i].stype, Dht[i].pin); + snprintf_P(Dht[i].stype, sizeof(Dht[i].stype), PSTR("%s%c%02d"), Dht[i].stype, IndexSeparator(), Dht[i].pin); } } } diff --git a/sonoff/xsns_09_bmp.ino b/sonoff/xsns_09_bmp.ino index 82b681cc4..12252e3b6 100755 --- a/sonoff/xsns_09_bmp.ino +++ b/sonoff/xsns_09_bmp.ino @@ -542,7 +542,7 @@ void BmpShow(bool json) char name[10]; strlcpy(name, bmp_sensors[bmp_idx].bmp_name, sizeof(name)); if (bmp_count > 1) { - snprintf_P(name, sizeof(name), PSTR("%s-%02X"), name, bmp_sensors[bmp_idx].bmp_address); // BMXXXX-XX + snprintf_P(name, sizeof(name), PSTR("%s%c%02X"), name, IndexSeparator(), bmp_sensors[bmp_idx].bmp_address); // BMXXXX-XX } char temperature[33]; diff --git a/sonoff/xsns_14_sht3x.ino b/sonoff/xsns_14_sht3x.ino index 7ead33fcf..17ac313ee 100755 --- a/sonoff/xsns_14_sht3x.ino +++ b/sonoff/xsns_14_sht3x.ino @@ -104,7 +104,7 @@ void Sht3xShow(bool json) dtostrfd(t, Settings.flag2.temperature_resolution, temperature); char humidity[33]; dtostrfd(h, Settings.flag2.humidity_resolution, humidity); - snprintf_P(types, sizeof(types), PSTR("%s-0x%02X"), sht3x_sensors[i].types, sht3x_sensors[i].address); // "SHT3X-0xXX" + snprintf_P(types, sizeof(types), PSTR("%s%c0x%02X"), sht3x_sensors[i].types, IndexSeparator(), sht3x_sensors[i].address); // "SHT3X-0xXX" if (json) { ResponseAppend_P(JSON_SNS_TEMPHUM, types, temperature, humidity);