This commit is contained in:
J. Nick Koston 2025-07-21 19:39:23 -10:00
parent 97525cfe87
commit 72fd984d4b
No known key found for this signature in database
3 changed files with 142 additions and 623 deletions

View File

@ -1377,7 +1377,6 @@ void APIConnection::complete_authentication_() {
}
bool APIConnection::send_hello_response(const HelloRequest &msg) {
// Process the request first
this->client_info_.name = msg.client_info;
this->client_info_.peername = this->helper_->getpeername();
this->client_api_version_major_ = msg.api_version_major;

File diff suppressed because it is too large Load Diff

View File

@ -575,13 +575,7 @@ class StringType(TypeInfo):
# For SOURCE_SERVER, always use StringRef
if not self._needs_decode:
return (
f"if (!this->{self.field_name}_ref_.empty()) {{"
f' out.append("\'").append(this->{self.field_name}_ref_.c_str()).append("\'");'
f"}} else {{"
f' out.append("\'").append("").append("\'");'
f"}}"
)
return f"append_quoted_string(out, this->{self.field_name}_ref_);"
# For SOURCE_BOTH, check if StringRef is set (sending) or use string (received)
return (
@ -1868,6 +1862,15 @@ namespace api {
namespace esphome {
namespace api {
// Helper function to append a quoted string, handling empty StringRef
static inline void append_quoted_string(std::string &out, const StringRef &ref) {
out.append("'");
if (!ref.empty()) {
out.append(ref.c_str());
}
out.append("'");
}
"""
content += "namespace enums {\n\n"