Reset ble peripheral with gatt server

The ble_peripheral is invalid when gatt server is unregistered.

PiperOrigin-RevId: 538932998
This commit is contained in:
Janusz Sobczak
2023-06-08 17:24:06 -07:00
committed by Copybara-Service
parent 1c455e3488
commit 0f59872587
+2 -1
View File
@@ -1153,6 +1153,7 @@ void MediumEnvironment::UnregisterGattServer(api::ble_v2::BleMedium& medium) {
}
auto& context = it->second;
context.gatt_server = nullptr;
context.ble_peripheral = nullptr;
});
}
@@ -1165,7 +1166,7 @@ Borrowable<api::ble_v2::GattServer*>* MediumEnvironment::GetGattServer(
const BleV2MediumContext& remote_context = medium_info.second;
const api::ble_v2::BlePeripheral* ble_peripheral =
remote_context.ble_peripheral;
if (ble_peripheral != nullptr &&
if (remote_context.gatt_server != nullptr && ble_peripheral != nullptr &&
(ble_peripheral->GetAddress() == peripheral.GetAddress())) {
if (remote_context.gatt_server == nullptr) {
break;