mirror of
https://github.com/esphome/esphome.git
synced 2026-09-04 03:56:04 +00:00
Merge remote-tracking branch 'origin/ble-server-inline-is-active' into integration
This commit is contained in:
@@ -81,8 +81,6 @@ void ESP32BLE::disable() {
|
||||
this->state_ = BLE_COMPONENT_STATE_DISABLE;
|
||||
}
|
||||
|
||||
bool ESP32BLE::is_active() { return this->state_ == BLE_COMPONENT_STATE_ACTIVE; }
|
||||
|
||||
#ifdef USE_ESP32_BLE_ADVERTISING
|
||||
void ESP32BLE::advertising_start() {
|
||||
this->advertising_init_();
|
||||
|
||||
@@ -135,7 +135,7 @@ class ESP32BLE : public Component {
|
||||
|
||||
void enable();
|
||||
void disable();
|
||||
bool is_active();
|
||||
ESPHOME_ALWAYS_INLINE bool is_active() { return this->state_ == BLE_COMPONENT_STATE_ACTIVE; }
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#ifdef USE_ESP32
|
||||
|
||||
#include <algorithm>
|
||||
#include <nvs_flash.h>
|
||||
#include <freertos/FreeRTOSConfig.h>
|
||||
#include <esp_bt_main.h>
|
||||
@@ -39,16 +38,18 @@ void BLEServer::loop() {
|
||||
case RUNNING: {
|
||||
// Start all services that are pending to start
|
||||
if (!this->services_to_start_.empty()) {
|
||||
for (auto &service : this->services_to_start_) {
|
||||
size_t write_idx = 0;
|
||||
for (size_t i = 0; i < this->services_to_start_.size(); i++) {
|
||||
BLEService *service = this->services_to_start_[i];
|
||||
if (service->is_created()) {
|
||||
service->start(); // Needs to be called once per characteristic in the service
|
||||
}
|
||||
// Remove services that have started or are starting
|
||||
if (!service->is_starting() && !service->is_running()) {
|
||||
this->services_to_start_[write_idx++] = service;
|
||||
}
|
||||
}
|
||||
// Remove services that have been started
|
||||
this->services_to_start_.erase(
|
||||
std::remove_if(this->services_to_start_.begin(), this->services_to_start_.end(),
|
||||
[](BLEService *service) { return service->is_starting() || service->is_running(); }),
|
||||
this->services_to_start_.end());
|
||||
this->services_to_start_.erase(this->services_to_start_.begin() + write_idx, this->services_to_start_.end());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -91,8 +92,6 @@ void BLEServer::loop() {
|
||||
}
|
||||
}
|
||||
|
||||
bool BLEServer::is_running() { return this->parent_->is_active() && this->state_ == RUNNING; }
|
||||
|
||||
bool BLEServer::can_proceed() { return this->is_running() || !this->parent_->is_active(); }
|
||||
|
||||
void BLEServer::restart_advertising_() {
|
||||
|
||||
@@ -32,7 +32,7 @@ class BLEServer : public Component, public GATTsEventHandler, public BLEStatusEv
|
||||
float get_setup_priority() const override;
|
||||
bool can_proceed() override;
|
||||
|
||||
bool is_running();
|
||||
ESPHOME_ALWAYS_INLINE bool is_running() { return this->parent_->is_active() && this->state_ == RUNNING; }
|
||||
|
||||
void set_manufacturer_data(const std::vector<uint8_t> &data) {
|
||||
this->manufacturer_data_ = data;
|
||||
|
||||
Reference in New Issue
Block a user