Commit Graph

432 Commits

Author SHA1 Message Date
J. Nick Koston bc6691da9a Merge remote-tracking branch 'origin/rp2040-upload-improvements' into integration 2026-03-09 17:49:47 -10:00
Javier Peletier e82f0f4432 [cpptests] support testing platform components (#13075)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-03-10 02:41:02 +00:00
J. Nick Koston d6ce5dda81 [ci] Skip YAML anchor keys in integration fixture component extraction (#14670) 2026-03-09 22:54:56 +00:00
J. Nick Koston 972d0978bd [api] Add explicit static_cast<uint32_t> in decode_zigzag32 calls
On BLE builds where proto_varint_value_t is uint64_t, decode_zigzag32()
takes uint32_t — make the narrowing explicit to match the static_cast
pattern used for other type conversions in generated code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:04:55 -10:00
J. Nick Koston 6a0539b3d6 Merge branch 'inline-varint-parse-fast-path' into integration 2026-03-08 21:00:55 -10:00
J. Nick Koston 9f57c2a9b6 [api] Fix HELPER_LOG format mismatch and remove unused is_varint64 codegen field
- Cast msg_size/type_varint.value to uint32_t in HELPER_LOG to match PRIu32
  format (proto_varint_value_t is uint64_t on BLE builds)
- Remove unused is_varint64 field from api_protobuf.py TypeInfo classes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:52:26 -10:00
J. Nick Koston fab59c86a7 Merge remote-tracking branch 'upstream/dev' into inline-varint-parse-fast-path 2026-03-08 19:07:58 -10:00
J. Nick Koston b838085e41 [api] Use proto_varint_value_t type alias instead of #ifdef blocks
Replace per-override #ifdef USE_API_VARINT64 conditionals with a
single type alias proto_varint_value_t, eliminating preprocessor
blocks from every decode_varint signature in api_pb2.cpp/h.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 18:56:15 -10:00
J. Nick Koston fcd72336f0 [api] Change decode_varint parameter from ProtoVarIntResult to raw value type
Pass uint32_t (or uint64_t when USE_API_VARINT64 is defined) directly
to decode_varint() instead of the ProtoVarIntResult struct. This
eliminates accessor method overhead in each of the 51 overrides,
replacing value.as_uint32() with direct value usage, value.as_bool()
with value != 0, etc. No vtable growth - single virtual method with
conditionally-typed parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 18:39:59 -10:00
Clyde Stubbs f3ca86b670 [ci-custom] Directions on constant hoisting (#14637) 2026-03-08 23:48:03 -04:00
J. Nick Koston 3653e0cf9f Merge branch 'dev' into inline-varint-parse-fast-path 2026-03-08 17:24:17 -10:00
J. Nick Koston 088a8a4338 [ci] Match symbols with changed signatures in memory impact analysis (#14600)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 17:23:58 -10:00
J. Nick Koston e285fd6815 [api] Inline ProtoVarInt::parse fast path and return consumed in struct
Replace optional<ProtoVarInt> + consumed pointer with ProtoVarIntResult
struct that returns value + consumed count directly. This eliminates
memory stores through a pointer on the fast path (single-byte varints
< 128), keeping everything in registers.

The parse() method is now ESPHOME_ALWAYS_INLINE with the multi-byte
slow path outlined to parse_slow_(). The common case for protobuf
field tags, small enums, booleans, and typical message sizes/types
is a simple high-bit check + register return with no function call.

Measured on ESP32 (Xtensa): try_read_frame_ grows only +12 bytes
(320 → 332) for two inlined parse sites, while eliminating two
function calls per message on the hot path.
2026-03-08 17:13:03 -10:00
J. Nick Koston 36755d6a08 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-07 21:17:44 -10:00
tomaszduda23 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 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
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 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 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 45ed033ee5 Merge remote-tracking branch 'upstream/proto-force-field-option' into integration 2026-03-07 16:46:32 -10:00
J. Nick Koston 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
J. Nick Koston 77f2c371b2 [api] Single-pass protobuf encode for BLE proxy advertisements (#14575) 2026-03-07 07:26:34 -10:00
J. Nick Koston 8f7c34c502 Merge branch 'proto-backpatch-encode' into integration 2026-03-06 14:27:11 -10:00
J. Nick Koston 3d5b1e327e [api] Add single-pass encode_sub_message to eliminate redundant calculate_size() calls
Replace encode_message with encode_sub_message for protobuf submessage encoding.

For repeated submessage fields, encode_sub_message uses a backpatch approach:
writes field tag, reserves 1 byte for length varint, encodes the body, then
backpatches the actual length. For bodies >= 128 bytes, shifts the body forward
to make room for a multi-byte varint. This eliminates 2 of 3 calculate_size()
calls per repeated submessage element.

For singular submessage fields, encode_sub_message uses calculate_size() upfront
to skip empty submessages without writing to the buffer, preserving the debug
size check.

For the BLE advertisement proxy hot path (16 advertisements per batch), this
reduces calculate_size() calls from 48 to 16 per flush.
2026-03-06 14:26:58 -10:00
J. Nick Koston 42dbb51022 [api] Devirtualize protobuf encode/calculate_size (#14449)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-06 19:03:54 +00:00
J. Nick Koston 191e5d70b5 Merge origin/log-skip-vprintf-indirection into integration 2026-03-05 22:12:26 -10:00
J. Nick Koston 6e36af6c4b [log] Add ESPHOME_DEBUG_ASSERT for log function invariants
Add ESPHOME_DEBUG_ASSERT macro that only fires when ESPHOME_DEBUG is
defined. Use it to assert global_logger is not null in log functions.
Enable ESPHOME_DEBUG in C++ unit test builds so these assertions are
active during testing but have zero cost in production firmware.
2026-03-05 22:05:17 -10:00
J. Nick Koston 21fb5975d6 Merge remote-tracking branch 'upstream/dev' into integration
# Conflicts:
#	esphome/components/esphome/ota/ota_esphome.h
#	esphome/components/http_request/ota/ota_http_request.cpp
#	esphome/components/http_request/ota/ota_http_request.h
#	esphome/components/ota/ota_backend_factory.h
#	esphome/components/web_server/ota/ota_web_server.cpp
#	esphome/components/wifi/wifi_component.cpp
2026-03-05 10:57:44 -10:00
Kevin Ahrendt 5c5ea8824e [audio_file] New component for embedding files into firmware (#14434)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-03-05 09:51:08 -10:00
J. Nick Koston 6e99bc96a2 Merge remote-tracking branch 'upstream/rp2040-socket-wake' into integration 2026-03-04 22:37:44 -10:00
Clyde Stubbs f5c37bf486 [packet_transport] Minimise heap allocations (#14482) 2026-03-05 14:24:01 +11:00
J. Nick Koston 765075b1d0 tweaks 2026-03-03 21:35:11 -10:00
J. Nick Koston 3a5f03d0a3 naming 2026-03-03 20:22:02 -10:00
J. Nick Koston daf2e6ecc8 naming 2026-03-03 20:21:25 -10:00
J. Nick Koston 08c9990b53 simple register 2026-03-03 20:14:34 -10:00
J. Nick Koston a7b61b1061 twea 2026-03-03 18:22:23 -10:00
J. Nick Koston b0279752eb tweak 2026-03-03 17:09:36 -10:00
J. Nick Koston 78602ccacb [ci] Add lint check to prevent powf in core and base entity platforms (#14126) 2026-03-03 07:03:50 -10:00
J. Nick Koston 1f1b20f4fe [core] Pack entity string properties into PROGMEM-indexed uint8_t fields (#14171) 2026-03-03 07:03:24 -10:00
J. Nick Koston f68a3ed15d [api] Remove virtual destructor from ProtoMessage (#14393) 2026-03-01 18:09:00 -10:00
J. Nick Koston b7cb65ec49 [ci] Fix TypeError in ci-custom.py when POST lint checks fail (#14378) 2026-02-28 14:23:20 -10:00
J. Nick Koston 5c56b99742 [ci] Fix C++ unit tests missing time component dependency (#14364) 2026-02-27 13:19:11 -10:00
J. Nick Koston 1ccfcfc8d8 [time] Eliminate libc timezone bloat (~9.5KB flash ESP32, ~2% RAM on ESP8266) (#13635)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 15:12:44 -10:00
J. Nick Koston 8bb577de64 [api] Split ProtoVarInt::parse into 32-bit and 64-bit phases (#14039) 2026-02-25 12:23:13 -06:00
Jonathan Swoboda fb6c7d81d5 [core] Fix multiline log continuations without leading whitespace (#14217)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 05:08:40 +00:00
J. Nick Koston 9571a979eb [ci] Suggest StringRef instead of std::string_view (#14183) 2026-02-21 13:53:45 -06:00
J. Nick Koston f77da803c9 [api] Write protobuf encode output to pre-sized buffer directly (#14018) 2026-02-20 21:39:18 -06:00
Jonathan Swoboda 9ce01fc369 [esp32] Add engineering_sample option for ESP32-P4 (#14139)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 11:20:05 -05:00
J. Nick Koston b5a8e1c94c [ci] Update lint message to recommend constexpr over static const (#14099) 2026-02-19 09:06:46 -06:00
Guillermo Ruffino 7b251dcc31 [schema-gen] fix Windows: ensure UTF-8 encoding when reading component files (#13952) 2026-02-12 11:23:59 -05:00