mirror of
https://github.com/esphome/esphome.git
synced 2025-08-07 10:57:46 +00:00
[esp32_ble] Make BLE notification limit configurable to fix ESP_GATT_NO_RESOURCES errors (#10098)
This commit is contained in:
parent
2b3e546203
commit
5021cc6d5f
@ -118,6 +118,7 @@ CONF_IO_CAPABILITY = "io_capability"
|
|||||||
CONF_ADVERTISING_CYCLE_TIME = "advertising_cycle_time"
|
CONF_ADVERTISING_CYCLE_TIME = "advertising_cycle_time"
|
||||||
CONF_DISABLE_BT_LOGS = "disable_bt_logs"
|
CONF_DISABLE_BT_LOGS = "disable_bt_logs"
|
||||||
CONF_CONNECTION_TIMEOUT = "connection_timeout"
|
CONF_CONNECTION_TIMEOUT = "connection_timeout"
|
||||||
|
CONF_MAX_NOTIFICATIONS = "max_notifications"
|
||||||
|
|
||||||
NO_BLUETOOTH_VARIANTS = [const.VARIANT_ESP32S2]
|
NO_BLUETOOTH_VARIANTS = [const.VARIANT_ESP32S2]
|
||||||
|
|
||||||
@ -173,6 +174,11 @@ CONFIG_SCHEMA = cv.Schema(
|
|||||||
cv.positive_time_period_seconds,
|
cv.positive_time_period_seconds,
|
||||||
cv.Range(min=TimePeriod(seconds=10), max=TimePeriod(seconds=180)),
|
cv.Range(min=TimePeriod(seconds=10), max=TimePeriod(seconds=180)),
|
||||||
),
|
),
|
||||||
|
cv.SplitDefault(CONF_MAX_NOTIFICATIONS, esp32_idf=12): cv.All(
|
||||||
|
cv.only_with_esp_idf,
|
||||||
|
cv.positive_int,
|
||||||
|
cv.Range(min=1, max=64),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
).extend(cv.COMPONENT_SCHEMA)
|
).extend(cv.COMPONENT_SCHEMA)
|
||||||
|
|
||||||
@ -272,6 +278,15 @@ async def to_code(config):
|
|||||||
"CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT", timeout_seconds
|
"CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT", timeout_seconds
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Set the maximum number of notification registrations
|
||||||
|
# This controls how many BLE characteristics can have notifications enabled
|
||||||
|
# across all connections for a single GATT client interface
|
||||||
|
# https://github.com/esphome/issues/issues/6808
|
||||||
|
if CONF_MAX_NOTIFICATIONS in config:
|
||||||
|
add_idf_sdkconfig_option(
|
||||||
|
"CONFIG_BT_GATTC_NOTIF_REG_MAX", config[CONF_MAX_NOTIFICATIONS]
|
||||||
|
)
|
||||||
|
|
||||||
cg.add_define("USE_ESP32_BLE")
|
cg.add_define("USE_ESP32_BLE")
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,11 +355,6 @@ async def to_code(config):
|
|||||||
add_idf_sdkconfig_option(
|
add_idf_sdkconfig_option(
|
||||||
"CONFIG_BTDM_CTRL_BLE_MAX_CONN", config[CONF_MAX_CONNECTIONS]
|
"CONFIG_BTDM_CTRL_BLE_MAX_CONN", config[CONF_MAX_CONNECTIONS]
|
||||||
)
|
)
|
||||||
# CONFIG_BT_GATTC_NOTIF_REG_MAX controls the number of
|
|
||||||
# max notifications in 5.x, setting CONFIG_BT_ACL_CONNECTIONS
|
|
||||||
# is enough in 4.x
|
|
||||||
# https://github.com/esphome/issues/issues/6808
|
|
||||||
add_idf_sdkconfig_option("CONFIG_BT_GATTC_NOTIF_REG_MAX", 9)
|
|
||||||
|
|
||||||
cg.add_define("USE_OTA_STATE_CALLBACK") # To be notified when an OTA update starts
|
cg.add_define("USE_OTA_STATE_CALLBACK") # To be notified when an OTA update starts
|
||||||
cg.add_define("USE_ESP32_BLE_CLIENT")
|
cg.add_define("USE_ESP32_BLE_CLIENT")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user