mirror of
https://github.com/esphome/esphome.git
synced 2025-08-02 00:17:48 +00:00
safer
This commit is contained in:
parent
9291dc4e27
commit
1f0958e824
@ -32,6 +32,10 @@ std::vector<uint64_t> get_128bit_uuid_vec(esp_bt_uuid_t uuid_source) {
|
|||||||
// This achieves ~97% WiFi MTU utilization while staying under the limit
|
// This achieves ~97% WiFi MTU utilization while staying under the limit
|
||||||
static constexpr size_t FLUSH_BATCH_SIZE = 16;
|
static constexpr size_t FLUSH_BATCH_SIZE = 16;
|
||||||
|
|
||||||
|
// Verify BLE advertisement data array size matches the BLE specification (31 bytes adv + 31 bytes scan response)
|
||||||
|
static_assert(sizeof(((api::BluetoothLERawAdvertisement *) nullptr)->data) == 62,
|
||||||
|
"BLE advertisement data array size mismatch");
|
||||||
|
|
||||||
BluetoothProxy::BluetoothProxy() { global_bluetooth_proxy = this; }
|
BluetoothProxy::BluetoothProxy() { global_bluetooth_proxy = this; }
|
||||||
|
|
||||||
void BluetoothProxy::setup() {
|
void BluetoothProxy::setup() {
|
||||||
@ -77,12 +81,6 @@ bool BluetoothProxy::parse_devices(const esp32_ble::BLEScanResult *scan_results,
|
|||||||
auto &result = scan_results[i];
|
auto &result = scan_results[i];
|
||||||
uint8_t length = result.adv_data_len + result.scan_rsp_len;
|
uint8_t length = result.adv_data_len + result.scan_rsp_len;
|
||||||
|
|
||||||
// Validate length
|
|
||||||
if (length > 62) {
|
|
||||||
ESP_LOGW(TAG, "BLE advertisement too large: %d bytes (max 62)", length);
|
|
||||||
length = 62;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we need to expand the vector
|
// Check if we need to expand the vector
|
||||||
if (this->advertisement_count_ >= advertisements.size()) {
|
if (this->advertisement_count_ >= advertisements.size()) {
|
||||||
if (this->advertisement_pool_.empty()) {
|
if (this->advertisement_pool_.empty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user