Commit Graph

460 Commits

Author SHA1 Message Date
J. Nick Koston b6ea52b6a7 Merge remote-tracking branch 'upstream/lint-no-powf-core' into integration 2026-03-02 16:02:44 -10:00
J. Nick Koston 0847031fda Merge branch 'dev' into lint-no-powf-core 2026-03-02 13:16:06 -10:00
J. Nick Koston f68a3ed15d [api] Remove virtual destructor from ProtoMessage (#14393) 2026-03-01 18:09:00 -10:00
J. Nick Koston c2a6295b37 Merge remote-tracking branch 'upstream/remove-virtual-destructor-proto-message' into integration 2026-02-28 16:40:48 -10:00
J. Nick Koston 28178b8c1c fixes 2026-02-28 16:39:13 -10:00
J. Nick Koston f3c175ab39 [api] Remove virtual destructor from ProtoMessage
API protobuf messages are never deleted through base class pointers —
they are always stack-allocated and passed by reference. The virtual
destructor occupies 2 vtable slots (complete + deleting destructor)
on 32-bit platforms using the Itanium ABI, costing 8 bytes per vtable.

With 122 message classes, removing the virtual destructor saves
~976 bytes of flash. Each vtable shrinks from 24 bytes to 16 bytes.
2026-02-28 16:29:19 -10:00
J. Nick Koston 9b8fe6230c Merge remote-tracking branch 'upstream/isr-wake-enable-loop-soon' into integration 2026-02-28 14:56:19 -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 c37d02e2e5 Merge remote-tracking branch 'upstream/dev' into integration 2026-02-27 14:00:10 -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
J. Nick Koston f255f03822 Merge remote-tracking branch 'upstream/dev' into lint-no-powf-core
# Conflicts:
#	esphome/core/helpers.h
#	script/ci-custom.py
2026-02-23 17:05:39 -06:00
J. Nick Koston 9bf34be20d Merge remote-tracking branch 'upstream/dev' into integration 2026-02-23 12:07:15 -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 c98b955881 Merge remote-tracking branch 'origin/pack-entity-strings' into integration 2026-02-21 22:13:39 -06:00
J. Nick Koston 5fd0ee1717 Merge branch 'dev' into pack-entity-strings 2026-02-21 22:12:49 -06:00
J. Nick Koston e74506b957 Merge branch 'scheduler_de_template' into integration 2026-02-21 17:34:37 -06: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 2906f56b3f tweaks 2026-02-20 23:32:28 -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
J. Nick Koston 4c70f2001a Merge branch 'fix_logger_loop_disable' into integration 2026-02-20 13:21:08 -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 d51b0e51b1 Merge remote-tracking branch 'origin/api_varint_split_32_64' into integration 2026-02-19 20:25:25 -06:00
J. Nick Koston 21b9a4139a Address review feedback: fix unconditional guard bug, add ifndef guard, clarify comment
- Fix get_varint64_ifdef() to return unconditional guard when any 64-bit
  varint field has no ifdef (None in ifdefs set)
- Wrap USE_API_VARINT64 define with #ifndef to avoid redefinition warnings
  when esphome/core/defines.h also defines it (test/IDE builds)
- Clarify proto.h comment about uint32_t shift behavior at byte 4
- Add namespace to generated api_pb2_defines.h for linter compliance
2026-02-19 20:23:17 -06:00
J. Nick Koston 4e3b2abd5f Fix ODR violation: generate api_pb2_defines.h for consistent ProtoVarInt layout
USE_API_VARINT64 was only defined in api_pb2.h, but proto.cpp (where
decode() and parse_wide() live) includes proto.h directly. This caused:

1. parse_wide() not compiled in proto.cpp (guarded by #ifdef)
2. decode() used 32-bit-only parse(), returning {} for varints > 5 bytes
3. ODR violation: ProtoVarInt was 4 bytes in proto.cpp but 8 bytes in
   api_pb2*.cpp translation units

For bluetooth_proxy, 48-bit BLE addresses encode as 7-byte varints.
The failed parse caused decode() to return early, leaving request_type
at its default value of 0 (BLUETOOTH_DEVICE_REQUEST_TYPE_CONNECT),
producing spurious "V1 connections removed" errors.

Fix: Generate api_pb2_defines.h with the USE_API_VARINT64 define and
include it from proto.h, ensuring all translation units see a consistent
ProtoVarInt layout.
2026-02-19 20:08:29 -06:00
J. Nick Koston eb83c85a08 [ci] Add lint check to prevent powf in core and base entity platforms
Add a ci-custom.py check that prevents powf() from being introduced
into esphome/core/ and base entity platform components (sensor, light,
climate, etc.). These files are linked into every build, and powf
pulls in __ieee754_powf (~2.3KB flash).

Existing legitimate uses of powf with non-integer exponents (gamma
correction in helpers.cpp) are excluded. New uses can opt out with
// NOLINT if truly necessary.
2026-02-19 15:56:19 -06:00
J. Nick Koston 41cfe2f9ad Merge remote-tracking branch 'upstream/dev' into integration 2026-02-19 09:17:46 -06:00
J. Nick Koston b5a8e1c94c [ci] Update lint message to recommend constexpr over static const (#14099) 2026-02-19 09:06:46 -06:00
J. Nick Koston 2873f7f8f3 Merge branch 'api_varint_split_32_64' into integration 2026-02-18 10:23:08 -06:00
J. Nick Koston bd6048faf8 Merge origin/dev into api_varint_split_32_64 2026-02-17 18:56:11 -06:00
J. Nick Koston 3989236154 [api] Split ProtoVarInt::parse into 32-bit and 64-bit phases
On 32-bit platforms (ESP32 Xtensa), 64-bit shifts in varint parsing
compile to __ashldi3 library calls. Since the vast majority of protobuf
varint fields (message types, sizes, enum values, sensor readings) fit
in 4 bytes, the 64-bit arithmetic is unnecessary overhead on the common
path.

Split parse() into two phases:
- Bytes 0-3: uint32_t loop with native 32-bit shifts (0, 7, 14, 21)
- Bytes 4-9: noinline parse_wide_() with uint64_t, only for BLE
  addresses and other 64-bit fields

The code generator auto-detects which proto messages use int64/uint64/
sint64 fields and emits USE_API_VARINT64 conditionally. On non-BLE
configs, parse_wide_() and the 64-bit accessors (as_uint64, as_int64,
as_sint64) are compiled out entirely.

Saves ~40 bytes flash on non-BLE configs. Benchmark shows 25-50%
faster parsing for 1-4 byte varints (the common case).
2026-02-17 18:54:25 -06:00
J. Nick Koston 63bf03c467 Merge branch 'api-proto-write-presized-buffer' into integration 2026-02-16 16:09:01 -06:00
J. Nick Koston 9d387b66db address copilot revie wcomments 2026-02-16 16:03:35 -06:00
J. Nick Koston 09f604f2fc Merge branch 'api-proto-write-presized-buffer' into integration
# Conflicts:
#	esphome/components/api/proto.h
2026-02-16 15:17:06 -06:00
J. Nick Koston f1d51773af Revert "[api] Pass ProtoWriteBuffer by reference in encode()"
This reverts commit 6369f3b279.
2026-02-16 15:12:10 -06:00
J. Nick Koston 6369f3b279 [api] Pass ProtoWriteBuffer by reference in encode()
Pass ProtoWriteBuffer by reference instead of by value in virtual
encode() methods. This avoids copying both buffer_ and pos_ pointers
for every encode call - only a single pointer is passed.

Also simplifies encode_message since child writes directly advance
the shared pos_. Adds debug_check_size_ to verify calculate_size
matches actual encode output.
2026-02-16 15:01:59 -06:00
J. Nick Koston af4579ca87 [api] Write protobuf encode output to pre-sized buffer directly
ProtoSize::calculate_size() already computes the exact encoded size
before encode() runs and is the boundary validation. The buffer is
pre-sized to match. Since the buffer size is always correct,
push_back() capacity checks on every byte are redundant overhead.

Rename ProtoWriteBuffer to ProtoWritePreSizedBuffer to document the
contract. Write through a raw uint8_t* pointer instead of push_back().
Pre-resize the buffer to include payload space before encoding.

Add ESPHOME_DEBUG_API bounds checks to validate writes stay within the
pre-sized region during development and integration testing.
2026-02-16 14:40:55 -06:00
J. Nick Koston e8f2d21d66 Merge remote-tracking branch 'origin/deprecate-wifi-ssid' into integration 2026-02-12 10:49:15 -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
J. Nick Koston 6c6da8a3cd [api] Skip class generation for empty SOURCE_CLIENT protobuf messages (#13880) 2026-02-09 18:45:24 +00:00
J. Nick Koston e4ea016d1e [ci] Block new std::to_string() usage, suggest snprintf alternatives (#13369) 2026-02-09 12:26:19 -06:00
J. Nick Koston 743fdee8e2 Merge branch 'no_gen_empty_messages' into integration 2026-02-09 12:20:20 -06:00
J. Nick Koston 8b733921b5 rename dict to make bot happy 2026-02-09 12:20:01 -06:00
J. Nick Koston e40fccc526 Merge branch 'no_gen_empty_messages' into integration
# Conflicts:
#	esphome/components/esp32_hosted/update/esp32_hosted_update.cpp
#	esphome/core/component.cpp
2026-02-09 12:12:28 -06:00
J. Nick Koston c658d7b57f [api] Merge auth check into base read_message, eliminate APIServerConnection (#13873) 2026-02-09 12:02:02 -06:00
J. Nick Koston 3cde3daceb [api] Collapse APIServerConnection intermediary layer (#13872) 2026-02-09 08:45:33 -06:00
J. Nick Koston 4f5be934a0 [api] Skip class generation for empty SOURCE_CLIENT protobuf messages 2026-02-09 04:12:01 -06:00
J. Nick Koston f3a0d46ee9 Revert "[api] Skip class generation for empty SOURCE_CLIENT protobuf messages"
This reverts commit bd23e3ffa9.
2026-02-09 04:11:39 -06:00
J. Nick Koston bd23e3ffa9 [api] Skip class generation for empty SOURCE_CLIENT protobuf messages 2026-02-09 04:05:23 -06:00