diff options
author | dakkar <dakkar@thenautilus.net> | 2019-02-22 12:39:08 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2019-02-22 12:39:08 +0000 |
commit | 67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97 (patch) | |
tree | 0f5b064f03372305369a41b10e157aa89552e2f0 /sensor/patchedBLE/src/BLEDevice.h | |
parent | uni-init BLE before sleeping (diff) | |
parent | Merge pull request #23 from tatsutaigu/master (diff) | |
download | thermostat-67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97.tar.gz thermostat-67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97.tar.bz2 thermostat-67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97.zip |
Merge commit 'b232e7f5f0e87f36afbc2f4e03a2c49c48dd47bc'
Diffstat (limited to 'sensor/patchedBLE/src/BLEDevice.h')
-rw-r--r-- | sensor/patchedBLE/src/BLEDevice.h | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/sensor/patchedBLE/src/BLEDevice.h b/sensor/patchedBLE/src/BLEDevice.h index 16c323c..cb4fc17 100644 --- a/sensor/patchedBLE/src/BLEDevice.h +++ b/sensor/patchedBLE/src/BLEDevice.h @@ -22,8 +22,12 @@ #include "BLEAddress.h" /** - * @brief %BLE functions. + * @brief BLE functions. */ +typedef void (*gap_event_handler)(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param); +typedef void (*gattc_event_handler)(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t* param); +typedef void (*gatts_event_handler)(esp_gatts_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gatts_cb_param_t* param); + class BLEDevice { public: @@ -44,16 +48,31 @@ public: 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? + /* move advertising to BLEDevice for saving ram and flash in beacons */ + static BLEAdvertising* getAdvertising(); + static void startAdvertising(); + static uint16_t m_appId; + /* multi connect */ + static std::map<uint16_t, conn_status_t> getPeerDevices(bool client); + static void addPeerDevice(void* peer, bool is_client, uint16_t conn_id); + static void updatePeerDevice(void* peer, bool _client, uint16_t conn_id); + static void removePeerDevice(uint16_t conn_id, bool client); + static BLEClient* getClientByGattIf(uint16_t conn_id); + static void setCustomGapHandler(gap_event_handler handler); + static void setCustomGattcHandler(gattc_event_handler handler); + static void setCustomGattsHandler(gatts_event_handler handler); + static void deinit(bool release_memory = false); + static uint16_t m_localMTU; + static esp_ble_sec_act_t m_securityLevel; private: - static BLEServer *m_pServer; - static BLEScan *m_pScan; - static BLEClient *m_pClient; - static esp_ble_sec_act_t m_securityLevel; + static BLEServer* m_pServer; + static BLEScan* m_pScan; + static BLEClient* m_pClient; static BLESecurityCallbacks* m_securityCallbacks; - static uint16_t m_localMTU; - + static BLEAdvertising* m_bleAdvertising; static esp_gatt_if_t getGattcIF(); + static std::map<uint16_t, conn_status_t> m_connectedClientsMap; static void gattClientEventHandler( esp_gattc_cb_event_t event, @@ -69,6 +88,12 @@ private: esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param); +public: +/* custom gap and gatt handlers for flexibility */ + static gap_event_handler m_customGapHandler; + static gattc_event_handler m_customGattcHandler; + static gatts_event_handler m_customGattsHandler; + }; // class BLE #endif // CONFIG_BT_ENABLED |