From a7d1686cfd124ec8bce1b7789879fe280334a022 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 8 Feb 2026 09:14:15 -0600 Subject: [PATCH] empty messages --- esphome/components/api/api_pb2_service.cpp | 34 ++++++++-------------- esphome/components/api/api_pb2_service.h | 1 + script/api_protobuf/api_protobuf.py | 7 +++-- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/esphome/components/api/api_pb2_service.cpp b/esphome/components/api/api_pb2_service.cpp index fe158273d8..c9df562241 100644 --- a/esphome/components/api/api_pb2_service.cpp +++ b/esphome/components/api/api_pb2_service.cpp @@ -15,6 +15,7 @@ void APIServerConnectionBase::log_receive_message_(const LogString *name, const DumpBuffer dump_buf; ESP_LOGVV(TAG, "%s: %s", LOG_STR_ARG(name), msg.dump_to(dump_buf)); } +void APIServerConnectionBase::log_receive_message_(const LogString *name) { ESP_LOGVV(TAG, "%s", LOG_STR_ARG(name)); } #endif void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type, const uint8_t *msg_data) { @@ -30,56 +31,49 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type, } case DisconnectRequest::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - DisconnectRequest msg; - this->log_receive_message_(LOG_STR("on_disconnect_request"), msg); + this->log_receive_message_(LOG_STR("on_disconnect_request")); #endif this->on_disconnect_request(); break; } case DisconnectResponse::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - DisconnectResponse msg; - this->log_receive_message_(LOG_STR("on_disconnect_response"), msg); + this->log_receive_message_(LOG_STR("on_disconnect_response")); #endif this->on_disconnect_response(); break; } case PingRequest::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - PingRequest msg; - this->log_receive_message_(LOG_STR("on_ping_request"), msg); + this->log_receive_message_(LOG_STR("on_ping_request")); #endif this->on_ping_request(); break; } case PingResponse::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - PingResponse msg; - this->log_receive_message_(LOG_STR("on_ping_response"), msg); + this->log_receive_message_(LOG_STR("on_ping_response")); #endif this->on_ping_response(); break; } case DeviceInfoRequest::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - DeviceInfoRequest msg; - this->log_receive_message_(LOG_STR("on_device_info_request"), msg); + this->log_receive_message_(LOG_STR("on_device_info_request")); #endif this->on_device_info_request(); break; } case ListEntitiesRequest::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - ListEntitiesRequest msg; - this->log_receive_message_(LOG_STR("on_list_entities_request"), msg); + this->log_receive_message_(LOG_STR("on_list_entities_request")); #endif this->on_list_entities_request(); break; } case SubscribeStatesRequest::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - SubscribeStatesRequest msg; - this->log_receive_message_(LOG_STR("on_subscribe_states_request"), msg); + this->log_receive_message_(LOG_STR("on_subscribe_states_request")); #endif this->on_subscribe_states_request(); break; @@ -140,8 +134,7 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type, #ifdef USE_API_HOMEASSISTANT_SERVICES case SubscribeHomeassistantServicesRequest::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - SubscribeHomeassistantServicesRequest msg; - this->log_receive_message_(LOG_STR("on_subscribe_homeassistant_services_request"), msg); + this->log_receive_message_(LOG_STR("on_subscribe_homeassistant_services_request")); #endif this->on_subscribe_homeassistant_services_request(); break; @@ -159,8 +152,7 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type, #ifdef USE_API_HOMEASSISTANT_STATES case SubscribeHomeAssistantStatesRequest::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - SubscribeHomeAssistantStatesRequest msg; - this->log_receive_message_(LOG_STR("on_subscribe_home_assistant_states_request"), msg); + this->log_receive_message_(LOG_STR("on_subscribe_home_assistant_states_request")); #endif this->on_subscribe_home_assistant_states_request(); break; @@ -367,8 +359,7 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type, #ifdef USE_BLUETOOTH_PROXY case SubscribeBluetoothConnectionsFreeRequest::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - SubscribeBluetoothConnectionsFreeRequest msg; - this->log_receive_message_(LOG_STR("on_subscribe_bluetooth_connections_free_request"), msg); + this->log_receive_message_(LOG_STR("on_subscribe_bluetooth_connections_free_request")); #endif this->on_subscribe_bluetooth_connections_free_request(); break; @@ -377,8 +368,7 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type, #ifdef USE_BLUETOOTH_PROXY case UnsubscribeBluetoothLEAdvertisementsRequest::MESSAGE_TYPE: { #ifdef HAS_PROTO_MESSAGE_DUMP - UnsubscribeBluetoothLEAdvertisementsRequest msg; - this->log_receive_message_(LOG_STR("on_unsubscribe_bluetooth_le_advertisements_request"), msg); + this->log_receive_message_(LOG_STR("on_unsubscribe_bluetooth_le_advertisements_request")); #endif this->on_unsubscribe_bluetooth_le_advertisements_request(); break; diff --git a/esphome/components/api/api_pb2_service.h b/esphome/components/api/api_pb2_service.h index 80622ff6bb..b8c9e4da6f 100644 --- a/esphome/components/api/api_pb2_service.h +++ b/esphome/components/api/api_pb2_service.h @@ -14,6 +14,7 @@ class APIServerConnectionBase : public ProtoService { protected: void log_send_message_(const char *name, const char *dump); void log_receive_message_(const LogString *name, const ProtoMessage &msg); + void log_receive_message_(const LogString *name); public: #endif diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index c1eae7f5b7..55e8c97582 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -2530,8 +2530,7 @@ def build_service_message_type( case = "" if log: case += "#ifdef HAS_PROTO_MESSAGE_DUMP\n" - case += f"{mt.name} msg;\n" - case += f'this->log_receive_message_(LOG_STR("{func}"), msg);\n' + case += f'this->log_receive_message_(LOG_STR("{func}"));\n' case += "#endif\n" case += f"this->{func}();\n" case += "break;" @@ -2851,6 +2850,7 @@ static const char *const TAG = "api.service"; hpp += ( " void log_receive_message_(const LogString *name, const ProtoMessage &msg);\n" ) + hpp += " void log_receive_message_(const LogString *name);\n" hpp += " public:\n" hpp += "#endif\n\n" @@ -2874,6 +2874,9 @@ static const char *const TAG = "api.service"; cpp += " DumpBuffer dump_buf;\n" cpp += ' ESP_LOGVV(TAG, "%s: %s", LOG_STR_ARG(name), msg.dump_to(dump_buf));\n' cpp += "}\n" + cpp += f"void {class_name}::log_receive_message_(const LogString *name) {{\n" + cpp += ' ESP_LOGVV(TAG, "%s", LOG_STR_ARG(name));\n' + cpp += "}\n" cpp += "#endif\n\n" for mt in file.message_type: