mirror of
https://github.com/esphome/esphome.git
synced 2025-10-20 02:33:50 +01:00
Merge branch 'integration' into memory_api
This commit is contained in:
@@ -99,8 +99,7 @@ bool BLEServer::can_proceed() { return this->is_running() || !this->parent_->is_
|
|||||||
|
|
||||||
void BLEServer::restart_advertising_() {
|
void BLEServer::restart_advertising_() {
|
||||||
if (this->is_running()) {
|
if (this->is_running()) {
|
||||||
this->parent_->advertising_set_manufacturer_data(
|
this->parent_->advertising_set_manufacturer_data(this->manufacturer_data_);
|
||||||
std::span<const uint8_t>(this->manufacturer_data_.get(), this->manufacturer_data_length_));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,11 +35,7 @@ class BLEServer : public Component, public GATTsEventHandler, public BLEStatusEv
|
|||||||
bool is_running();
|
bool is_running();
|
||||||
|
|
||||||
void set_manufacturer_data(const std::vector<uint8_t> &data) {
|
void set_manufacturer_data(const std::vector<uint8_t> &data) {
|
||||||
this->manufacturer_data_length_ = data.size();
|
this->manufacturer_data_ = data;
|
||||||
this->manufacturer_data_.reset(data.empty() ? nullptr : new uint8_t[data.size()]);
|
|
||||||
if (!data.empty()) {
|
|
||||||
memcpy(this->manufacturer_data_.get(), data.data(), data.size());
|
|
||||||
}
|
|
||||||
this->restart_advertising_();
|
this->restart_advertising_();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,27 +87,24 @@ class BLEServer : public Component, public GATTsEventHandler, public BLEStatusEv
|
|||||||
void remove_client_(uint16_t conn_id);
|
void remove_client_(uint16_t conn_id);
|
||||||
void dispatch_callbacks_(CallbackType type, uint16_t conn_id);
|
void dispatch_callbacks_(CallbackType type, uint16_t conn_id);
|
||||||
|
|
||||||
// 4-byte aligned (pointers and vectors on 32-bit)
|
|
||||||
std::vector<CallbackEntry> callbacks_;
|
std::vector<CallbackEntry> callbacks_;
|
||||||
|
|
||||||
|
std::vector<uint8_t> manufacturer_data_{};
|
||||||
|
esp_gatt_if_t gatts_if_{0};
|
||||||
|
bool registered_{false};
|
||||||
|
|
||||||
|
uint16_t clients_[USE_ESP32_BLE_MAX_CONNECTIONS]{};
|
||||||
|
uint8_t client_count_{0};
|
||||||
std::vector<ServiceEntry> services_{};
|
std::vector<ServiceEntry> services_{};
|
||||||
std::vector<BLEService *> services_to_start_{};
|
std::vector<BLEService *> services_to_start_{};
|
||||||
std::unique_ptr<uint8_t[]> manufacturer_data_{};
|
|
||||||
BLEService *device_information_service_{};
|
BLEService *device_information_service_{};
|
||||||
|
|
||||||
// 2-byte aligned
|
|
||||||
uint16_t clients_[USE_ESP32_BLE_MAX_CONNECTIONS]{};
|
|
||||||
|
|
||||||
// 1-byte aligned
|
|
||||||
uint8_t manufacturer_data_length_{0};
|
|
||||||
uint8_t client_count_{0};
|
|
||||||
esp_gatt_if_t gatts_if_{0};
|
|
||||||
enum State : uint8_t {
|
enum State : uint8_t {
|
||||||
INIT = 0x00,
|
INIT = 0x00,
|
||||||
REGISTERING,
|
REGISTERING,
|
||||||
STARTING_SERVICE,
|
STARTING_SERVICE,
|
||||||
RUNNING,
|
RUNNING,
|
||||||
} state_{INIT};
|
} state_{INIT};
|
||||||
bool registered_{false};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
Reference in New Issue
Block a user