summaryrefslogtreecommitdiff
path: root/sensor/patchedBLE/src/BLERemoteCharacteristic.h
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-08-03 12:23:17 +0100
committerdakkar <dakkar@thenautilus.net>2018-08-03 12:23:17 +0100
commitbb00c2da73b6ab8837f50c9f889ee151f8abc036 (patch)
tree3922eb826386260568ccaa1da7056c141f752a97 /sensor/patchedBLE/src/BLERemoteCharacteristic.h
parentdon't print from callback, there's races (diff)
parentUpload of 0.4.16 (diff)
downloadthermostat-bb00c2da73b6ab8837f50c9f889ee151f8abc036.tar.gz
thermostat-bb00c2da73b6ab8837f50c9f889ee151f8abc036.tar.bz2
thermostat-bb00c2da73b6ab8837f50c9f889ee151f8abc036.zip
Add 'sensor/patchedBLE/' from commit '7951347ed68313d75c367e1f2cce763cb56d1eb2'
git-subtree-dir: sensor/patchedBLE git-subtree-mainline: 27e209cf58abeda1dc110777f99a98804a13fdbf git-subtree-split: 7951347ed68313d75c367e1f2cce763cb56d1eb2
Diffstat (limited to 'sensor/patchedBLE/src/BLERemoteCharacteristic.h')
-rw-r--r--sensor/patchedBLE/src/BLERemoteCharacteristic.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/sensor/patchedBLE/src/BLERemoteCharacteristic.h b/sensor/patchedBLE/src/BLERemoteCharacteristic.h
new file mode 100644
index 0000000..6f23f49
--- /dev/null
+++ b/sensor/patchedBLE/src/BLERemoteCharacteristic.h
@@ -0,0 +1,85 @@
+/*
+ * BLERemoteCharacteristic.h
+ *
+ * Created on: Jul 8, 2017
+ * Author: kolban
+ */
+
+#ifndef COMPONENTS_CPP_UTILS_BLEREMOTECHARACTERISTIC_H_
+#define COMPONENTS_CPP_UTILS_BLEREMOTECHARACTERISTIC_H_
+#include "sdkconfig.h"
+#if defined(CONFIG_BT_ENABLED)
+
+#include <string>
+
+#include <esp_gattc_api.h>
+
+#include "BLERemoteService.h"
+#include "BLERemoteDescriptor.h"
+#include "BLEUUID.h"
+#include "FreeRTOS.h"
+
+class BLERemoteService;
+class BLERemoteDescriptor;
+
+/**
+ * @brief A model of a remote %BLE characteristic.
+ */
+class BLERemoteCharacteristic {
+public:
+ ~BLERemoteCharacteristic();
+
+ // Public member functions
+ bool canBroadcast();
+ bool canIndicate();
+ bool canNotify();
+ bool canRead();
+ bool canWrite();
+ bool canWriteNoResponse();
+ BLERemoteDescriptor* getDescriptor(BLEUUID uuid);
+ std::map<std::string, BLERemoteDescriptor *>* getDescriptors();
+ uint16_t getHandle();
+ BLEUUID getUUID();
+ std::string readValue(void);
+ uint8_t readUInt8(void);
+ uint16_t readUInt16(void);
+ uint32_t readUInt32(void);
+ void registerForNotify(void (*notifyCallback)(BLERemoteCharacteristic* pBLERemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify));
+ void writeValue(uint8_t* data, size_t length, bool response = false);
+ void writeValue(std::string newValue, bool response = false);
+ void writeValue(uint8_t newValue, bool response = false);
+ std::string toString(void);
+
+private:
+ BLERemoteCharacteristic(uint16_t handle, BLEUUID uuid, esp_gatt_char_prop_t charProp, BLERemoteService* pRemoteService);
+ friend class BLEClient;
+ friend class BLERemoteService;
+ friend class BLERemoteDescriptor;
+
+ // Private member functions
+ void gattClientEventHandler(
+ esp_gattc_cb_event_t event,
+ esp_gatt_if_t gattc_if,
+ esp_ble_gattc_cb_param_t* evtParam);
+
+
+ BLERemoteService* getRemoteService();
+ void removeDescriptors();
+ void retrieveDescriptors();
+
+ // Private properties
+ BLEUUID m_uuid;
+ esp_gatt_char_prop_t m_charProp;
+ uint16_t m_handle;
+ BLERemoteService* m_pRemoteService;
+ FreeRTOS::Semaphore m_semaphoreReadCharEvt = FreeRTOS::Semaphore("ReadCharEvt");
+ FreeRTOS::Semaphore m_semaphoreRegForNotifyEvt = FreeRTOS::Semaphore("RegForNotifyEvt");
+ FreeRTOS::Semaphore m_semaphoreWriteCharEvt = FreeRTOS::Semaphore("WriteCharEvt");
+ std::string m_value;
+ void (*m_notifyCallback)(BLERemoteCharacteristic* pBLERemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify);
+
+ // We maintain a map of descriptors owned by this characteristic keyed by a string representation of the UUID.
+ std::map<std::string, BLERemoteDescriptor*> m_descriptorMap;
+}; // BLERemoteCharacteristic
+#endif /* CONFIG_BT_ENABLED */
+#endif /* COMPONENTS_CPP_UTILS_BLEREMOTECHARACTERISTIC_H_ */