ESPHome 2025.12.1
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
5
6#ifdef USE_ESP32
7
8namespace esphome::ble_client {
9
10class BLETextSensorNotifyTrigger : public Trigger<std::string>, public BLETextSensor {
11 public:
12 explicit BLETextSensorNotifyTrigger(BLETextSensor *sensor) { sensor_ = sensor; }
13 void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
14 esp_ble_gattc_cb_param_t *param) override {
15 switch (event) {
16 case ESP_GATTC_SEARCH_CMPL_EVT: {
17 this->sensor_->node_state = espbt::ClientState::ESTABLISHED;
18 break;
19 }
20 case ESP_GATTC_NOTIFY_EVT: {
21 if (param->notify.conn_id != this->sensor_->parent()->get_conn_id() ||
22 param->notify.handle != this->sensor_->handle)
23 break;
24 this->trigger(this->sensor_->parse_data(param->notify.value, param->notify.value_len));
25 }
26 default:
27 break;
28 }
29 }
30
31 protected:
33};
34
35} // namespace esphome::ble_client
36
37#endif
void trigger(const Ts &...x)
Definition automation.h:204
std::string parse_data(uint8_t *value, uint16_t value_len)
BLETextSensorNotifyTrigger(BLETextSensor *sensor)
Definition automation.h:12
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
Definition automation.h:13