1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 13:22:19 +01:00

Move esp32_ble_server to its own component (#1898)

This commit is contained in:
Jesse Hills
2021-06-12 08:31:15 +12:00
committed by GitHub
parent eb24da7c82
commit 5a2cfa2798
24 changed files with 192 additions and 146 deletions

View File

@@ -1,4 +1,5 @@
#include "ble.h"
#include "esphome/core/application.h"
#include "esphome/core/log.h"
@@ -26,14 +27,22 @@ void ESP32BLE::setup() {
return;
}
this->advertising_ = new BLEAdvertising();
this->advertising_->set_scan_response(true);
this->advertising_->set_min_preferred_interval(0x06);
this->advertising_->start();
ESP_LOGD(TAG, "BLE setup complete");
}
void ESP32BLE::mark_failed() {
Component::mark_failed();
#ifdef USE_ESP32_BLE_SERVER
if (this->server_ != nullptr) {
this->server_->mark_failed();
}
#endif
}
bool ESP32BLE::ble_setup_() {
@@ -142,7 +151,9 @@ void ESP32BLE::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gat
void ESP32BLE::real_gatts_event_handler_(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,
esp_ble_gatts_cb_param_t *param) {
ESP_LOGV(TAG, "(BLE) gatts_event [esp_gatt_if: %d] - %d", gatts_if, event);
#ifdef USE_ESP32_BLE_SERVER
this->server_->gatts_event_handler(event, gatts_if, param);
#endif
}
void ESP32BLE::real_gattc_event_handler_(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,