Fix: Incorporate unique serial number in preference's hash for multiple Sensirion sensors (#5479)

This commit is contained in:
kahrendt
2023-10-25 15:23:55 -04:00
committed by GitHub
parent fdef6c6d46
commit 258b0fbff3
3 changed files with 12 additions and 6 deletions
+3 -2
View File
@@ -61,9 +61,10 @@ void SGP4xComponent::setup() {
ESP_LOGD(TAG, "Product version: 0x%0X", uint16_t(this->featureset_ & 0x1FF));
if (this->store_baseline_) {
// Hash with compilation time
// Hash with compilation time and serial number
// This ensures the baseline storage is cleared after OTA
uint32_t hash = fnv1_hash(App.get_compilation_time());
// Serial numbers are unique to each sensor, so mulitple sensors can be used without conflict
uint32_t hash = fnv1_hash(App.get_compilation_time() + std::to_string(this->serial_number_));
this->pref_ = global_preferences->make_preference<SGP4xBaselines>(hash, true);
if (this->pref_.load(&this->voc_baselines_storage_)) {