Log the high performance override; pin range bounds; fold compile test into the existing build

This commit is contained in:
J. Nick Koston
2026-08-21 17:36:40 -05:00
parent 8f68ce0ae8
commit b2fd7ef7ac
4 changed files with 32 additions and 12 deletions
+7 -1
View File
@@ -32,7 +32,8 @@ CONF_TCP_SEND_BUFFER = "tcp_send_buffer"
# stock ESP-IDF default (5744 bytes) stalls bursty senders like a Bluetooth
# proxy streaming GATT notifications. Bounds follow the lwIP guidance for the
# default 1440 byte MSS: at least 2 x MSS, at most 65535 without window
# scaling.
# scaling. The cap is kept even when window scaling is on (high performance
# with PSRAM) as a deliberate conservative bound.
TCP_SEND_BUFFER_MIN = 2880
TCP_SEND_BUFFER_MAX = 65535
@@ -463,6 +464,11 @@ async def to_code(config):
# After the high performance block so an explicit size wins over the
# bundle's 65534 (last write wins in the sdkconfig store).
if (tcp_send_buffer := config.get(CONF_TCP_SEND_BUFFER)) is not None:
if CORE.is_esp32 and should_enable:
_LOGGER.info(
"TCP send buffer set to %d bytes by configuration (overriding high performance value)",
tcp_send_buffer,
)
add_idf_sdkconfig_option("CONFIG_LWIP_TCP_SND_BUF_DEFAULT", tcp_send_buffer)
if CORE.is_nrf52:
@@ -14,16 +14,23 @@ import pytest
from voluptuous import Invalid
from esphome import config_validation as cv
from esphome.components.esp32.const import KEY_VARIANT, VARIANT_ESP32
from esphome.components.network import CONFIG_SCHEMA
from esphome.const import KEY_FRAMEWORK_VERSION, PlatformFramework
from esphome.components.esp32.const import (
KEY_SDKCONFIG_OPTIONS,
KEY_VARIANT,
VARIANT_ESP32,
)
from esphome.components.network import (
CONF_TCP_SEND_BUFFER,
CONFIG_SCHEMA,
TCP_SEND_BUFFER_MAX,
TCP_SEND_BUFFER_MIN,
)
from esphome.const import KEY_ESP32, KEY_FRAMEWORK_VERSION, PlatformFramework
from esphome.core import CORE
from tests.component_tests.types import SetCoreConfigCallable
def _sdkconfig_option(name: str) -> int | None:
from esphome.components.esp32.const import KEY_ESP32, KEY_SDKCONFIG_OPTIONS
return CORE.data[KEY_ESP32][KEY_SDKCONFIG_OPTIONS].get(name)
@@ -44,6 +51,18 @@ def test_tcp_send_buffer_overrides_high_performance(
assert _sdkconfig_option("CONFIG_LWIP_TCP_SND_BUF_DEFAULT") == 16384
@pytest.mark.parametrize("value", [TCP_SEND_BUFFER_MIN, TCP_SEND_BUFFER_MAX])
def test_boundary_values_accepted(
set_core_config: SetCoreConfigCallable, value: int
) -> None:
set_core_config(
PlatformFramework.ESP32_IDF,
core_data={KEY_FRAMEWORK_VERSION: cv.Version(5, 5, 5)},
platform_data={KEY_VARIANT: VARIANT_ESP32},
)
assert CONFIG_SCHEMA({"tcp_send_buffer": value})[CONF_TCP_SEND_BUFFER] == value
@pytest.mark.parametrize("value", ["1kB", "128kB"])
def test_out_of_range_rejected(
set_core_config: SetCoreConfigCallable, value: str
@@ -1,6 +0,0 @@
wifi:
ssid: MySSID
password: password1
network:
tcp_send_buffer: 32kB
@@ -2,3 +2,4 @@
network:
enable_high_performance: true
tcp_send_buffer: 32kB