From 982aa24675bcf6bb3776057c2fc9e88e46a513f5 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Tue, 18 Feb 2025 14:32:53 +0100 Subject: [PATCH] fix: update add_timer method to use unsigned char for lamp_name buffer --- esphome/components/dynamic_lamp/dynamic_lamp.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/esphome/components/dynamic_lamp/dynamic_lamp.cpp b/esphome/components/dynamic_lamp/dynamic_lamp.cpp index 64a09e76e7..789eafc890 100644 --- a/esphome/components/dynamic_lamp/dynamic_lamp.cpp +++ b/esphome/components/dynamic_lamp/dynamic_lamp.cpp @@ -231,8 +231,8 @@ bool DynamicLampComponent::add_timer(std::string lamp_name, bool timer_active, u 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(); - char lamp_name_buffer[32]; - strncpy(lamp_name_buffer, lamp_name.c_str(), 32); + unsigned char lamp_name_buffer[32]; + strncpy(reinterpret_cast(lamp_name_buffer), lamp_name.c_str(), 32); DynamicLampTimer new_timer; new_timer.lamp_name = lamp_name_buffer; new_timer.active = timer_active; @@ -257,7 +257,6 @@ bool DynamicLampComponent::add_timer(std::string lamp_name, bool timer_active, u new_timer.lamp_name, 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(sizeof(new_timer))); - //this->fram_->write(2048, reinterpret_cast(lamp_name_buffer), 32); this->fram_->write((2048), timer_as_bytes, 56); return true; }