3 #include "ble_descriptor.h" 9 #include <unordered_map> 13 #include <esp_gap_ble_api.h> 14 #include <esp_gatt_defs.h> 15 #include <esp_gattc_api.h> 16 #include <esp_gatts_api.h> 17 #include <esp_bt_defs.h> 18 #include <freertos/FreeRTOS.h> 19 #include <freertos/semphr.h> 22 namespace esp32_ble_server {
24 using namespace esp32_ble;
25 using namespace bytebuffer;
26 using namespace event_emitter;
30 namespace BLECharacteristicEvt {
41 public EventEmitter<BLECharacteristicEvt::EmptyEvt, uint16_t> {
47 void set_value(
const std::vector<uint8_t> &buffer);
48 void set_value(
const std::string &buffer);
50 void set_broadcast_property(
bool value);
51 void set_indicate_property(
bool value);
52 void set_notify_property(
bool value);
53 void set_read_property(
bool value);
54 void set_write_property(
bool value);
55 void set_write_no_response_property(
bool value);
60 void do_delete() { this->clients_to_notify_.clear(); }
61 void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
68 std::vector<uint8_t> &
get_value() {
return this->value_; }
70 static const uint32_t PROPERTY_READ = 1 << 0;
71 static const uint32_t PROPERTY_WRITE = 1 << 1;
72 static const uint32_t PROPERTY_NOTIFY = 1 << 2;
73 static const uint32_t PROPERTY_BROADCAST = 1 << 3;
74 static const uint32_t PROPERTY_INDICATE = 1 << 4;
75 static const uint32_t PROPERTY_WRITE_NR = 1 << 5;
81 bool write_event_{
false};
85 uint16_t handle_{0xFFFF};
87 uint16_t value_read_offset_{0};
94 esp_gatt_perm_t permissions_ = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
BLEService * get_service()
std::vector< BLEDescriptor * > descriptors_
A class modelled on the Java ByteBuffer class.
esp_gatt_char_prop_t properties_
std::vector< uint8_t > value_
SemaphoreHandle_t set_value_lock_
std::vector< uint8_t > & get_value()
std::unordered_map< uint16_t, bool > clients_to_notify_
Implementation of SPI Controller mode.