-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathBLERemoteDescriptor.h
57 lines (50 loc) · 1.97 KB
/
BLERemoteDescriptor.h
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
/*
* BLERemoteDescriptor.h
*
* Created on: Jul 8, 2017
* Author: kolban
*/
#ifndef COMPONENTS_CPP_UTILS_BLEREMOTEDESCRIPTOR_H_
#define COMPONENTS_CPP_UTILS_BLEREMOTEDESCRIPTOR_H_
#include "soc/soc_caps.h"
#if SOC_BLE_SUPPORTED
#include "sdkconfig.h"
#if defined(CONFIG_BLUEDROID_ENABLED)
#include <string>
#include <esp_gattc_api.h>
#include "BLERemoteCharacteristic.h"
#include "BLEUUID.h"
#include "RTOS.h"
class BLERemoteCharacteristic;
/**
* @brief A model of remote %BLE descriptor.
*/
class BLERemoteDescriptor {
public:
uint16_t getHandle();
BLERemoteCharacteristic *getRemoteCharacteristic();
BLEUUID getUUID();
String readValue(void);
uint8_t readUInt8(void);
uint16_t readUInt16(void);
uint32_t readUInt32(void);
String toString(void);
void writeValue(uint8_t *data, size_t length, bool response = false);
void writeValue(String newValue, bool response = false);
void writeValue(uint8_t newValue, bool response = false);
void setAuth(esp_gatt_auth_req_t auth);
void gattClientEventHandler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *evtParam);
private:
friend class BLERemoteCharacteristic;
BLERemoteDescriptor(uint16_t handle, BLEUUID uuid, BLERemoteCharacteristic *pRemoteCharacteristic);
uint16_t m_handle; // Server handle of this descriptor.
BLEUUID m_uuid; // UUID of this descriptor.
String m_value; // Last received value of the descriptor.
BLERemoteCharacteristic *m_pRemoteCharacteristic; // Reference to the Remote characteristic of which this descriptor is associated.
FreeRTOS::Semaphore m_semaphoreReadDescrEvt = FreeRTOS::Semaphore("ReadDescrEvt");
FreeRTOS::Semaphore m_semaphoreWriteDescrEvt = FreeRTOS::Semaphore("WriteDescrEvt");
esp_gatt_auth_req_t m_auth;
};
#endif /* CONFIG_BLUEDROID_ENABLED */
#endif /* SOC_BLE_SUPPORTED */
#endif /* COMPONENTS_CPP_UTILS_BLEREMOTEDESCRIPTOR_H_ */