Commit Graph
24270 Commits
Author SHA1 Message Date
J. Nick Koston 297685d4bf Merge remote-tracking branch 'origin/proto-byte-buffer' into integration 2026-03-07 22:42:14 -10:00
J. Nick Koston 6a6b67a549 Merge remote-tracking branch 'upstream/dev' into proto-byte-buffer
# Conflicts:
#	esphome/components/api/proto.h
2026-03-07 22:11:15 -10:00
J. Nick KostonandClaude Opus 4.6 a530aeec22 [api] Inline varint and encode_varint_raw fast paths for hot loop performance (#14607)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 22:09:12 -10:00
dependabot[bot] d9e76da806 Bump aioesphomeapi from 44.4.0 to 44.5.0 (#14617)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-08 07:59:25 +00:00
J. Nick Koston 36755d6a08 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-07 21:17:44 -10:00
e4b89a69d4 [nrf52, ota] ble and serial OTA based on mcumgr (#11932)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick+github@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-07 20:32:20 -10:00
J. Nick Koston 5228c8b54d Merge branch 'inline-varint-fast-path' into integration 2026-03-07 20:18:00 -10:00
J. Nick Koston fa027ec130 Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 20:16:51 -10:00
J. Nick Koston 507c29add7 Inline encode_varint_raw fast path and add [[likely]] hints
Apply the same inline fast-path / noinline slow-path split to
ProtoWriteBuffer::encode_varint_raw that was done for ProtoSize::varint.

For values < 128 (field tags, small field values, short lengths), the
single-byte write is now inlined at each call site instead of going
through a full function call. The multi-byte loop is outlined into
encode_varint_raw_slow_().

Also add [[likely]] to both varint fast paths (ProtoSize::varint and
encode_varint_raw) to hint branch prediction.
2026-03-07 20:12:33 -10:00
J. Nick Koston 78c27851bb [api] APIBuffer: add explicit include, fix stale comment, clarify docs
- Add explicit #include "api_buffer.h" in api_server.h
- Remove stale "swap trick" comment in api_frame_helper.h
- Document that exact-size allocation is intentional (no growth factor)
- Clarify debug_check_bounds_ scope to protobuf write path only
2026-03-07 20:07:34 -10:00
Keith Burzinski 04cff1c916 [usb_uart] Return flush result, expose timeout via config (#14616) 2026-03-08 00:04:14 -06:00
J. Nick Koston 84e5825fd1 Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 19:46:15 -10:00
J. Nick Koston f7aeaad929 [api] Replace std::vector<uint8_t> with APIBuffer to skip zero-fill
Replace std::vector<uint8_t> with a minimal APIBuffer class for the
shared protobuf write buffer, frame helper receive buffer (rx_buf_),
and noise handshake prologue buffer.

std::vector::resize() zero-fills new bytes via memset. Every byte is
immediately overwritten by the protobuf encoder or socket reads,
making the zero-fill pure waste. APIBuffer skips zero-initialization
on resize() and uses make_unique_for_overwrite where available.

Also removes a dead write_raw_ template overload from api_frame_helper.h.
2026-03-07 19:45:50 -10:00
J. Nick Koston 409ff279b7 Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 19:45:07 -10:00
J. Nick Koston 126f695b93 [api] Extract APIBuffer to own file, use for rx_buf_ and prologue_
- Move APIBuffer (renamed from ProtoByteBuffer) to api_buffer.h/cpp
- Use APIBuffer for rx_buf_ (frame helper receive buffer) and
  prologue_ (noise handshake buffer) to skip zero-fill on resize
- Remove dead write_raw_ template overload and unused <vector> include
2026-03-07 19:41:05 -10:00
5e842a8b20 [uart] Return flush result, expose timeout via config (#14608)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-08 05:23:13 +00:00
J. Nick Koston b088c54bf5 Merge branch 'dev' into proto-byte-buffer 2026-03-07 18:59:44 -10:00
J. Nick Koston 9c245100ed Merge branch 'dev' into inline-varint-fast-path 2026-03-07 18:59:33 -10:00
J. Nick KostonandClaude Opus 4.6 be6c3c52ac [api] Add force proto field option to skip zero checks on hot path (#14610)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:59:13 -10:00
Jonathan SwobodaandClaude Opus 4.6 9fea8fe01b [vbus][rf_bridge][sensirion_common] Add buffer size guards (#14597)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:50:36 -10:00
J. Nick KostonandKeith Burzinski d55fe9a34b [api] Fix value-initialization of DeviceInfoResponse (#14615)
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
2026-03-07 18:34:35 -10:00
J. Nick Koston 66919ef969 [i2s_audio] Include legacy driver IDF component when use_legacy is set (#14613) 2026-03-07 22:33:54 -06:00
J. Nick Koston 543e9b9b54 Merge remote-tracking branch 'upstream/fix-modbus-usb-uart-timeout' into integration 2026-03-07 18:28:07 -10:00
J. Nick Koston dca303494b Merge remote-tracking branch 'upstream/proto-force-field-option' into integration 2026-03-07 18:28:00 -10:00
J. Nick Koston e6d222959b Merge remote-tracking branch 'upstream/ld2450-integration-tests' into integration 2026-03-07 18:27:54 -10:00
J. Nick Koston 6d63a478b1 Merge remote-tracking branch 'upstream/fix-i2s-legacy-driver-include' into integration 2026-03-07 18:27:33 -10:00
J. Nick Koston 3b4897381f Address review feedback
- Avoid unnecessary vector construction in static mode path
- Use wraparound-safe millis comparison for staged RX
- Fix stale comments (20ms -> 40ms, ESP-IDF -> ESP32)
- Clarify MODBUS_BITS_PER_CHAR is approximate
2026-03-07 18:25:33 -10:00
J. Nick Koston 5319b8593b Add latency simulation to uart_mock for USB UART test
Add inject_to_rx_buffer_delayed() to uart_mock which stages bytes
that aren't visible to available() until the delay elapses. This
simulates USB packet delivery latency.

The test uses a 40ms delay which is:
- Greater than the old ~2ms timeout (fails without fix)
- Less than the new 50ms fallback timeout (passes with fix)
2026-03-07 18:07:18 -10:00
J. Nick Koston ab08aa7553 fix hostname len 2026-03-07 17:51:56 -10:00
J. Nick Koston 7d9a081a84 Make RX_FULL_THRESHOLD_UNSET public
Needed since modbus accesses it from outside the class.
2026-03-07 17:49:01 -10:00
J. Nick Koston c4b26fd3f5 Add integration test for non-hardware UART and extract constants
- Add test fixture simulating USB UART (no rx_full_threshold set)
  with a 20ms gap between response chunks
- Make rx_full_threshold optional in uart_mock
- Extract MODBUS_BITS_PER_CHAR and MS_PER_SEC constexprs
2026-03-07 17:41:56 -10:00
J. Nick Koston d13e87b5b5 [modbus] Fix timeout for non-hardware UARTs (e.g., USB UART)
The rx_full_threshold is only meaningful for ESP32 native UARTs where
it controls the hardware FIFO interrupt threshold. On other platforms
(USB UART, Arduino, etc.) it was left at the default of 1, causing
the long_rx_buffer_delay_ms calculation to produce a tiny value (~1-2ms).

This caused false timeouts on partial responses when data arrives in
USB packets with inherent USB-level latency, leading to cascading
CRC failures as the remaining bytes were parsed as garbage.

Change the default rx_full_threshold to 0 (unset sentinel) and use
50ms when unset, matching the previous hardcoded timeout behavior.
2026-03-07 17:37:57 -10:00
J. Nick Koston f01a050db2 [i2s_audio] Include legacy driver IDF component when use_legacy is set
The "driver" shim component (providing driver/i2s.h) was excluded by
default in #13623 to reduce compile time. When use_legacy is true,
the i2s_audio component needs this shim for the legacy I2S API headers.
2026-03-07 17:21:00 -10:00
J. Nick Koston 8582069e69 Add force support to EnumType encode_content
Ensure EnumType.encode_content passes force=true to the encode
function when the force field option is set, matching all other
TypeInfo subclasses for consistency and safety.
2026-03-07 17:13:43 -10:00
J. Nick Koston 72232c95d8 Use YAML anchors for filter dedup, add missing assertion, fix dummy baud rate 2026-03-07 17:13:06 -10:00
J. Nick KostonandClaude Opus 4.6 a9cce33fd5 Support force option on all field types
Fixed-width types (float, fixed32, sfixed32, fixed64, sfixed64)
now handle force=true by emitting a compile-time constant size
instead of the zero-checked calc_ call.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 17:07:59 -10:00
J. Nick Koston d8915da9cc [ld2450] Add integration tests with mock UART 2026-03-07 17:03:16 -10:00
J. Nick Koston 45ed033ee5 Merge remote-tracking branch 'upstream/proto-force-field-option' into integration 2026-03-07 16:46:32 -10:00
J. Nick KostonandClaude Opus 4.6 a27f5127d8 [api] Add force field option to skip zero checks on hot path
Add a `force` proto field option that generates `_force` variants of
calc_ and encode methods, skipping the zero/empty check. Applied to
BluetoothLERawAdvertisement fields that are almost always non-default
(address, rssi, data) to eliminate dead branches on the BLE proxy
hot path.

On-device benchmarks show calculate_size improved from 12,649 ns to
10,982 ns per 12-advertisement batch (-13.2%) with only +8 bytes flash.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 16:44:12 -10:00
dependabot[bot] ea7cfffdda Bump aioesphomeapi from 44.3.1 to 44.4.0 (#14609)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-08 02:40:13 +00:00
J. Nick KostonandClaude Opus 4.6 71bc54eb81 Merge upstream/inline-varint-fast-path into integration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 15:42:58 -10:00
J. Nick KostonandClaude Opus 4.6 8ae54656fc Move varint_slow to private
It has a precondition (value >= 128) and should not be callable
from outside the class.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 15:41:45 -10:00
J. Nick KostonandClaude Opus 4.6 a5780eec54 Extract varint_wide helper to deduplicate cascade
The constexpr path and the noinline slow path shared the same
if/else cascade for values >= 128. Extract into a private
constexpr ESPHOME_ALWAYS_INLINE helper used by both.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 15:41:01 -10:00
J. Nick KostonandClaude Opus 4.6 44b50055af Rename varint_slow_ to varint_slow for clang-tidy naming
Static methods use lower_snake_case without trailing underscore.
The trailing underscore convention is for member fields only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 15:31:33 -10:00
J. Nick KostonandClaude Opus 4.6 ddeb8038c4 Merge origin/inline-varint-fast-path into integration branch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 15:29:52 -10:00
J. Nick KostonandClaude Opus 4.6 244e672b0a Revert force-inlining of calc_uint32 and calc_length
The ESPHOME_ALWAYS_INLINE on these caused significant flash bloat in
cold calculate_size() callers (DeviceInfoResponse +117B, HelloResponse
+63B, ListEntitiesEventResponse +79B) while only benefiting the BLE
hot path marginally. Let the compiler decide when to inline these.

The varint() fast path remains force-inlined as that eliminates the
most expensive indirect calls on the hot path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 15:28:06 -10:00
J. Nick Koston 05896c38e8 [api] Inline ProtoSize::varint fast path for hot loop performance
Split ProtoSize::varint() into an always-inlined fast path (value < 128)
and a noinline slow path, eliminating indirect function calls on the BLE
advertisement encode hot path. Also force-inline calc_uint32() and
calc_length() so the compiler fully inlines size calculations per
advertisement instead of emitting out-of-line calls.

Verified via Xtensa disassembly: eliminates ~80 indirect function calls
per 16-advertisement batch flush (3 calc + varint per advertisement).
Total hot path code reduced from 24 to 21 functions.
2026-03-07 15:20:58 -10:00
J. Nick Koston ce3fcca292 Merge branch 'integration' of https://github.com/esphome/esphome into integration 2026-03-07 14:51:36 -10:00
J. Nick Koston da8de59bcb Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 13:38:26 -10:00
J. Nick Koston 2a1af73d6f Merge branch 'dev' into proto-byte-buffer 2026-03-07 13:34:15 -10:00