ESPHome  2024.6.6
ble_text_sensor.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #ifdef USE_ESP32
9 #include <esp_gattc_api.h>
10 
11 namespace esphome {
12 namespace ble_client {
13 
15 
17  public:
18  void loop() override;
19  void update() override;
20  void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
21  esp_ble_gattc_cb_param_t *param) override;
22  void dump_config() override;
23  float get_setup_priority() const override { return setup_priority::DATA; }
24  void set_service_uuid16(uint16_t uuid) { this->service_uuid_ = espbt::ESPBTUUID::from_uint16(uuid); }
25  void set_service_uuid32(uint32_t uuid) { this->service_uuid_ = espbt::ESPBTUUID::from_uint32(uuid); }
26  void set_service_uuid128(uint8_t *uuid) { this->service_uuid_ = espbt::ESPBTUUID::from_raw(uuid); }
27  void set_char_uuid16(uint16_t uuid) { this->char_uuid_ = espbt::ESPBTUUID::from_uint16(uuid); }
28  void set_char_uuid32(uint32_t uuid) { this->char_uuid_ = espbt::ESPBTUUID::from_uint32(uuid); }
29  void set_char_uuid128(uint8_t *uuid) { this->char_uuid_ = espbt::ESPBTUUID::from_raw(uuid); }
30  void set_descr_uuid16(uint16_t uuid) { this->descr_uuid_ = espbt::ESPBTUUID::from_uint16(uuid); }
31  void set_descr_uuid32(uint32_t uuid) { this->descr_uuid_ = espbt::ESPBTUUID::from_uint32(uuid); }
32  void set_descr_uuid128(uint8_t *uuid) { this->descr_uuid_ = espbt::ESPBTUUID::from_raw(uuid); }
33  void set_enable_notify(bool notify) { this->notify_ = notify; }
34  std::string parse_data(uint8_t *value, uint16_t value_len);
35  uint16_t handle;
36 
37  protected:
38  bool notify_;
42 };
43 
44 } // namespace ble_client
45 } // namespace esphome
46 #endif
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
std::string parse_data(uint8_t *value, uint16_t value_len)
float get_setup_priority() const override
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void set_service_uuid16(uint16_t uuid)
void set_service_uuid32(uint32_t uuid)
void set_descr_uuid16(uint16_t uuid)
static ESPBTUUID from_uint32(uint32_t uuid)
Definition: ble_uuid.cpp:22
static ESPBTUUID from_uint16(uint16_t uuid)
Definition: ble_uuid.cpp:16
void set_descr_uuid128(uint8_t *uuid)
void set_descr_uuid32(uint32_t uuid)
void set_service_uuid128(uint8_t *uuid)
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
static ESPBTUUID from_raw(const uint8_t *data)
Definition: ble_uuid.cpp:28
void set_char_uuid128(uint8_t *uuid)
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override