BLE loop use (#1882)

This commit is contained in:
Jesse Hills
2021-06-10 14:04:39 +12:00
committed by GitHub
parent ea0127e42b
commit 99d90845b5
14 changed files with 272 additions and 165 deletions
+11 -2
View File
@@ -16,22 +16,31 @@ class BLEDescriptor {
public:
BLEDescriptor(ESPBTUUID uuid, uint16_t max_len = 100);
virtual ~BLEDescriptor();
bool do_create(BLECharacteristic *characteristic);
void do_create(BLECharacteristic *characteristic);
void set_value(const std::string &value);
void set_value(const uint8_t *data, size_t length);
void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
bool is_created() { return this->state_ == CREATED; }
bool is_failed() { return this->state_ == FAILED; }
protected:
BLECharacteristic *characteristic_{nullptr};
ESPBTUUID uuid_;
uint16_t handle_{0xFFFF};
SemaphoreHandle_t create_lock_;
esp_attr_value_t value_;
esp_gatt_perm_t permissions_ = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
enum State : uint8_t {
FAILED = 0x00,
INIT,
CREATING,
CREATED,
} state_{INIT};
};
} // namespace esp32_ble