diff --git a/esphome/components/api/api_frame_helper_plaintext.cpp b/esphome/components/api/api_frame_helper_plaintext.cpp index fdaacbd94e..59daf49bfc 100644 --- a/esphome/components/api/api_frame_helper_plaintext.cpp +++ b/esphome/components/api/api_frame_helper_plaintext.cpp @@ -10,6 +10,10 @@ #include #include +#ifdef USE_ESP8266 +#include +#endif + namespace esphome::api { static const char *const TAG = "api.plaintext"; @@ -197,9 +201,17 @@ APIError APIPlaintextFrameHelper::read_packet(ReadPacketBuffer *buffer) { // We must send at least 3 bytes to be read, so we add // a message after the indicator byte to ensures its long // enough and can aid in debugging. - const char msg[] = "\x00" - "Bad indicator byte"; +#ifdef USE_ESP8266 + static const char msg_progmem[] PROGMEM = "\x00" + "Bad indicator byte"; + char msg[19]; + memcpy_P(msg, msg_progmem, 19); iov[0].iov_base = (void *) msg; +#else + static const char msg[] = "\x00" + "Bad indicator byte"; + iov[0].iov_base = (void *) msg; +#endif iov[0].iov_len = 19; this->write_raw_(iov, 1, 19); }