ESPHome
2025.12.1
Loading...
Searching...
No Matches
esphome
components
ble_client
text_sensor
automation.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/automation.h
"
4
#include "
esphome/components/ble_client/text_sensor/ble_text_sensor.h
"
5
6
#ifdef USE_ESP32
7
8
namespace
esphome::ble_client
{
9
10
class
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
:
32
BLETextSensor
*
sensor_
;
33
};
34
35
}
// namespace esphome::ble_client
36
37
#endif
ble_text_sensor.h
esphome::Trigger
Definition
automation.h:201
esphome::Trigger< std::string >::trigger
void trigger(const Ts &...x)
Definition
automation.h:204
esphome::ble_client::BLEClientNode::node_state
espbt::ClientState node_state
Definition
ble_client.h:37
esphome::ble_client::BLETextSensor
Definition
ble_text_sensor.h:15
esphome::ble_client::BLETextSensor::parse_data
std::string parse_data(uint8_t *value, uint16_t value_len)
Definition
ble_text_sensor.cpp:116
esphome::ble_client::BLETextSensorNotifyTrigger
Definition
automation.h:10
esphome::ble_client::BLETextSensorNotifyTrigger::BLETextSensorNotifyTrigger
BLETextSensorNotifyTrigger(BLETextSensor *sensor)
Definition
automation.h:12
esphome::ble_client::BLETextSensorNotifyTrigger::sensor_
BLETextSensor * sensor_
Definition
automation.h:32
esphome::ble_client::BLETextSensorNotifyTrigger::gattc_event_handler
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
automation.h
esphome::ble_client
Definition
automation.cpp:5
Generated by
1.12.0