summaryrefslogtreecommitdiff
path: root/src/BLEDevice.h
blob: acf20f3534240ff69ea2309065d8078cb9c46ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * 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 <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();
static BLEServer* createServer();
static void       dumpDevices();
static BLEScan*   getScan();
static void       init(std::string deviceName);
 
private:
static BLEServer *m_pServer;
static BLEScan   *m_pScan;
static BLEClient *m_pClient;
 
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);
 
public:
static void setPower(esp_power_level_t powerLevel);
 
}// class BLE 
 
#endif // CONFIG_BT_ENABLED 
#endif /* MAIN_BLEDevice_H_ */