diff options
author | Neil Kolban <kolban1@kolban.com> | 2017-11-21 09:51:03 -0600 |
---|---|---|
committer | Neil Kolban <kolban1@kolban.com> | 2017-11-21 09:51:03 -0600 |
commit | 4a781e01832176d61af010669b8c362f5a777768 (patch) | |
tree | 6a7a16309d61c4728512f5eb632d3ad565288c36 /src/BLEDescriptor.h | |
parent | Fixes for #121 (diff) | |
download | thermostat-4a781e01832176d61af010669b8c362f5a777768.tar.gz thermostat-4a781e01832176d61af010669b8c362f5a777768.tar.bz2 thermostat-4a781e01832176d61af010669b8c362f5a777768.zip |
Updates 2017-11-21 0950
Diffstat (limited to 'src/BLEDescriptor.h')
-rw-r--r-- | src/BLEDescriptor.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/BLEDescriptor.h b/src/BLEDescriptor.h index 1d32d50..4eda4c9 100644 --- a/src/BLEDescriptor.h +++ b/src/BLEDescriptor.h @@ -17,6 +17,7 @@ class BLEService; class BLECharacteristic; +class BLEDescriptorCallbacks; /** * @brief A model of a %BLE descriptor. @@ -27,6 +28,7 @@ public: BLEDescriptor(BLEUUID uuid); virtual ~BLEDescriptor(); + uint16_t getHandle(); size_t getLength(); BLEUUID getUUID(); uint8_t* getValue(); @@ -34,6 +36,7 @@ public: esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t* param); + void setCallbacks(BLEDescriptorCallbacks* pCallbacks); void setValue(uint8_t* data, size_t size); void setValue(std::string value); std::string toString(); @@ -45,10 +48,24 @@ private: esp_attr_value_t m_value; uint16_t m_handle; BLECharacteristic* m_pCharacteristic; + BLEDescriptorCallbacks* m_pCallback; void executeCreate(BLECharacteristic* pCharacteristic); - uint16_t getHandle(); void setHandle(uint16_t handle); FreeRTOS::Semaphore m_semaphoreCreateEvt = FreeRTOS::Semaphore("CreateEvt"); }; + +/** + * @brief Callbacks that can be associated with a %BLE descriptors to inform of events. + * + * When a server application creates a %BLE descriptor, we may wish to be informed when there is either + * a read or write request to the descriptors value. An application can register a + * sub-classed instance of this class and will be notified when such an event happens. + */ +class BLEDescriptorCallbacks { +public: + virtual ~BLEDescriptorCallbacks(); + virtual void onRead(BLEDescriptor* pDescriptor); + virtual void onWrite(BLEDescriptor* pDescriptor); +}; #endif /* CONFIG_BT_ENABLED */ #endif /* COMPONENTS_CPP_UTILS_BLEDESCRIPTOR_H_ */ |