mirror of
https://github.com/esphome/esphome.git
synced 2025-09-08 14:22:21 +01:00
fix: update lamp_name_cstr handling in add_timer method to use buffer
This commit is contained in:
@@ -230,7 +230,9 @@ std::array<bool, 16> DynamicLampComponent::get_lamp_outputs_by_name(std::string
|
||||
bool DynamicLampComponent::add_timer(std::string lamp_name, bool timer_active, uint8_t mode, uint8_t hour,
|
||||
uint8_t minute, bool monday, bool tuesday, bool wednesday, bool thursday,
|
||||
bool friday, bool saturday, bool sunday) {
|
||||
unsigned char* lamp_name_cstr = lamp_name.c_str();
|
||||
//unsigned char* lamp_name_cstr = lamp_name.c_str();
|
||||
unsigned char lamp_name_buffer[32];
|
||||
strncopy(lamp_name_buffer, lamp_name.data(), 32);
|
||||
DynamicLampTimer new_timer;
|
||||
new_timer.active = timer_active;
|
||||
new_timer.mode = mode;
|
||||
@@ -253,7 +255,7 @@ bool DynamicLampComponent::add_timer(std::string lamp_name, bool timer_active, u
|
||||
lamp_name.c_str(), new_timer.active, new_timer.mode, new_timer.hour, new_timer.minute, new_timer.monday, new_timer.tuesday, new_timer.wednesday,
|
||||
new_timer.thursday, new_timer.friday, new_timer.saturday, new_timer.sunday);
|
||||
ESP_LOGV(TAG, "Size of struct is %" PRIu8 "", static_cast<uint8_t>(sizeof(new_timer)));
|
||||
this->fram_->write(2048, lamp_name_cstr, 32);
|
||||
this->fram_->write(2048, &lamp_name_buffer, 32);
|
||||
this->fram_->writeObject((2048 + 32), new_timer);
|
||||
return true;
|
||||
}
|
||||
@@ -280,4 +282,4 @@ void DynamicLampComponent::restore_lamp_values_(uint8_t lamp_number) {
|
||||
}
|
||||
|
||||
} // namespace dynamic_lamp
|
||||
} // namespace esphome
|
||||
}
|
Reference in New Issue
Block a user