mirror of
https://github.com/esphome/esphome.git
synced 2026-10-14 10:12:52 +00:00
Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e217df8d41 | ||
|
|
003698970e | ||
|
|
f8208b8fc2 | ||
|
|
18ec9dd85b | ||
|
|
f12f5d3a1f | ||
|
|
33a9439d8f | ||
|
|
c0ed06215a | ||
|
|
7235c2a8d6 | ||
|
|
07b8bb53f8 | ||
|
|
6d1cd3f62e | ||
|
|
5cbf994b28 | ||
|
|
6cf30012a5 | ||
|
|
beff1dec4f | ||
|
|
e5e92b1e22 | ||
|
|
f843cc81c6 | ||
|
|
e8e5f6366d | ||
|
|
a00982af2a | ||
|
|
e0e0e3cb8f | ||
|
|
20bda75684 | ||
|
|
8a4959eb6c | ||
|
|
d0bb1e5a98 |
@@ -382,7 +382,7 @@ void BluedroidGattClient::set_disconnecting_() {
|
||||
|
||||
esp_err_t BluedroidGattClient::update_conn_params_(uint16_t min_interval, uint16_t max_interval, uint16_t latency,
|
||||
uint16_t timeout, const char *param_type) {
|
||||
esp_ble_conn_update_params_t conn_params = {{0}};
|
||||
esp_ble_conn_update_params_t conn_params = {};
|
||||
memcpy(conn_params.bda, this->remote_bda_, sizeof(esp_bd_addr_t));
|
||||
conn_params.min_int = min_interval;
|
||||
conn_params.max_int = max_interval;
|
||||
|
||||
@@ -298,7 +298,7 @@ void BLEClientBase::log_warning_(const char *message) {
|
||||
|
||||
esp_err_t BLEClientBase::update_conn_params_(uint16_t min_interval, uint16_t max_interval, uint16_t latency,
|
||||
uint16_t timeout, const char *param_type) {
|
||||
esp_ble_conn_update_params_t conn_params = {{0}};
|
||||
esp_ble_conn_update_params_t conn_params = {};
|
||||
memcpy(conn_params.bda, this->remote_bda_, sizeof(esp_bd_addr_t));
|
||||
conn_params.min_int = min_interval;
|
||||
conn_params.max_int = max_interval;
|
||||
|
||||
@@ -21,6 +21,7 @@ from esphome.components.esp32 import (
|
||||
VARIANT_ESP32S31,
|
||||
add_idf_sdkconfig_option,
|
||||
get_esp32_variant,
|
||||
idf_version,
|
||||
require_usb_serial_jtag_secondary,
|
||||
require_vfs_termios,
|
||||
)
|
||||
@@ -473,6 +474,16 @@ async def _late_logger_init(config: ConfigType) -> None:
|
||||
elif config[CONF_HARDWARE_UART] == USB_SERIAL_JTAG:
|
||||
add_idf_sdkconfig_option("CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG", True)
|
||||
cg.add_define("USE_LOGGER_UART_SELECTION_USB_SERIAL_JTAG")
|
||||
# Log V2 formats centrally in esp_log() (~4KB flash, ~180B RAM). 6.1
|
||||
# adds CONSTRAINED_ENV_SAFE=n, keeping early/DRAM logs on
|
||||
# esp_rom_printf instead of pulling ~1.2KB esp_rom_vprintf into IRAM.
|
||||
if idf_version() >= cv.Version(6, 1, 0):
|
||||
add_idf_sdkconfig_option("CONFIG_LOG_VERSION_1", False)
|
||||
add_idf_sdkconfig_option("CONFIG_LOG_VERSION_2", True)
|
||||
add_idf_sdkconfig_option("CONFIG_LOG_API_CONSTRAINED_ENV_SAFE", False)
|
||||
cg.add_define("USE_ESP32_LOG_V2")
|
||||
# --wrap: a strong definition collides; see logger_esp32.cpp
|
||||
cg.add_build_flag("-Wl,--wrap=esp_log_format")
|
||||
# Define platform support flags for components that need auto-detection
|
||||
try:
|
||||
uart_selection(USB_SERIAL_JTAG)
|
||||
|
||||
@@ -163,4 +163,66 @@ const LogString *Logger::get_uart_selection_() {
|
||||
}
|
||||
|
||||
} // namespace esphome::logger
|
||||
|
||||
// The version guard keeps builds that define USE_ESP32_LOG_V2 unconditionally (static analysis) off
|
||||
// IDF private headers that only 6.1 has
|
||||
#if defined(USE_ESP32_LOG_V2) && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 1, 0)
|
||||
#include <esp_private/log_message.h>
|
||||
#include <esp_log_write.h>
|
||||
#include <esp_rom_sys.h>
|
||||
|
||||
namespace esphome::logger {
|
||||
|
||||
// IDF levels NONE=0 E=1 W=2 I=3 D=4 V=5; ESPHome inserts CONFIG at 4
|
||||
static inline uint8_t idf_to_esphome_level(uint8_t idf_level) {
|
||||
if (idf_level <= 3)
|
||||
return idf_level;
|
||||
return idf_level >= 5 ? ESPHOME_LOG_LEVEL_VERBOSE : ESPHOME_LOG_LEVEL_DEBUG;
|
||||
}
|
||||
|
||||
// Console output without the logger hook: early boot and constrained env
|
||||
// (fwrite locks crash during PHY init on USB JTAG). Cold path.
|
||||
static void __attribute__((noinline)) esp_log_format_direct(esp_log_msg_t *message) {
|
||||
// Constrained-env stacks are small; enough for IDF's own one-liners
|
||||
char stack_buf[256];
|
||||
LogBuffer buf{stack_buf, sizeof(stack_buf)};
|
||||
buf.write_header(idf_to_esphome_level(message->config.opts.log_level), message->tag ? message->tag : "esp-idf", 0,
|
||||
nullptr);
|
||||
buf.format_body(message->format, message->args);
|
||||
esp_rom_printf("%s\n", stack_buf);
|
||||
}
|
||||
|
||||
} // namespace esphome::logger
|
||||
|
||||
extern "C" {
|
||||
// Replaces liblog's formatter, which calls the vprintf hook 3x per message
|
||||
// (header, body, newline). --wrap because a strong definition collides:
|
||||
// liblog resolves the symbol within its own archive. Not IRAM_ATTR: cache-off
|
||||
// callers bypass esp_log() under CONSTRAINED_ENV_SAFE=n.
|
||||
void __wrap_esp_log_format(esp_log_msg_t *message) { // NOLINT
|
||||
extern vprintf_like_t esp_log_vprint_func;
|
||||
if (esp_log_vprint_func == &esphome::esp_idf_log_vprintf_) [[likely]] {
|
||||
if (message->config.opts.constrained_env) [[unlikely]] {
|
||||
esphome::logger::esp_log_format_direct(message);
|
||||
return;
|
||||
}
|
||||
// Call the logger directly with V2's separate tag and severity so lines
|
||||
// render as e.g. "[E][wifi]:"; the hook signature cannot carry them.
|
||||
// global_logger is set before the hook is installed (pre_setup above).
|
||||
esphome::logger::global_logger->log_vprintf_(esphome::logger::idf_to_esphome_level(message->config.opts.log_level),
|
||||
message->tag ? message->tag : "esp-idf", 0, message->format,
|
||||
message->args);
|
||||
return;
|
||||
}
|
||||
extern int vprintf(const char *, __gnuc_va_list); // NOLINT
|
||||
if (esp_log_vprint_func == &vprintf || message->config.opts.constrained_env) {
|
||||
// No hook yet (early boot) or constrained env: direct console output
|
||||
esphome::logger::esp_log_format_direct(message);
|
||||
return;
|
||||
}
|
||||
// Custom hook via esp_log_set_vprintf: forward the body as-is
|
||||
esp_log_vprint_func(message->format, message->args);
|
||||
}
|
||||
} // extern "C"
|
||||
#endif // USE_ESP32_LOG_V2 && IDF >= 6.1
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,7 @@ int NoiseResponderHandshake::init(const NoiseContext &ctx, const uint8_t *prolog
|
||||
.cipher_id = NOISE_CIPHER_CHACHAPOLY,
|
||||
.hash_id = NOISE_HASH_SHA256,
|
||||
.hybrid_id = NOISE_DH_NONE,
|
||||
.reserved = {},
|
||||
};
|
||||
|
||||
int err = noise_handshakestate_new_by_id(&this->handshake_, &nid, NOISE_ROLE_RESPONDER);
|
||||
|
||||
@@ -374,6 +374,7 @@
|
||||
#define USE_ESPNOW_MAX_PAYLOAD_SIZE 1470
|
||||
|
||||
#define USE_CAPTIVE_PORTAL
|
||||
#define USE_ESP32_LOG_V2
|
||||
#define USE_WIFI_SCAN_RESULTS_LOCK
|
||||
#define USE_ESP32_BLE
|
||||
#define USE_ESP32_BLE_MAX_CONNECTIONS 3
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
packages:
|
||||
logger: !include common-default_uart.yaml
|
||||
|
||||
# IDF 6.1 is where Log V2 and the esp_log_format wrap are enabled; the default IDF has no V2
|
||||
esp32:
|
||||
framework:
|
||||
type: esp-idf
|
||||
version: 6.1.0
|
||||
Reference in New Issue
Block a user