mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
@@ -65,7 +65,13 @@ bool BleMedium::StartScanning(
|
||||
&context.peripheral, &peripheral,
|
||||
peripheral.GetName().c_str());
|
||||
discovered_peripheral_callback_.peripheral_discovered_cb(
|
||||
<<<<<<< HEAD
|
||||
context.peripheral, service_id, fast_advertisement);
|
||||
=======
|
||||
context.peripheral, service_id,
|
||||
context.peripheral.GetAdvertisementBytes(service_id),
|
||||
fast_advertisement);
|
||||
>>>>>>> release
|
||||
}
|
||||
},
|
||||
.peripheral_lost_cb =
|
||||
|
||||
@@ -85,11 +85,20 @@ class BleMedium final {
|
||||
public:
|
||||
using Platform = api::ImplementationPlatform;
|
||||
struct DiscoveredPeripheralCallback {
|
||||
<<<<<<< HEAD
|
||||
std::function<void(BlePeripheral& peripheral,
|
||||
const std::string& service_id,
|
||||
bool fast_advertisement)>
|
||||
peripheral_discovered_cb =
|
||||
DefaultCallback<BlePeripheral&, const std::string&, bool>();
|
||||
=======
|
||||
std::function<void(BlePeripheral& peripheral, const std::string& service_id,
|
||||
const ByteArray& advertisement_bytes,
|
||||
bool fast_advertisement)>
|
||||
peripheral_discovered_cb =
|
||||
DefaultCallback<BlePeripheral&, const std::string&,
|
||||
const ByteArray&, bool>();
|
||||
>>>>>>> release
|
||||
std::function<void(BlePeripheral& peripheral,
|
||||
const std::string& service_id)>
|
||||
peripheral_lost_cb =
|
||||
|
||||
@@ -72,12 +72,20 @@ TEST_F(BleMediumTest, CanStartAdvertising) {
|
||||
fast_advertisement_service_uuid);
|
||||
|
||||
EXPECT_TRUE(ble_b.StartScanning(
|
||||
<<<<<<< HEAD
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
=======
|
||||
service_id, fast_advertisement_service_uuid,
|
||||
>>>>>>> release
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch](
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
const ByteArray& advertisement_bytes,
|
||||
>>>>>>> release
|
||||
bool fast_advertisement) { found_latch.CountDown(); },
|
||||
}));
|
||||
EXPECT_TRUE(found_latch.Await(kWaitDuration).result());
|
||||
@@ -99,12 +107,20 @@ TEST_F(BleMediumTest, CanStartScanning) {
|
||||
CountDownLatch lost_latch(1);
|
||||
|
||||
ble_a.StartScanning(
|
||||
<<<<<<< HEAD
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
=======
|
||||
service_id, fast_advertisement_service_uuid,
|
||||
>>>>>>> release
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch](
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
const ByteArray& advertisement_bytes,
|
||||
>>>>>>> release
|
||||
bool fast_advertisement) { found_latch.CountDown(); },
|
||||
.peripheral_lost_cb =
|
||||
[&lost_latch](BlePeripheral& peripheral,
|
||||
@@ -134,12 +150,20 @@ TEST_F(BleMediumTest, CanStopDiscovery) {
|
||||
CountDownLatch lost_latch(1);
|
||||
|
||||
ble_a.StartScanning(
|
||||
<<<<<<< HEAD
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
=======
|
||||
service_id, fast_advertisement_service_uuid,
|
||||
>>>>>>> release
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch](
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
const ByteArray& advertisement_bytes,
|
||||
>>>>>>> release
|
||||
bool fast_advertisement) { found_latch.CountDown(); },
|
||||
.peripheral_lost_cb =
|
||||
[&lost_latch](BlePeripheral& peripheral,
|
||||
@@ -170,12 +194,20 @@ TEST_F(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
|
||||
|
||||
BlePeripheral* discovered_peripheral = nullptr;
|
||||
ble_a.StartScanning(
|
||||
<<<<<<< HEAD
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
=======
|
||||
service_id, fast_advertisement_service_uuid,
|
||||
>>>>>>> release
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch, &discovered_peripheral](
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
const ByteArray& advertisement_bytes,
|
||||
>>>>>>> release
|
||||
bool fast_advertisement) {
|
||||
NEARBY_LOG(
|
||||
INFO,
|
||||
|
||||
@@ -34,6 +34,12 @@ class Future final {
|
||||
void AddListener(Runnable runnable, api::Executor* executor) {
|
||||
impl_->AddListener(std::move(runnable), executor);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
bool IsSet() const {
|
||||
return impl_->IsSet();
|
||||
}
|
||||
>>>>>>> release
|
||||
|
||||
private:
|
||||
// Instance of future implementation is wrapped in shared_ptr<> to make
|
||||
|
||||
@@ -39,8 +39,14 @@ class SettableFuture : public api::SettableFuture<T> {
|
||||
exception_ = {Exception::kSuccess};
|
||||
completed_.Notify();
|
||||
InvokeAllLocked();
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
return true;
|
||||
=======
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
>>>>>>> release
|
||||
}
|
||||
|
||||
void AddListener(Runnable runnable, api::Executor* executor) override {
|
||||
@@ -52,6 +58,14 @@ class SettableFuture : public api::SettableFuture<T> {
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
bool IsSet() const {
|
||||
MutexLock lock(&mutex_);
|
||||
return done_;
|
||||
}
|
||||
|
||||
>>>>>>> release
|
||||
bool SetException(Exception exception) override {
|
||||
MutexLock lock(&mutex_);
|
||||
return SetExceptionLocked(exception);
|
||||
@@ -108,7 +122,11 @@ class SettableFuture : public api::SettableFuture<T> {
|
||||
listeners_.clear();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
Mutex mutex_;
|
||||
=======
|
||||
mutable Mutex mutex_;
|
||||
>>>>>>> release
|
||||
ConditionVariable completed_{&mutex_};
|
||||
std::vector<std::pair<api::Executor*, std::function<void()>>> listeners_;
|
||||
bool done_{false};
|
||||
|
||||
Reference in New Issue
Block a user