mirror of
https://github.com/esphome/esphome.git
synced 2025-09-26 15:12:21 +01:00
more
This commit is contained in:
@@ -424,13 +424,17 @@ void load_ble_event(BLEEvent *event, esp_gap_ble_cb_event_t e, esp_ble_gap_cb_pa
|
|||||||
event->load_gap_event(e, p);
|
event->load_gap_event(e, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_ESP32_BLE_CLIENT
|
||||||
void load_ble_event(BLEEvent *event, esp_gattc_cb_event_t e, esp_gatt_if_t i, esp_ble_gattc_cb_param_t *p) {
|
void load_ble_event(BLEEvent *event, esp_gattc_cb_event_t e, esp_gatt_if_t i, esp_ble_gattc_cb_param_t *p) {
|
||||||
event->load_gattc_event(e, i, p);
|
event->load_gattc_event(e, i, p);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_ESP32_BLE_SERVER
|
||||||
void load_ble_event(BLEEvent *event, esp_gatts_cb_event_t e, esp_gatt_if_t i, esp_ble_gatts_cb_param_t *p) {
|
void load_ble_event(BLEEvent *event, esp_gatts_cb_event_t e, esp_gatt_if_t i, esp_ble_gatts_cb_param_t *p) {
|
||||||
event->load_gatts_event(e, i, p);
|
event->load_gatts_event(e, i, p);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename... Args> void enqueue_ble_event(Args... args) {
|
template<typename... Args> void enqueue_ble_event(Args... args) {
|
||||||
// Allocate an event from the pool
|
// Allocate an event from the pool
|
||||||
@@ -451,8 +455,12 @@ template<typename... Args> void enqueue_ble_event(Args... args) {
|
|||||||
|
|
||||||
// Explicit template instantiations for the friend function
|
// Explicit template instantiations for the friend function
|
||||||
template void enqueue_ble_event(esp_gap_ble_cb_event_t, esp_ble_gap_cb_param_t *);
|
template void enqueue_ble_event(esp_gap_ble_cb_event_t, esp_ble_gap_cb_param_t *);
|
||||||
|
#ifdef USE_ESP32_BLE_SERVER
|
||||||
template void enqueue_ble_event(esp_gatts_cb_event_t, esp_gatt_if_t, esp_ble_gatts_cb_param_t *);
|
template void enqueue_ble_event(esp_gatts_cb_event_t, esp_gatt_if_t, esp_ble_gatts_cb_param_t *);
|
||||||
|
#endif
|
||||||
|
#ifdef USE_ESP32_BLE_CLIENT
|
||||||
template void enqueue_ble_event(esp_gattc_cb_event_t, esp_gatt_if_t, esp_ble_gattc_cb_param_t *);
|
template void enqueue_ble_event(esp_gattc_cb_event_t, esp_gatt_if_t, esp_ble_gattc_cb_param_t *);
|
||||||
|
#endif
|
||||||
|
|
||||||
void ESP32BLE::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) {
|
void ESP32BLE::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
@@ -74,17 +74,21 @@ class GAPScanEventHandler {
|
|||||||
virtual void gap_scan_event_handler(const BLEScanResult &scan_result) = 0;
|
virtual void gap_scan_event_handler(const BLEScanResult &scan_result) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef USE_ESP32_BLE_CLIENT
|
||||||
class GATTcEventHandler {
|
class GATTcEventHandler {
|
||||||
public:
|
public:
|
||||||
virtual void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
|
virtual void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
|
||||||
esp_ble_gattc_cb_param_t *param) = 0;
|
esp_ble_gattc_cb_param_t *param) = 0;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_ESP32_BLE_SERVER
|
||||||
class GATTsEventHandler {
|
class GATTsEventHandler {
|
||||||
public:
|
public:
|
||||||
virtual void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,
|
virtual void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,
|
||||||
esp_ble_gatts_cb_param_t *param) = 0;
|
esp_ble_gatts_cb_param_t *param) = 0;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
class BLEStatusEventHandler {
|
class BLEStatusEventHandler {
|
||||||
public:
|
public:
|
||||||
@@ -123,8 +127,12 @@ class ESP32BLE : public Component {
|
|||||||
void register_gap_scan_event_handler(GAPScanEventHandler *handler) {
|
void register_gap_scan_event_handler(GAPScanEventHandler *handler) {
|
||||||
this->gap_scan_event_handlers_.push_back(handler);
|
this->gap_scan_event_handlers_.push_back(handler);
|
||||||
}
|
}
|
||||||
|
#ifdef USE_ESP32_BLE_CLIENT
|
||||||
void register_gattc_event_handler(GATTcEventHandler *handler) { this->gattc_event_handlers_.push_back(handler); }
|
void register_gattc_event_handler(GATTcEventHandler *handler) { this->gattc_event_handlers_.push_back(handler); }
|
||||||
|
#endif
|
||||||
|
#ifdef USE_ESP32_BLE_SERVER
|
||||||
void register_gatts_event_handler(GATTsEventHandler *handler) { this->gatts_event_handlers_.push_back(handler); }
|
void register_gatts_event_handler(GATTsEventHandler *handler) { this->gatts_event_handlers_.push_back(handler); }
|
||||||
|
#endif
|
||||||
void register_ble_status_event_handler(BLEStatusEventHandler *handler) {
|
void register_ble_status_event_handler(BLEStatusEventHandler *handler) {
|
||||||
this->ble_status_event_handlers_.push_back(handler);
|
this->ble_status_event_handlers_.push_back(handler);
|
||||||
}
|
}
|
||||||
@@ -152,8 +160,12 @@ class ESP32BLE : public Component {
|
|||||||
// Vectors (12 bytes each on 32-bit, naturally aligned to 4 bytes)
|
// Vectors (12 bytes each on 32-bit, naturally aligned to 4 bytes)
|
||||||
std::vector<GAPEventHandler *> gap_event_handlers_;
|
std::vector<GAPEventHandler *> gap_event_handlers_;
|
||||||
std::vector<GAPScanEventHandler *> gap_scan_event_handlers_;
|
std::vector<GAPScanEventHandler *> gap_scan_event_handlers_;
|
||||||
|
#ifdef USE_ESP32_BLE_CLIENT
|
||||||
std::vector<GATTcEventHandler *> gattc_event_handlers_;
|
std::vector<GATTcEventHandler *> gattc_event_handlers_;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_ESP32_BLE_SERVER
|
||||||
std::vector<GATTsEventHandler *> gatts_event_handlers_;
|
std::vector<GATTsEventHandler *> gatts_event_handlers_;
|
||||||
|
#endif
|
||||||
std::vector<BLEStatusEventHandler *> ble_status_event_handlers_;
|
std::vector<BLEStatusEventHandler *> ble_status_event_handlers_;
|
||||||
|
|
||||||
// Large objects (size depends on template parameters, but typically aligned to 4 bytes)
|
// Large objects (size depends on template parameters, but typically aligned to 4 bytes)
|
||||||
|
Reference in New Issue
Block a user