1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-14 17:22:20 +01:00
This commit is contained in:
J. Nick Koston
2025-06-14 23:54:42 -05:00
parent 4cea7f0237
commit f9040ca932
2 changed files with 5 additions and 5 deletions

View File

@@ -23,9 +23,6 @@ namespace esp32_ble {
static const char *const TAG = "esp32_ble"; static const char *const TAG = "esp32_ble";
// Maximum size of the BLE event queue
static constexpr size_t MAX_BLE_QUEUE_SIZE = SCAN_RESULT_BUFFER_SIZE * 2;
static RAMAllocator<BLEEvent> EVENT_ALLOCATOR( // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) static RAMAllocator<BLEEvent> EVENT_ALLOCATOR( // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
RAMAllocator<BLEEvent>::ALLOW_FAILURE | RAMAllocator<BLEEvent>::ALLOC_INTERNAL); RAMAllocator<BLEEvent>::ALLOW_FAILURE | RAMAllocator<BLEEvent>::ALLOC_INTERNAL);
@@ -370,7 +367,7 @@ void ESP32BLE::loop() {
template<typename... Args> void enqueue_ble_event(Args... args) { template<typename... Args> void enqueue_ble_event(Args... args) {
// Check if buffer is full before allocating // Check if buffer is full before allocating
if (global_ble->ble_events_.size() >= MAX_BLE_QUEUE_SIZE) { if (global_ble->ble_events_.size() >= (MAX_BLE_QUEUE_SIZE - 1)) {
// Buffer is full, push will fail and increment dropped count internally // Buffer is full, push will fail and increment dropped count internally
return; return;
} }

View File

@@ -30,6 +30,9 @@ static constexpr uint8_t SCAN_RESULT_BUFFER_SIZE = 32;
static constexpr uint8_t SCAN_RESULT_BUFFER_SIZE = 20; static constexpr uint8_t SCAN_RESULT_BUFFER_SIZE = 20;
#endif #endif
// Maximum size of the BLE event queue
static constexpr size_t MAX_BLE_QUEUE_SIZE = SCAN_RESULT_BUFFER_SIZE * 2;
uint64_t ble_addr_to_uint64(const esp_bd_addr_t address); uint64_t ble_addr_to_uint64(const esp_bd_addr_t address);
// NOLINTNEXTLINE(modernize-use-using) // NOLINTNEXTLINE(modernize-use-using)
@@ -144,7 +147,7 @@ class ESP32BLE : public Component {
std::vector<BLEStatusEventHandler *> ble_status_event_handlers_; std::vector<BLEStatusEventHandler *> ble_status_event_handlers_;
BLEComponentState state_{BLE_COMPONENT_STATE_OFF}; BLEComponentState state_{BLE_COMPONENT_STATE_OFF};
LockFreeQueue<BLEEvent, SCAN_RESULT_BUFFER_SIZE * 2> ble_events_; LockFreeQueue<BLEEvent, MAX_BLE_QUEUE_SIZE> ble_events_;
BLEAdvertising *advertising_{}; BLEAdvertising *advertising_{};
esp_ble_io_cap_t io_cap_{ESP_IO_CAP_NONE}; esp_ble_io_cap_t io_cap_{ESP_IO_CAP_NONE};
uint32_t advertising_cycle_time_{}; uint32_t advertising_cycle_time_{};