ESPHome 2025.9.0-dev
Loading...
Searching...
No Matches
bluetooth_connection.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ESP32
4
6
8
9class BluetoothProxy;
10
12 public:
13 void dump_config() override;
14 void loop() override;
15 bool gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
16 esp_ble_gattc_cb_param_t *param) override;
17 void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override;
19
20 esp_err_t read_characteristic(uint16_t handle);
21 esp_err_t write_characteristic(uint16_t handle, const std::string &data, bool response);
22 esp_err_t read_descriptor(uint16_t handle);
23 esp_err_t write_descriptor(uint16_t handle, const std::string &data, bool response);
24
25 esp_err_t notify_characteristic(uint16_t handle, bool enable);
26
27 void set_address(uint64_t address) override;
28
29 protected:
30 friend class BluetoothProxy;
31
32 bool supports_efficient_uuids_() const;
34 void reset_connection_(esp_err_t reason);
35 void update_allocated_slot_(uint64_t find_value, uint64_t set_value);
36 void log_connection_error_(const char *operation, esp_gatt_status_t status);
37 void log_connection_warning_(const char *operation, esp_err_t err);
38 void log_gatt_not_connected_(const char *action, const char *type);
39 void log_gatt_operation_error_(const char *operation, uint16_t handle, esp_gatt_status_t status);
40 esp_err_t check_and_log_error_(const char *operation, esp_err_t err);
41
42 // Memory optimized layout for 32-bit systems
43 // Group 1: Pointers (4 bytes each, naturally aligned)
45
46 // Group 2: 2-byte types
47 int16_t send_service_{-3}; // -3 = INIT_SENDING_SERVICES, -2 = DONE_SENDING_SERVICES, >=0 = service index
48
49 // Group 3: 1-byte types
51 // 1 byte used, 1 byte padding
52};
53
54} // namespace esphome::bluetooth_proxy
55
56#endif // USE_ESP32
uint8_t address
Definition bl0906.h:4
uint8_t status
Definition bl0942.h:8
void log_connection_error_(const char *operation, esp_gatt_status_t status)
void log_gatt_operation_error_(const char *operation, uint16_t handle, esp_gatt_status_t status)
esp32_ble_tracker::AdvertisementParserType get_advertisement_parser_type() override
esp_err_t write_descriptor(uint16_t handle, const std::string &data, bool response)
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override
bool gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
void log_connection_warning_(const char *operation, esp_err_t err)
esp_err_t write_characteristic(uint16_t handle, const std::string &data, bool response)
esp_err_t check_and_log_error_(const char *operation, esp_err_t err)
esp_err_t notify_characteristic(uint16_t handle, bool enable)
void log_gatt_not_connected_(const char *action, const char *type)
void update_allocated_slot_(uint64_t find_value, uint64_t set_value)
uint8_t type