8 #ifndef MAIN_BLEDEVICE_H_
9 #define MAIN_BLEDEVICE_H_
11 #include "sdkconfig.h"
12 #if defined(CONFIG_BT_ENABLED)
14 #include <esp_gattc_api.h>
18 #include "BLEExceptions.h"
19 #include "BLERemoteService.h"
20 #include "BLEService.h"
21 #include "BLEAddress.h"
22 #include "BLEAdvertisedDevice.h"
24 class BLERemoteService;
25 class BLEClientCallbacks;
26 class BLEAdvertisedDevice;
36 bool connect(BLEAdvertisedDevice* device);
37 bool connect(BLEAddress address, esp_ble_addr_type_t type = BLE_ADDR_TYPE_PUBLIC);
39 BLEAddress getPeerAddress();
41 std::map<std::string, BLERemoteService*>* getServices();
42 BLERemoteService* getService(
const char* uuid);
43 BLERemoteService* getService(BLEUUID uuid);
44 std::string getValue(BLEUUID serviceUUID, BLEUUID characteristicUUID);
48 esp_gap_ble_cb_event_t event,
49 esp_ble_gap_cb_param_t* param);
53 void setClientCallbacks(BLEClientCallbacks *pClientCallbacks);
54 void setValue(BLEUUID serviceUUID, BLEUUID characteristicUUID, std::string value);
56 std::string toString();
58 esp_gatt_if_t getGattcIf();
63 friend class BLEDevice;
64 friend class BLERemoteService;
65 friend class BLERemoteCharacteristic;
66 friend class BLERemoteDescriptor;
68 void gattClientEventHandler(
69 esp_gattc_cb_event_t event,
70 esp_gatt_if_t gattc_if,
71 esp_ble_gattc_cb_param_t* param);
73 BLEAddress m_peerAddress = BLEAddress((uint8_t*)
"\0\0\0\0\0\0");
76 esp_gatt_if_t m_gattc_if;
77 bool m_haveServices =
false;
78 bool m_isConnected =
false;
80 BLEClientCallbacks* m_pClientCallbacks;
85 std::map<std::string, BLERemoteService*> m_servicesMap;
86 std::map<BLERemoteService*, uint16_t> m_servicesMapByInstID;
95 class BLEClientCallbacks {
97 virtual ~BLEClientCallbacks() {};
98 virtual void onConnect(BLEClient *pClient) = 0;
99 virtual void onDisconnect(BLEClient *pClient) = 0;
102 #endif // CONFIG_BT_ENABLED
Definition: FreeRTOS.h:31