Roll forward to cl/331498408

Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: If30a8df80799adec3aafba5b8dd4c539fc21e16d
This commit is contained in:
Alexey Polyudov
2020-09-14 02:00:27 -07:00
parent d5bed12d40
commit 3b7071cf0f
41 changed files with 2153 additions and 81 deletions
+11 -5
View File
@@ -182,15 +182,20 @@ BleMedium::~BleMedium() {
}
}
bool BleMedium::StartAdvertising(const std::string& service_id,
const ByteArray& advertisement_bytes) {
bool BleMedium::StartAdvertising(
const std::string& service_id, const ByteArray& advertisement_bytes,
const std::string& fast_advertisement_service_uuid) {
NEARBY_LOGS(INFO) << "G3 Ble StartAdvertising: service_id=" << service_id
<< ", advertisement bytes=" << advertisement_bytes.data()
<< "(" << advertisement_bytes.size() << ")";
<< "(" << advertisement_bytes.size() << "),"
<< " fast advertisement service uuid="
<< fast_advertisement_service_uuid;
auto& env = MediumEnvironment::Instance();
auto& peripheral = adapter_->GetPeripheral();
peripheral.SetAdvertisementBytes(service_id, advertisement_bytes);
env.UpdateBleMediumForAdvertising(*this, peripheral, service_id, true);
bool fast_advertisement = !fast_advertisement_service_uuid.empty();
env.UpdateBleMediumForAdvertising(*this, peripheral, service_id,
fast_advertisement, true);
absl::MutexLock lock(&mutex_);
if (server_socket_ != nullptr) server_socket_.release();
@@ -227,7 +232,8 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
auto& env = MediumEnvironment::Instance();
env.UpdateBleMediumForAdvertising(*this, adapter_->GetPeripheral(),
service_id, false);
service_id, /*fast_advertisement=*/false,
/*enabled=*/false);
accept_loops_runner_.Shutdown();
if (server_socket_ == nullptr) {
NEARBY_LOGS(ERROR) << "G3 Ble StopAdvertising: Failed to find Ble Server "