Fixes BLE remote address type when connecting (#3702)

This commit is contained in:
rbaron 2022-08-15 05:09:33 +02:00 committed by Jesse Hills
parent fb8846bb45
commit 8cfcd5904c
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A
2 changed files with 3 additions and 1 deletions

View file

@ -54,6 +54,7 @@ bool BLEClient::parse_device(const espbt::ESPBTDevice &device) {
this->remote_bda[3] = (addr >> 16) & 0xFF; this->remote_bda[3] = (addr >> 16) & 0xFF;
this->remote_bda[4] = (addr >> 8) & 0xFF; this->remote_bda[4] = (addr >> 8) & 0xFF;
this->remote_bda[5] = (addr >> 0) & 0xFF; this->remote_bda[5] = (addr >> 0) & 0xFF;
this->remote_addr_type = device.get_address_type();
return true; return true;
} }
@ -83,7 +84,7 @@ void BLEClient::set_enabled(bool enabled) {
void BLEClient::connect() { void BLEClient::connect() {
ESP_LOGI(TAG, "Attempting BLE connection to %s", this->address_str().c_str()); ESP_LOGI(TAG, "Attempting BLE connection to %s", this->address_str().c_str());
auto ret = esp_ble_gattc_open(this->gattc_if, this->remote_bda, BLE_ADDR_TYPE_PUBLIC, true); auto ret = esp_ble_gattc_open(this->gattc_if, this->remote_bda, this->remote_addr_type, true);
if (ret) { if (ret) {
ESP_LOGW(TAG, "esp_ble_gattc_open error, address=%s status=%d", this->address_str().c_str(), ret); ESP_LOGW(TAG, "esp_ble_gattc_open error, address=%s status=%d", this->address_str().c_str(), ret);
this->set_states_(espbt::ClientState::IDLE); this->set_states_(espbt::ClientState::IDLE);

View file

@ -115,6 +115,7 @@ class BLEClient : public espbt::ESPBTClient, public Component {
int gattc_if; int gattc_if;
esp_bd_addr_t remote_bda; esp_bd_addr_t remote_bda;
esp_ble_addr_type_t remote_addr_type;
uint16_t conn_id; uint16_t conn_id;
uint64_t address; uint64_t address;
bool enabled; bool enabled;