ESPHome 2025.5.0
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 {
9namespace ble_client {
10
11class BLETextSensorNotifyTrigger : public Trigger<std::string>, public BLETextSensor {
12 public:
13 explicit BLETextSensorNotifyTrigger(BLETextSensor *sensor) { sensor_ = sensor; }
14 void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
15 esp_ble_gattc_cb_param_t *param) override {
16 switch (event) {
17 case ESP_GATTC_SEARCH_CMPL_EVT: {
18 this->sensor_->node_state = espbt::ClientState::ESTABLISHED;
19 break;
20 }
21 case ESP_GATTC_NOTIFY_EVT: {
22 if (param->notify.conn_id != this->sensor_->parent()->get_conn_id() ||
23 param->notify.handle != this->sensor_->handle)
24 break;
25 this->trigger(this->sensor_->parse_data(param->notify.value, param->notify.value_len));
26 }
27 default:
28 break;
29 }
30 }
31
32 protected:
34};
35
36} // namespace ble_client
37} // namespace esphome
38
39#endif
std::string parse_data(uint8_t *value, uint16_t value_len)
BLETextSensorNotifyTrigger(BLETextSensor *sensor)
Definition automation.h:13
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:14
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7