This commit is contained in:
J. Nick Koston
2026-01-02 22:19:01 -10:00
parent 979b96f7d4
commit fb255d7e7c
3 changed files with 22 additions and 12 deletions

View File

@@ -747,7 +747,10 @@ void HelloResponse::dump_to(std::string &out) const {
dump_field(out, "name", this->name);
}
#ifdef USE_API_PASSWORD
void AuthenticationRequest::dump_to(std::string &out) const { dump_field(out, "password", this->password); }
void AuthenticationRequest::dump_to(std::string &out) const {
MessageDumpHelper helper(out, "AuthenticationRequest");
dump_field(out, "password", this->password);
}
void AuthenticationResponse::dump_to(std::string &out) const {
MessageDumpHelper helper(out, "AuthenticationResponse");
dump_field(out, "invalid_password", this->invalid_password);
@@ -1148,7 +1151,10 @@ void NoiseEncryptionSetKeyRequest::dump_to(std::string &out) const {
out.append(format_hex_pretty(this->key, this->key_len));
out.append("\n");
}
void NoiseEncryptionSetKeyResponse::dump_to(std::string &out) const { dump_field(out, "success", this->success); }
void NoiseEncryptionSetKeyResponse::dump_to(std::string &out) const {
MessageDumpHelper helper(out, "NoiseEncryptionSetKeyResponse");
dump_field(out, "success", this->success);
}
#endif
#ifdef USE_API_HOMEASSISTANT_SERVICES
void SubscribeHomeassistantServicesRequest::dump_to(std::string &out) const {
@@ -1738,7 +1744,10 @@ void BluetoothDeviceConnectionResponse::dump_to(std::string &out) const {
dump_field(out, "mtu", this->mtu);
dump_field(out, "error", this->error);
}
void BluetoothGATTGetServicesRequest::dump_to(std::string &out) const { dump_field(out, "address", this->address); }
void BluetoothGATTGetServicesRequest::dump_to(std::string &out) const {
MessageDumpHelper helper(out, "BluetoothGATTGetServicesRequest");
dump_field(out, "address", this->address);
}
void BluetoothGATTDescriptor::dump_to(std::string &out) const {
MessageDumpHelper helper(out, "BluetoothGATTDescriptor");
for (const auto &it : this->uuid) {
@@ -1959,7 +1968,10 @@ void VoiceAssistantAnnounceRequest::dump_to(std::string &out) const {
dump_field(out, "preannounce_media_id", this->preannounce_media_id);
dump_field(out, "start_conversation", this->start_conversation);
}
void VoiceAssistantAnnounceFinished::dump_to(std::string &out) const { dump_field(out, "success", this->success); }
void VoiceAssistantAnnounceFinished::dump_to(std::string &out) const {
MessageDumpHelper helper(out, "VoiceAssistantAnnounceFinished");
dump_field(out, "success", this->success);
}
void VoiceAssistantWakeWord::dump_to(std::string &out) const {
MessageDumpHelper helper(out, "VoiceAssistantWakeWord");
dump_field(out, "id", this->id);

View File

@@ -220,7 +220,7 @@ class CustomAPIDevice {
for (auto &it : data) {
auto &kv = resp.data.emplace_back();
kv.key = StringRef(it.first);
kv.value = StringRef(it.second);
kv.value = it.second; // value is std::string (no_zero_copy), assign directly
}
global_api_server->send_homeassistant_action(resp);
}
@@ -263,7 +263,7 @@ class CustomAPIDevice {
for (auto &it : data) {
auto &kv = resp.data.emplace_back();
kv.key = StringRef(it.first);
kv.value = StringRef(it.second);
kv.value = it.second; // value is std::string (no_zero_copy), assign directly
}
global_api_server->send_homeassistant_action(resp);
}

View File

@@ -2151,12 +2151,10 @@ def build_message_type(
# dump_to implementation will go in dump_cpp
dump_impl = f"void {desc.name}::dump_to(std::string &out) const {{"
if dump:
if len(dump) == 1 and len(dump[0]) + len(dump_impl) + 3 < 120:
dump_impl += f" {dump[0]} "
else:
dump_impl += "\n"
dump_impl += f' MessageDumpHelper helper(out, "{desc.name}");\n'
dump_impl += indent("\n".join(dump)) + "\n"
# Always use MessageDumpHelper for consistent output formatting
dump_impl += "\n"
dump_impl += f' MessageDumpHelper helper(out, "{desc.name}");\n'
dump_impl += indent("\n".join(dump)) + "\n"
else:
o2 = f'out.append("{desc.name} {{}}");'
if len(dump_impl) + len(o2) + 3 < 120: