8 #ifndef COMPONENTS_CPP_UTILS_BLECHARACTERISTIC_H_ 
    9 #define COMPONENTS_CPP_UTILS_BLECHARACTERISTIC_H_ 
   10 #include "sdkconfig.h" 
   11 #if defined(CONFIG_BT_ENABLED) 
   15 #include <esp_gatts_api.h> 
   16 #include <esp_gap_ble_api.h> 
   17 #include "BLEDescriptor.h" 
   23 class BLECharacteristicCallbacks;
 
   28 class BLEDescriptorMap {
 
   30     void setByUUID(
const char* uuid, BLEDescriptor* pDescriptor);
 
   31     void setByUUID(BLEUUID uuid, BLEDescriptor* pDescriptor);
 
   32     void setByHandle(uint16_t handle, BLEDescriptor* pDescriptor);
 
   33     BLEDescriptor* getByUUID(
const char* uuid);
 
   34     BLEDescriptor* getByUUID(BLEUUID uuid);
 
   35     BLEDescriptor* getByHandle(uint16_t handle);
 
   36     std::string toString();
 
   37     void handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t* param);
 
   38     BLEDescriptor* getFirst();
 
   39     BLEDescriptor* getNext();
 
   41     std::map<BLEDescriptor*, std::string> m_uuidMap;
 
   42     std::map<uint16_t, BLEDescriptor*> m_handleMap;
 
   43     std::map<BLEDescriptor*, std::string>::iterator m_iterator;
 
   53 class BLECharacteristic {
 
   55     BLECharacteristic(
const char* uuid, uint32_t properties = 0);
 
   56     BLECharacteristic(BLEUUID uuid, uint32_t properties = 0);
 
   57     virtual ~BLECharacteristic();
 
   59     void           addDescriptor(BLEDescriptor* pDescriptor);
 
   60     BLEDescriptor* getDescriptorByUUID(
const char* descriptorUUID);
 
   61     BLEDescriptor* getDescriptorByUUID(BLEUUID descriptorUUID);
 
   63     std::string    getValue();
 
   67     void notify(
bool is_notification = 
true);
 
   68     void setBroadcastProperty(
bool value);
 
   69     void setCallbacks(BLECharacteristicCallbacks* pCallbacks);
 
   70     void setIndicateProperty(
bool value);
 
   71     void setNotifyProperty(
bool value);
 
   72     void setReadProperty(
bool value);
 
   73     void setValue(uint8_t* data, 
size_t size);
 
   74     void setValue(std::string value);
 
   75     void setValue(uint16_t& data16);
 
   76     void setValue(uint32_t& data32);
 
   77     void setValue(
int& data32);
 
   78     void setValue(
float& data32);
 
   79     void setValue(
double& data64); 
 
   80     void setWriteProperty(
bool value);
 
   81     void setWriteNoResponseProperty(
bool value);
 
   82     std::string toString();
 
   84     void setAccessPermissions(esp_gatt_perm_t perm);
 
   86     static const uint32_t PROPERTY_READ      = 1<<0;
 
   87     static const uint32_t PROPERTY_WRITE     = 1<<1;
 
   88     static const uint32_t PROPERTY_NOTIFY    = 1<<2;
 
   89     static const uint32_t PROPERTY_BROADCAST = 1<<3;
 
   90     static const uint32_t PROPERTY_INDICATE  = 1<<4;
 
   91     static const uint32_t PROPERTY_WRITE_NR  = 1<<5;
 
   95     friend class BLEServer;
 
   96     friend class BLEService;
 
   97     friend class BLEDescriptor;
 
   98     friend class BLECharacteristicMap;
 
  101     BLEDescriptorMap            m_descriptorMap;
 
  103     esp_gatt_char_prop_t        m_properties;
 
  104     BLECharacteristicCallbacks* m_pCallbacks;
 
  105     BLEService*                 m_pService;
 
  107     esp_gatt_perm_t             m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
 
  109     void handleGATTServerEvent(
 
  110             esp_gatts_cb_event_t      event,
 
  111             esp_gatt_if_t             gatts_if,
 
  112             esp_ble_gatts_cb_param_t* param);
 
  114     void                 executeCreate(BLEService* pService);
 
  115     esp_gatt_char_prop_t getProperties();
 
  116     BLEService*          getService();
 
  117     void                 setHandle(uint16_t handle);
 
  130 class BLECharacteristicCallbacks {
 
  132     virtual ~BLECharacteristicCallbacks();
 
  133     virtual void onRead(BLECharacteristic* pCharacteristic);
 
  134     virtual void onWrite(BLECharacteristic* pCharacteristic);
 
Definition: FreeRTOS.h:31