14#include <esp_gap_ble_api.h>
15#include <esp_gatt_defs.h>
16#include <esp_gattc_api.h>
17#include <esp_gatts_api.h>
18#include <esp_bt_defs.h>
19#include <freertos/FreeRTOS.h>
20#include <freertos/semphr.h>
23namespace esp32_ble_server {
25using namespace esp32_ble;
26using namespace bytebuffer;
36 void set_value(
const std::vector<uint8_t> &buffer);
37 void set_value(
const std::string &buffer);
50 void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
70 void on_write(std::function<
void(std::span<const uint8_t>, uint16_t)> &&callback) {
72 std::make_unique<std::function<void(std::span<const uint8_t>, uint16_t)>>(std::move(callback));
74 void on_read(std::function<
void(uint16_t)> &&callback) {
75 this->
on_read_callback_ = std::make_unique<std::function<void(uint16_t)>>(std::move(callback));
105 esp_gatt_perm_t
permissions_ = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
A class modelled on the Java ByteBuffer class.
void set_broadcast_property(bool value)
ClientNotificationEntry * find_client_in_notify_list_(uint16_t conn_id)
void remove_descriptor(BLEDescriptor *descriptor)
std::unique_ptr< std::function< void(std::span< const uint8_t >, uint16_t)> > on_write_callback_
void set_write_property(bool value)
enum esphome::esp32_ble_server::BLECharacteristic::State INIT
void remove_client_from_notify_list_(uint16_t conn_id)
void set_property_bit_(esp_gatt_char_prop_t bit, bool value)
std::vector< uint8_t > value_
SemaphoreHandle_t set_value_lock_
void set_value(ByteBuffer buffer)
uint16_t value_read_offset_
BLEService * get_service()
BLECharacteristic(ESPBTUUID uuid, uint32_t properties)
void set_notify_property(bool value)
void set_read_property(bool value)
static const uint32_t PROPERTY_WRITE_NR
void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
void on_write(std::function< void(std::span< const uint8_t >, uint16_t)> &&callback)
esp_gatt_perm_t permissions_
static const uint32_t PROPERTY_NOTIFY
static const uint32_t PROPERTY_WRITE
void set_indicate_property(bool value)
std::vector< BLEDescriptor * > descriptors_
static const uint32_t PROPERTY_INDICATE
void set_write_no_response_property(bool value)
void add_descriptor(BLEDescriptor *descriptor)
static const uint32_t PROPERTY_READ
static const uint32_t PROPERTY_BROADCAST
void on_read(std::function< void(uint16_t)> &&callback)
std::vector< ClientNotificationEntry > clients_to_notify_
esp_gatt_char_prop_t properties_
void do_create(BLEService *service)
std::unique_ptr< std::function< void(uint16_t)> > on_read_callback_
std::vector< uint8_t > & get_value()
Providing packet encoding functions for exchanging data with a remote host.