mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 06:36:45 +00:00
[esp32_ble_tracker] Write require feature defines after all clients are registered (#9780)
This commit is contained in:
parent
e56b681506
commit
b17e2019c7
@ -30,7 +30,7 @@ from esphome.const import (
|
|||||||
CONF_SERVICE_UUID,
|
CONF_SERVICE_UUID,
|
||||||
CONF_TRIGGER_ID,
|
CONF_TRIGGER_ID,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
from esphome.enum import StrEnum
|
from esphome.enum import StrEnum
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
@ -365,14 +365,22 @@ async def to_code(config):
|
|||||||
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")
|
||||||
|
|
||||||
# Add feature-specific defines based on what's needed
|
CORE.add_job(_add_ble_features)
|
||||||
if BLEFeatures.ESP_BT_DEVICE in _required_features:
|
|
||||||
cg.add_define("USE_ESP32_BLE_DEVICE")
|
|
||||||
|
|
||||||
if config.get(CONF_SOFTWARE_COEXISTENCE):
|
if config.get(CONF_SOFTWARE_COEXISTENCE):
|
||||||
cg.add_define("USE_ESP32_BLE_SOFTWARE_COEXISTENCE")
|
cg.add_define("USE_ESP32_BLE_SOFTWARE_COEXISTENCE")
|
||||||
|
|
||||||
|
|
||||||
|
# This needs to be run as a job with very low priority so that all components have
|
||||||
|
# chance to call register_ble_tracker and register_client before the list is checked
|
||||||
|
# and added to the global defines list.
|
||||||
|
@coroutine_with_priority(-1000)
|
||||||
|
async def _add_ble_features():
|
||||||
|
# Add feature-specific defines based on what's needed
|
||||||
|
if BLEFeatures.ESP_BT_DEVICE in _required_features:
|
||||||
|
cg.add_define("USE_ESP32_BLE_DEVICE")
|
||||||
|
|
||||||
|
|
||||||
ESP32_BLE_START_SCAN_ACTION_SCHEMA = cv.Schema(
|
ESP32_BLE_START_SCAN_ACTION_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(): cv.use_id(ESP32BLETracker),
|
cv.GenerateID(): cv.use_id(ESP32BLETracker),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user