1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00
This commit is contained in:
J. Nick Koston
2026-01-12 17:00:26 -10:00
parent b5f6a6e24d
commit 5e911e20bc
8 changed files with 593 additions and 377 deletions

View File

@@ -305,7 +305,8 @@ uint16_t APIConnection::encode_message_to_buffer(ProtoMessage &msg, uint8_t mess
#ifdef HAS_PROTO_MESSAGE_DUMP
// If in log-only mode, just log and return
if (conn->flags_.log_only_mode) {
conn->log_send_message_(msg.message_name(), msg.dump());
DumpBuffer dump_buf;
conn->log_send_message_(msg.message_name(), msg.dump_to(dump_buf));
return 1; // Return non-zero to indicate "success" for logging
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
HelloRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_hello_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_hello_request: %s", msg.dump_to(dump_buf));
#endif
this->on_hello_request(msg);
break;
@@ -28,7 +29,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
DisconnectRequest msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_disconnect_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_disconnect_request: %s", msg.dump_to(dump_buf));
#endif
this->on_disconnect_request(msg);
break;
@@ -37,7 +39,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
DisconnectResponse msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_disconnect_response: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_disconnect_response: %s", msg.dump_to(dump_buf));
#endif
this->on_disconnect_response(msg);
break;
@@ -46,7 +49,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
PingRequest msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_ping_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_ping_request: %s", msg.dump_to(dump_buf));
#endif
this->on_ping_request(msg);
break;
@@ -55,7 +59,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
PingResponse msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_ping_response: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_ping_response: %s", msg.dump_to(dump_buf));
#endif
this->on_ping_response(msg);
break;
@@ -64,7 +69,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
DeviceInfoRequest msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_device_info_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_device_info_request: %s", msg.dump_to(dump_buf));
#endif
this->on_device_info_request(msg);
break;
@@ -73,7 +79,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
ListEntitiesRequest msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_list_entities_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_list_entities_request: %s", msg.dump_to(dump_buf));
#endif
this->on_list_entities_request(msg);
break;
@@ -82,7 +89,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SubscribeStatesRequest msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_subscribe_states_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_subscribe_states_request: %s", msg.dump_to(dump_buf));
#endif
this->on_subscribe_states_request(msg);
break;
@@ -91,7 +99,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SubscribeLogsRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_subscribe_logs_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_subscribe_logs_request: %s", msg.dump_to(dump_buf));
#endif
this->on_subscribe_logs_request(msg);
break;
@@ -101,7 +110,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
CoverCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_cover_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_cover_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_cover_command_request(msg);
break;
@@ -112,7 +122,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
FanCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_fan_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_fan_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_fan_command_request(msg);
break;
@@ -123,7 +134,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
LightCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_light_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_light_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_light_command_request(msg);
break;
@@ -134,7 +146,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SwitchCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_switch_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_switch_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_switch_command_request(msg);
break;
@@ -145,7 +158,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SubscribeHomeassistantServicesRequest msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_subscribe_homeassistant_services_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_subscribe_homeassistant_services_request: %s", msg.dump_to(dump_buf));
#endif
this->on_subscribe_homeassistant_services_request(msg);
break;
@@ -155,7 +169,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
GetTimeResponse msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_get_time_response: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_get_time_response: %s", msg.dump_to(dump_buf));
#endif
this->on_get_time_response(msg);
break;
@@ -165,7 +180,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SubscribeHomeAssistantStatesRequest msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_subscribe_home_assistant_states_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_subscribe_home_assistant_states_request: %s", msg.dump_to(dump_buf));
#endif
this->on_subscribe_home_assistant_states_request(msg);
break;
@@ -176,7 +192,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
HomeAssistantStateResponse msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_home_assistant_state_response: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_home_assistant_state_response: %s", msg.dump_to(dump_buf));
#endif
this->on_home_assistant_state_response(msg);
break;
@@ -187,7 +204,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
ExecuteServiceRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_execute_service_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_execute_service_request: %s", msg.dump_to(dump_buf));
#endif
this->on_execute_service_request(msg);
break;
@@ -198,7 +216,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
CameraImageRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_camera_image_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_camera_image_request: %s", msg.dump_to(dump_buf));
#endif
this->on_camera_image_request(msg);
break;
@@ -209,7 +228,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
ClimateCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_climate_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_climate_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_climate_command_request(msg);
break;
@@ -220,7 +240,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
NumberCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_number_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_number_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_number_command_request(msg);
break;
@@ -231,7 +252,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SelectCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_select_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_select_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_select_command_request(msg);
break;
@@ -242,7 +264,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SirenCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_siren_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_siren_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_siren_command_request(msg);
break;
@@ -253,7 +276,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
LockCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_lock_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_lock_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_lock_command_request(msg);
break;
@@ -264,7 +288,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
ButtonCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_button_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_button_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_button_command_request(msg);
break;
@@ -275,7 +300,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
MediaPlayerCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_media_player_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_media_player_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_media_player_command_request(msg);
break;
@@ -286,7 +312,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SubscribeBluetoothLEAdvertisementsRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_subscribe_bluetooth_le_advertisements_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_subscribe_bluetooth_le_advertisements_request: %s", msg.dump_to(dump_buf));
#endif
this->on_subscribe_bluetooth_le_advertisements_request(msg);
break;
@@ -297,7 +324,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
BluetoothDeviceRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_bluetooth_device_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_bluetooth_device_request: %s", msg.dump_to(dump_buf));
#endif
this->on_bluetooth_device_request(msg);
break;
@@ -308,7 +336,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
BluetoothGATTGetServicesRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_bluetooth_gatt_get_services_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_bluetooth_gatt_get_services_request: %s", msg.dump_to(dump_buf));
#endif
this->on_bluetooth_gatt_get_services_request(msg);
break;
@@ -319,7 +348,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
BluetoothGATTReadRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_bluetooth_gatt_read_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_bluetooth_gatt_read_request: %s", msg.dump_to(dump_buf));
#endif
this->on_bluetooth_gatt_read_request(msg);
break;
@@ -330,7 +360,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
BluetoothGATTWriteRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_bluetooth_gatt_write_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_bluetooth_gatt_write_request: %s", msg.dump_to(dump_buf));
#endif
this->on_bluetooth_gatt_write_request(msg);
break;
@@ -341,7 +372,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
BluetoothGATTReadDescriptorRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_bluetooth_gatt_read_descriptor_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_bluetooth_gatt_read_descriptor_request: %s", msg.dump_to(dump_buf));
#endif
this->on_bluetooth_gatt_read_descriptor_request(msg);
break;
@@ -352,7 +384,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
BluetoothGATTWriteDescriptorRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_bluetooth_gatt_write_descriptor_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_bluetooth_gatt_write_descriptor_request: %s", msg.dump_to(dump_buf));
#endif
this->on_bluetooth_gatt_write_descriptor_request(msg);
break;
@@ -363,7 +396,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
BluetoothGATTNotifyRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_bluetooth_gatt_notify_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_bluetooth_gatt_notify_request: %s", msg.dump_to(dump_buf));
#endif
this->on_bluetooth_gatt_notify_request(msg);
break;
@@ -374,7 +408,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SubscribeBluetoothConnectionsFreeRequest msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_subscribe_bluetooth_connections_free_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_subscribe_bluetooth_connections_free_request: %s", msg.dump_to(dump_buf));
#endif
this->on_subscribe_bluetooth_connections_free_request(msg);
break;
@@ -385,7 +420,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
UnsubscribeBluetoothLEAdvertisementsRequest msg;
// Empty message: no decode needed
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_unsubscribe_bluetooth_le_advertisements_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_unsubscribe_bluetooth_le_advertisements_request: %s", msg.dump_to(dump_buf));
#endif
this->on_unsubscribe_bluetooth_le_advertisements_request(msg);
break;
@@ -396,7 +432,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
SubscribeVoiceAssistantRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_subscribe_voice_assistant_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_subscribe_voice_assistant_request: %s", msg.dump_to(dump_buf));
#endif
this->on_subscribe_voice_assistant_request(msg);
break;
@@ -407,7 +444,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
VoiceAssistantResponse msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_voice_assistant_response: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_voice_assistant_response: %s", msg.dump_to(dump_buf));
#endif
this->on_voice_assistant_response(msg);
break;
@@ -418,7 +456,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
VoiceAssistantEventResponse msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_voice_assistant_event_response: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_voice_assistant_event_response: %s", msg.dump_to(dump_buf));
#endif
this->on_voice_assistant_event_response(msg);
break;
@@ -429,7 +468,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
AlarmControlPanelCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_alarm_control_panel_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_alarm_control_panel_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_alarm_control_panel_command_request(msg);
break;
@@ -440,7 +480,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
TextCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_text_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_text_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_text_command_request(msg);
break;
@@ -451,7 +492,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
DateCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_date_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_date_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_date_command_request(msg);
break;
@@ -462,7 +504,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
TimeCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_time_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_time_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_time_command_request(msg);
break;
@@ -473,7 +516,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
VoiceAssistantAudio msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_voice_assistant_audio: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_voice_assistant_audio: %s", msg.dump_to(dump_buf));
#endif
this->on_voice_assistant_audio(msg);
break;
@@ -484,7 +528,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
ValveCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_valve_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_valve_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_valve_command_request(msg);
break;
@@ -495,7 +540,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
DateTimeCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_date_time_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_date_time_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_date_time_command_request(msg);
break;
@@ -506,7 +552,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
VoiceAssistantTimerEventResponse msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_voice_assistant_timer_event_response: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_voice_assistant_timer_event_response: %s", msg.dump_to(dump_buf));
#endif
this->on_voice_assistant_timer_event_response(msg);
break;
@@ -517,7 +564,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
UpdateCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_update_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_update_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_update_command_request(msg);
break;
@@ -528,7 +576,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
VoiceAssistantAnnounceRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_voice_assistant_announce_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_voice_assistant_announce_request: %s", msg.dump_to(dump_buf));
#endif
this->on_voice_assistant_announce_request(msg);
break;
@@ -539,7 +588,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
VoiceAssistantConfigurationRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_voice_assistant_configuration_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_voice_assistant_configuration_request: %s", msg.dump_to(dump_buf));
#endif
this->on_voice_assistant_configuration_request(msg);
break;
@@ -550,7 +600,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
VoiceAssistantSetConfiguration msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_voice_assistant_set_configuration: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_voice_assistant_set_configuration: %s", msg.dump_to(dump_buf));
#endif
this->on_voice_assistant_set_configuration(msg);
break;
@@ -561,7 +612,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
NoiseEncryptionSetKeyRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_noise_encryption_set_key_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_noise_encryption_set_key_request: %s", msg.dump_to(dump_buf));
#endif
this->on_noise_encryption_set_key_request(msg);
break;
@@ -572,7 +624,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
BluetoothScannerSetModeRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_bluetooth_scanner_set_mode_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_bluetooth_scanner_set_mode_request: %s", msg.dump_to(dump_buf));
#endif
this->on_bluetooth_scanner_set_mode_request(msg);
break;
@@ -583,7 +636,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
ZWaveProxyFrame msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_z_wave_proxy_frame: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_z_wave_proxy_frame: %s", msg.dump_to(dump_buf));
#endif
this->on_z_wave_proxy_frame(msg);
break;
@@ -594,7 +648,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
ZWaveProxyRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_z_wave_proxy_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_z_wave_proxy_request: %s", msg.dump_to(dump_buf));
#endif
this->on_z_wave_proxy_request(msg);
break;
@@ -605,7 +660,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
HomeassistantActionResponse msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_homeassistant_action_response: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_homeassistant_action_response: %s", msg.dump_to(dump_buf));
#endif
this->on_homeassistant_action_response(msg);
break;
@@ -616,7 +672,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
WaterHeaterCommandRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_water_heater_command_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_water_heater_command_request: %s", msg.dump_to(dump_buf));
#endif
this->on_water_heater_command_request(msg);
break;
@@ -627,7 +684,8 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
InfraredRFTransmitRawTimingsRequest msg;
msg.decode(msg_data, msg_size);
#ifdef HAS_PROTO_MESSAGE_DUMP
ESP_LOGVV(TAG, "on_infrared_rf_transmit_raw_timings_request: %s", msg.dump());
DumpBuffer dump_buf;
ESP_LOGVV(TAG, "on_infrared_rf_transmit_raw_timings_request: %s", msg.dump_to(dump_buf));
#endif
this->on_infrared_rf_transmit_raw_timings_request(msg);
break;

View File

@@ -19,7 +19,8 @@ class APIServerConnectionBase : public ProtoService {
bool send_message(const ProtoMessage &msg, uint8_t message_type) {
#ifdef HAS_PROTO_MESSAGE_DUMP
this->log_send_message_(msg.message_name(), msg.dump());
DumpBuffer dump_buf;
this->log_send_message_(msg.message_name(), msg.dump_to(dump_buf));
#endif
return this->send_message_(msg, message_type);
}

View File

@@ -139,13 +139,4 @@ void ProtoDecodableMessage::decode(const uint8_t *buffer, size_t length) {
}
}
#ifdef HAS_PROTO_MESSAGE_DUMP
const char *ProtoMessage::dump() const {
static DumpBuffer buf;
buf = DumpBuffer(); // Reset buffer
this->dump_to(buf);
return buf.c_str();
}
#endif
} // namespace esphome::api

View File

@@ -427,8 +427,7 @@ class ProtoMessage {
// Default implementation for messages with no fields
virtual void calculate_size(ProtoSize &size) const {}
#ifdef HAS_PROTO_MESSAGE_DUMP
const char *dump() const;
virtual void dump_to(DumpBuffer &out) const = 0;
virtual const char *dump_to(DumpBuffer &out) const = 0;
virtual const char *message_name() const { return "unknown"; }
#endif
};

View File

@@ -2216,24 +2216,22 @@ def build_message_type(
# dump_to method declaration in header
prot = "#ifdef HAS_PROTO_MESSAGE_DUMP\n"
prot += "void dump_to(DumpBuffer &out) const override;\n"
prot += "const char *dump_to(DumpBuffer &out) const override;\n"
prot += "#endif\n"
public_content.append(prot)
# dump_to implementation will go in dump_cpp
dump_impl = f"void {desc.name}::dump_to(DumpBuffer &out) const {{"
dump_impl = f"const char *{desc.name}::dump_to(DumpBuffer &out) const {{"
if dump:
# 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"
dump_impl += " return out.c_str();\n"
else:
o2 = f'out.append("{desc.name} {{}}");'
if len(dump_impl) + len(o2) + 3 < 120:
dump_impl += f" {o2} "
else:
dump_impl += "\n"
dump_impl += f" {o2}\n"
dump_impl += "\n"
dump_impl += f' out.append("{desc.name} {{}}");\n'
dump_impl += " return out.c_str();\n"
dump_impl += "}\n"
if base_class:
@@ -2521,7 +2519,8 @@ def build_service_message_type(
case += "// Empty message: no decode needed\n"
if log:
case += "#ifdef HAS_PROTO_MESSAGE_DUMP\n"
case += f'ESP_LOGVV(TAG, "{func}: %s", msg.dump());\n'
case += "DumpBuffer dump_buf;\n"
case += f'ESP_LOGVV(TAG, "{func}: %s", msg.dump_to(dump_buf));\n'
case += "#endif\n"
case += f"this->{func}(msg);\n"
case += "break;"
@@ -2853,7 +2852,8 @@ static const char *const TAG = "api.service";
# Add non-template send_message method
hpp += " bool send_message(const ProtoMessage &msg, uint8_t message_type) {\n"
hpp += "#ifdef HAS_PROTO_MESSAGE_DUMP\n"
hpp += " this->log_send_message_(msg.message_name(), msg.dump());\n"
hpp += " DumpBuffer dump_buf;\n"
hpp += " this->log_send_message_(msg.message_name(), msg.dump_to(dump_buf));\n"
hpp += "#endif\n"
hpp += " return this->send_message_(msg, message_type);\n"
hpp += " }\n\n"