Fix bluetooth_proxy

This commit is contained in:
Rapsssito 2023-11-08 16:30:19 +01:00 committed by Jesse Hills
parent cf22c55430
commit de57f1ad62
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -20,16 +20,21 @@ static const esp_bt_uuid_t NOTIFY_DESC_UUID = {
void BLEClientBase::setup() { void BLEClientBase::setup() {
static uint8_t connection_index = 0; static uint8_t connection_index = 0;
this->connection_index_ = connection_index++; this->connection_index_ = connection_index++;
auto ret = esp_ble_gattc_app_register(this->app_id);
if (ret) {
ESP_LOGE(TAG, "gattc app register failed. app_id=%d code=%d", this->app_id, ret);
this->mark_failed();
}
this->set_state(espbt::ClientState::IDLE);
} }
void BLEClientBase::loop() { void BLEClientBase::loop() {
if (!esp32_ble::global_ble->is_active()) {
this->set_state(espbt::ClientState::INIT);
return;
}
if (this->state_ == espbt::ClientState::INIT) {
auto ret = esp_ble_gattc_app_register(this->app_id);
if (ret) {
ESP_LOGE(TAG, "gattc app register failed. app_id=%d code=%d", this->app_id, ret);
this->mark_failed();
}
this->set_state(espbt::ClientState::IDLE);
}
// READY_TO_CONNECT means we have discovered the device // READY_TO_CONNECT means we have discovered the device
// and the scanner has been stopped by the tracker. // and the scanner has been stopped by the tracker.
if (this->state_ == espbt::ClientState::READY_TO_CONNECT) { if (this->state_ == espbt::ClientState::READY_TO_CONNECT) {