ESPHome
2024.11.1
esphome
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
{
9
namespace
ble_client {
10
11
class
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
:
33
BLETextSensor
*
sensor_
;
34
};
35
36
}
// namespace ble_client
37
}
// namespace esphome
38
39
#endif
esphome::ble_client::BLETextSensor::parse_data
std::string parse_data(uint8_t *value, uint16_t value_len)
Definition:
ble_text_sensor.cpp:107
esphome::ble_client::BLETextSensor
Definition:
ble_text_sensor.h:16
automation.h
esphome::Trigger< std::string >::trigger
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
Definition:
automation.h:95
esphome::ble_client::BLETextSensor::handle
uint16_t handle
Definition:
ble_text_sensor.h:35
ble_text_sensor.h
esphome::ble_client::BLETextSensorNotifyTrigger::BLETextSensorNotifyTrigger
BLETextSensorNotifyTrigger(BLETextSensor *sensor)
Definition:
automation.h:13
esphome::ble_client::BLETextSensorNotifyTrigger::sensor_
BLETextSensor * sensor_
Definition:
automation.h:33
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:14
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::Trigger
Definition:
automation.h:92
esphome::statsd::sensor
esphome::sensor::Sensor * sensor
Definition:
statsd.h:38
esphome::ble_client::BLETextSensorNotifyTrigger
Definition:
automation.h:11
esphome::ble_client::BLEClientNode::node_state
espbt::ClientState node_state
Definition:
ble_client.h:38
Generated by
1.8.13