mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Merge branch 'master' into release
This commit is contained in:
@@ -31,8 +31,10 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
return impl_->StopAdvertising(service_id);
|
||||
}
|
||||
|
||||
bool BleMedium::StartScanning(const std::string& service_id,
|
||||
DiscoveredPeripheralCallback callback) {
|
||||
bool BleMedium::StartScanning(
|
||||
const std::string& service_id,
|
||||
const std::string& fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback callback) {
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
discovered_peripheral_callback_ = std::move(callback);
|
||||
@@ -40,6 +42,7 @@ bool BleMedium::StartScanning(const std::string& service_id,
|
||||
}
|
||||
return impl_->StartScanning(
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
{
|
||||
.peripheral_discovered_cb =
|
||||
[this](api::BlePeripheral& peripheral,
|
||||
|
||||
@@ -120,6 +120,7 @@ class BleMedium final {
|
||||
|
||||
// Returns true once the BLE scan has been initiated.
|
||||
bool StartScanning(const std::string& service_id,
|
||||
const std::string& fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback callback);
|
||||
|
||||
// Returns true once BLE scanning for service_id is well and truly stopped;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace {
|
||||
constexpr absl::Duration kWaitDuration = absl::Milliseconds(1000);
|
||||
constexpr absl::string_view kServiceID{"com.google.location.nearby.apps.test"};
|
||||
constexpr absl::string_view kAdvertisementString{"\x0a\x0b\x0c\x0d"};
|
||||
constexpr absl::string_view kFastAdvertisementServiceUuid{"\xff\xfe"};
|
||||
constexpr absl::string_view kFastAdvertisementServiceUuid{"\xf3\xfe"};
|
||||
|
||||
class BleMediumTest : public ::testing::Test {
|
||||
protected:
|
||||
@@ -73,6 +73,7 @@ TEST_F(BleMediumTest, CanStartAdvertising) {
|
||||
|
||||
EXPECT_TRUE(ble_b.StartScanning(
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch](
|
||||
@@ -99,6 +100,7 @@ TEST_F(BleMediumTest, CanStartScanning) {
|
||||
|
||||
ble_a.StartScanning(
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch](
|
||||
@@ -133,6 +135,7 @@ TEST_F(BleMediumTest, CanStopDiscovery) {
|
||||
|
||||
ble_a.StartScanning(
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch](
|
||||
@@ -168,6 +171,7 @@ TEST_F(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
|
||||
BlePeripheral* discovered_peripheral = nullptr;
|
||||
ble_a.StartScanning(
|
||||
service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback{
|
||||
.peripheral_discovered_cb =
|
||||
[&found_latch, &discovered_peripheral](
|
||||
|
||||
@@ -202,8 +202,8 @@ class BluetoothClassicMedium final {
|
||||
api::BluetoothClassicMedium& GetImpl() { return *impl_; }
|
||||
BluetoothAdapter& GetAdapter() { return adapter_; }
|
||||
std::string GetMacAddress() const { return adapter_.GetMacAddress(); }
|
||||
BluetoothDevice FindRemoteDevice(const std::string& mac_address) {
|
||||
return BluetoothDevice(impl_->FindRemoteDevice(mac_address));
|
||||
BluetoothDevice GetRemoteDevice(const std::string& mac_address) {
|
||||
return BluetoothDevice(impl_->GetRemoteDevice(mac_address));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user