summaryrefslogtreecommitdiff
path: root/sensor/patchedBLE/src/BLEDevice.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/BLEDevice.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/BLEDevice.h')
-rw-r--r--sensor/patchedBLE/src/BLEDevice.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/sensor/patchedBLE/src/BLEDevice.h b/sensor/patchedBLE/src/BLEDevice.h
new file mode 100644
index 0000000..7a1b833
--- /dev/null
+++ b/sensor/patchedBLE/src/BLEDevice.h
@@ -0,0 +1,74 @@
+/*
+ * BLEDevice.h
+ *
+ * Created on: Mar 16, 2017
+ * Author: kolban
+ */
+
+#ifndef MAIN_BLEDevice_H_
+#define MAIN_BLEDevice_H_
+#include "sdkconfig.h"
+#if defined(CONFIG_BT_ENABLED)
+#include <esp_gap_ble_api.h> // ESP32 BLE
+#include <esp_gattc_api.h> // ESP32 BLE
+#include <map> // Part of C++ STL
+#include <string>
+#include <esp_bt.h>
+
+#include "BLEServer.h"
+#include "BLEClient.h"
+#include "BLEUtils.h"
+#include "BLEScan.h"
+#include "BLEAddress.h"
+
+/**
+ * @brief %BLE functions.
+ */
+class BLEDevice {
+public:
+
+ static BLEClient* createClient(); // Create a new BLE client.
+ static BLEServer* createServer(); // Cretae a new BLE server.
+ static BLEAddress getAddress(); // Retrieve our own local BD address.
+ static BLEScan* getScan(); // Get the scan object
+ static std::string getValue(BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID characteristicUUID); // Get the value of a characteristic of a service on a server.
+ static void init(std::string deviceName); // Initialize the local BLE environment.
+ static void setPower(esp_power_level_t powerLevel); // Set our power level.
+ static void setValue(BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID characteristicUUID, std::string value); // Set the value of a characteristic on a service on a server.
+ static std::string toString(); // Return a string representation of our device.
+ static void whiteListAdd(BLEAddress address); // Add an entry to the BLE white list.
+ static void whiteListRemove(BLEAddress address); // Remove an entry from the BLE white list.
+ static void setEncryptionLevel(esp_ble_sec_act_t level);
+ static void setSecurityCallbacks(BLESecurityCallbacks* pCallbacks);
+ static esp_err_t setMTU(uint16_t mtu);
+ static uint16_t getMTU();
+ static bool getInitialized(); // Returns the state of the device, is it initialized or not?
+
+private:
+ static BLEServer *m_pServer;
+ static BLEScan *m_pScan;
+ static BLEClient *m_pClient;
+ static esp_ble_sec_act_t m_securityLevel;
+ static BLESecurityCallbacks* m_securityCallbacks;
+ static uint16_t m_localMTU;
+
+ static esp_gatt_if_t getGattcIF();
+
+ static void gattClientEventHandler(
+ esp_gattc_cb_event_t event,
+ esp_gatt_if_t gattc_if,
+ esp_ble_gattc_cb_param_t* param);
+
+ static void gattServerEventHandler(
+ esp_gatts_cb_event_t event,
+ esp_gatt_if_t gatts_if,
+ esp_ble_gatts_cb_param_t* param);
+
+ static void gapEventHandler(
+ esp_gap_ble_cb_event_t event,
+ esp_ble_gap_cb_param_t* param);
+
+}; // class BLE
+
+#endif // CONFIG_BT_ENABLED
+#endif /* MAIN_BLEDevice_H_ */