From 504ca09451d270b42b7694110868ace4803546c3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 11 Jul 2025 11:59:14 -1000 Subject: [PATCH 1/2] revert --- esphome/components/api/api_frame_helper.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/esphome/components/api/api_frame_helper.cpp b/esphome/components/api/api_frame_helper.cpp index d65f5d4c82..156fd42cb3 100644 --- a/esphome/components/api/api_frame_helper.cpp +++ b/esphome/components/api/api_frame_helper.cpp @@ -616,10 +616,8 @@ APIError APINoiseFrameHelper::read_packet(ReadPacketBuffer *buffer) { APIError APINoiseFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) { // Resize to include MAC space (required for Noise encryption) buffer.get_buffer()->resize(buffer.get_buffer()->size() + frame_footer_size_); - uint16_t payload_size = - static_cast(buffer.get_buffer()->size() - frame_header_padding_ - frame_footer_size_); - - PacketInfo packet{type, 0, payload_size}; + PacketInfo packet{type, 0, + static_cast(buffer.get_buffer()->size() - frame_header_padding_ - frame_footer_size_)}; return write_protobuf_packets(buffer, std::span(&packet, 1)); } @@ -1005,9 +1003,7 @@ APIError APIPlaintextFrameHelper::read_packet(ReadPacketBuffer *buffer) { return APIError::OK; } APIError APIPlaintextFrameHelper::write_protobuf_packet(uint8_t type, ProtoWriteBuffer buffer) { - uint16_t payload_size = static_cast(buffer.get_buffer()->size() - frame_header_padding_); - - PacketInfo packet{type, 0, payload_size}; + PacketInfo packet{type, 0, static_cast(buffer.get_buffer()->size() - frame_header_padding_)}; return write_protobuf_packets(buffer, std::span(&packet, 1)); } From fb2d764c89247a280b2d7389ffd29bc884a79fe7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 11 Jul 2025 16:48:20 -1000 Subject: [PATCH 2/2] tidy --- .../custom_api_device_component/custom_api_device_component.cpp | 2 +- .../custom_api_device_component/custom_api_device_component.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/fixtures/external_components/custom_api_device_component/custom_api_device_component.cpp b/tests/integration/fixtures/external_components/custom_api_device_component/custom_api_device_component.cpp index 892ad17842..db0ae29511 100644 --- a/tests/integration/fixtures/external_components/custom_api_device_component/custom_api_device_component.cpp +++ b/tests/integration/fixtures/external_components/custom_api_device_component/custom_api_device_component.cpp @@ -21,7 +21,7 @@ void CustomAPIDeviceComponent::setup() { void CustomAPIDeviceComponent::on_test_service() { ESP_LOGI(TAG, "Custom test service called!"); } -void CustomAPIDeviceComponent::on_service_with_args(std::string arg_string, int32_t arg_int, bool arg_bool, +void CustomAPIDeviceComponent::on_service_with_args(const std::string &arg_string, int32_t arg_int, bool arg_bool, float arg_float) { ESP_LOGI(TAG, "Custom service called with: %s, %d, %d, %.2f", arg_string.c_str(), arg_int, arg_bool, arg_float); } diff --git a/tests/integration/fixtures/external_components/custom_api_device_component/custom_api_device_component.h b/tests/integration/fixtures/external_components/custom_api_device_component/custom_api_device_component.h index cdfda63348..21071c4430 100644 --- a/tests/integration/fixtures/external_components/custom_api_device_component/custom_api_device_component.h +++ b/tests/integration/fixtures/external_components/custom_api_device_component/custom_api_device_component.h @@ -17,7 +17,7 @@ class CustomAPIDeviceComponent : public Component, public CustomAPIDevice { void on_test_service(); - void on_service_with_args(std::string arg_string, int32_t arg_int, bool arg_bool, float arg_float); + void on_service_with_args(const std::string &arg_string, int32_t arg_int, bool arg_bool, float arg_float); void on_service_with_arrays(std::vector bool_array, std::vector int_array, std::vector float_array, std::vector string_array);