mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 14:43:51 +00:00
Bluetooth advertising automation (#995)
* esp32_ble_tracker: introduce UUID comparison function * ble_presence, ble_rssi: use new UUID comparison function * esp32_ble_tracker: introduce automation on BLE advertising * test2.yaml: remove deep_sleep due to firmware size restrictions
This commit is contained in:
@@ -43,35 +43,10 @@ class BLEPresenceDevice : public binary_sensor::BinarySensorInitiallyOff,
|
||||
}
|
||||
} else {
|
||||
for (auto uuid : device.get_service_uuids()) {
|
||||
switch (this->uuid_.get_uuid().len) {
|
||||
case ESP_UUID_LEN_16:
|
||||
if (uuid.get_uuid().len == ESP_UUID_LEN_16 &&
|
||||
uuid.get_uuid().uuid.uuid16 == this->uuid_.get_uuid().uuid.uuid16) {
|
||||
this->publish_state(true);
|
||||
this->found_ = true;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case ESP_UUID_LEN_32:
|
||||
if (uuid.get_uuid().len == ESP_UUID_LEN_32 &&
|
||||
uuid.get_uuid().uuid.uuid32 == this->uuid_.get_uuid().uuid.uuid32) {
|
||||
this->publish_state(true);
|
||||
this->found_ = true;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case ESP_UUID_LEN_128:
|
||||
if (uuid.get_uuid().len == ESP_UUID_LEN_128) {
|
||||
for (int i = 0; i < ESP_UUID_LEN_128; i++) {
|
||||
if (this->uuid_.get_uuid().uuid.uuid128[i] != uuid.get_uuid().uuid.uuid128[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this->publish_state(true);
|
||||
this->found_ = true;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
if (this->uuid_ == uuid) {
|
||||
this->publish_state(device.get_rssi());
|
||||
this->found_ = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user