mirror of
https://github.com/esphome/esphome.git
synced 2026-09-18 18:48:39 +00:00
Merge remote-tracking branch 'upstream/core-component-phase-raii' into integration
This commit is contained in:
@@ -289,12 +289,12 @@ def final_validate(config):
|
||||
def _consume_wifi_sockets(config: ConfigType) -> ConfigType:
|
||||
"""Register UDP PCBs used internally by lwIP for DHCP and DNS.
|
||||
|
||||
Only needed on LibreTiny where we directly set MEMP_NUM_UDP_PCB (the raw
|
||||
PCB pool shared by both application sockets and lwIP internals like DHCP/DNS).
|
||||
On ESP32, CONFIG_LWIP_MAX_SOCKETS only controls the POSIX socket layer —
|
||||
DHCP/DNS use raw udp_new() which bypasses it entirely.
|
||||
Needed on LibreTiny and RP2040 where we directly set MEMP_NUM_UDP_PCB (the
|
||||
raw PCB pool shared by both application sockets and lwIP internals like
|
||||
DHCP/DNS). On ESP32, CONFIG_LWIP_MAX_SOCKETS only controls the POSIX socket
|
||||
layer — DHCP/DNS use raw udp_new() which bypasses it entirely.
|
||||
"""
|
||||
if not (CORE.is_bk72xx or CORE.is_rtl87xx or CORE.is_ln882x):
|
||||
if not (CORE.is_bk72xx or CORE.is_rtl87xx or CORE.is_ln882x or CORE.is_rp2040):
|
||||
return config
|
||||
from esphome.components import socket
|
||||
|
||||
|
||||
@@ -150,6 +150,21 @@ TEST(ValueAccuracyToBuf, ReturnsCorrectLength) {
|
||||
EXPECT_EQ(strlen(buf), len);
|
||||
}
|
||||
|
||||
TEST(ValueAccuracyToBuf, NegativeZero) {
|
||||
// Hand-rolled formatter must preserve snprintf's sign-of-zero behavior.
|
||||
EXPECT_EQ(va_to_string(-0.0f, 2), va_reference(-0.0f, 2));
|
||||
EXPECT_EQ(va_to_string(-0.0f, 0), va_reference(-0.0f, 0));
|
||||
// Tiny negative that rounds to zero at this precision must still render as "-0.00".
|
||||
EXPECT_EQ(va_to_string(-0.001f, 2), va_reference(-0.001f, 2));
|
||||
}
|
||||
|
||||
TEST(ValueAccuracyToBuf, OverflowFallsBackToSnprintf) {
|
||||
// |value| * 10^acc must exceed UINT32_MAX to exercise the snprintf fallback path.
|
||||
EXPECT_EQ(va_to_string(1.0e7f, 3), va_reference(1.0e7f, 3));
|
||||
EXPECT_EQ(va_to_string(-1.0e7f, 3), va_reference(-1.0e7f, 3));
|
||||
EXPECT_EQ(va_to_string(5.0e9f, 0), va_reference(5.0e9f, 0));
|
||||
}
|
||||
|
||||
// --- value_accuracy_with_uom_to_buf ---
|
||||
|
||||
static std::string va_uom_to_string(float value, int8_t accuracy_decimals, const char *uom) {
|
||||
|
||||
Reference in New Issue
Block a user