Merge remote-tracking branch 'nearby/main' into apply-upstream

# Conflicts:
#	MODULE.bazel
#	connections/implementation/mediums/ble_v2.cc
#	internal/platform/implementation/BUILD
This commit is contained in:
kidfromjupiter
2026-02-04 19:12:40 +00:00
1278 changed files with 930060 additions and 211365 deletions
@@ -275,7 +275,7 @@ Exception BleL2capOutputStream::Close() {
}
BleL2capSocket::BleL2capSocket(int fd,
api::ble_v2::BlePeripheral::UniqueId peripheral_id)
api::ble::BlePeripheral::UniqueId peripheral_id)
: peripheral_id_(peripheral_id),
input_stream_(std::make_unique<BleL2capInputStream>(fd)),
output_stream_(std::make_unique<BleL2capOutputStream>(fd))
@@ -21,7 +21,7 @@
#include "absl/functional/any_invocable.h"
#include "absl/synchronization/mutex.h"
#include "internal/platform/exception.h"
#include "internal/platform/implementation/ble_v2.h"
#include "internal/platform/implementation/ble.h"
#include "internal/platform/input_stream.h"
#include "internal/platform/output_stream.h"
@@ -1,33 +0,0 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "internal/platform/implementation/linux/ble_medium.h"
#include <memory>
#include <string>
#include "absl/synchronization/mutex.h"
#include "internal/platform/implementation/ble.h"
#include "internal/platform/implementation/ble_v2.h"
#include "internal/platform/implementation/linux/ble_v2_medium.h"
#include "internal/platform/implementation/linux/bluetooth_adapter.h"
#include "internal/platform/logging.h"
#include "internal/platform/uuid.h"
namespace nearby {
namespace linux {
} // namespace linux
} // namespace nearby
@@ -1,73 +0,0 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef PLATFORM_IMPL_LINUX_API_BLE_MEDIUM_H_
#define PLATFORM_IMPL_LINUX_API_BLE_MEDIUM_H_
#include "internal/platform/implementation/ble.h"
namespace nearby {
namespace linux {
// Container of operations that can be performed over the BLE medium.
class BleMedium : public api::BleMedium {
public:
BleMedium() {}
~BleMedium() = default;
bool StartAdvertising(
const std::string &service_id, const ByteArray &advertisement_bytes,
const std::string &fast_advertisement_service_uuid) override {
return false;
}
bool StopAdvertising(const std::string &service_id) override { return false; }
// 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) override {
return false;
}
// Returns true once BLE scanning for service_id is well and truly stopped;
// after this returns, there must be no more invocations of the
// DiscoveredPeripheralCallback passed in to StartScanning() for service_id.
bool StopScanning(const std::string &service_id) override { return false; }
// Callback that is invoked when a new connection is accepted.
using AcceptedConnectionCallback = absl::AnyInvocable<void(
api::BleSocket &socket, const std::string &service_id)>;
// Returns true once BLE socket connection requests to service_id can be
// accepted.
bool StartAcceptingConnections(const std::string &service_id,
AcceptedConnectionCallback callback) override {
return false;
}
bool StopAcceptingConnections(const std::string &service_id) override {
return false;
}
// Connects to a BLE peripheral.
// On success, returns a new BleSocket.
// On error, returns nullptr.
std::unique_ptr<api::BleSocket> Connect(
api::BlePeripheral &peripheral, const std::string &service_id,
CancellationFlag *cancellation_flag) override {
return nullptr;
}
};
} // namespace linux
} // namespace nearby
#endif
@@ -26,7 +26,7 @@
#include <sdbus-c++/Types.h>
#include "absl/synchronization/mutex.h"
#include "internal/platform/implementation/ble_v2.h"
#include "internal/platform/implementation/ble.h"
// #include "internal/platform/implementation/linux/ble_gatt_client.h"
// #include "internal/platform/implementation/linux/ble_gatt_server.h"
#include "internal/platform/implementation/linux/ble_v2_medium.h"
@@ -86,8 +86,8 @@ BleV2Medium::BleV2Medium(BluetoothAdapter &adapter)
// called twice. Once with extended regular advertisement ( when IsExtendedAdvertisementsAvailable() == true )
// and another for GATT-backed header advertisement for legacy devices
bool BleV2Medium::StartAdvertising(
const api::ble_v2::BleAdvertisementData &advertising_data,
api::ble_v2::AdvertiseParameters advertise_set_parameters) {
const api::ble::BleAdvertisementData &advertising_data,
api::ble::AdvertiseParameters advertise_set_parameters) {
if (!advertising_data.is_extended_advertisement)
{
// can't send two LE advertisements at the same
@@ -128,10 +128,10 @@ BleV2Medium::BleV2Medium(BluetoothAdapter &adapter)
//async api
// this doesn't run. wonder why
std::unique_ptr<api::ble_v2::BleMedium::AdvertisingSession>
std::unique_ptr<api::ble::BleMedium::AdvertisingSession>
BleV2Medium::StartAdvertising(
const api::ble_v2::BleAdvertisementData &advertising_data,
api::ble_v2::AdvertiseParameters advertise_set_parameters,
const api::ble::BleAdvertisementData &advertising_data,
api::ble::AdvertiseParameters advertise_set_parameters,
AdvertisingCallback callback) {
if (!adapter_.IsEnabled()) {
LOG(WARNING) << ": BLE cannot start advertising because the "
@@ -204,8 +204,8 @@ BleV2Medium::StartAdvertising(
advs_.erase(adv_it);
return absl::OkStatus();
};
return std::make_unique<api::ble_v2::BleMedium::AdvertisingSession>(
api::ble_v2::BleMedium::AdvertisingSession{std::move(stop_adv)});
return std::make_unique<api::ble::BleMedium::AdvertisingSession>(
api::ble::BleMedium::AdvertisingSession{std::move(stop_adv)});
}
bool BleV2Medium::StopAdvertising() {
@@ -225,7 +225,7 @@ BleV2Medium::StartAdvertising(
}
bool BleV2Medium::StartScanning(const Uuid &service_uuid,
api::ble_v2::TxPowerLevel tx_power_level,
api::ble::TxPowerLevel tx_power_level,
ScanCallback callback) {
if (cur_monitored_service_uuid_.has_value()) {
LOG(ERROR) << __func__
@@ -339,9 +339,9 @@ bool BleV2Medium::StopScanning() {
return true;
}
std::unique_ptr<api::ble_v2::BleMedium::ScanningSession>
std::unique_ptr<api::ble::BleMedium::ScanningSession>
BleV2Medium::StartScanning(const Uuid &service_uuid,
api::ble_v2::TxPowerLevel tx_power_level,
api::ble::TxPowerLevel tx_power_level,
ScanningCallback callback) {
if (adv_monitor_manager_ == nullptr) {
// TODO: Implement manual monitoring.
@@ -429,8 +429,8 @@ bool BleV2Medium::StopScanning() {
}});
}
std::unique_ptr<api::ble_v2::GattServer> BleV2Medium::StartGattServer(
api::ble_v2::ServerGattConnectionCallback callback) {
std::unique_ptr<api::ble::GattServer> BleV2Medium::StartGattServer(
api::ble::ServerGattConnectionCallback callback) {
// (void)callback;
// return nullptr;
@@ -439,10 +439,10 @@ std::unique_ptr<api::ble_v2::GattServer> BleV2Medium::StartGattServer(
);
}
std::unique_ptr<api::ble_v2::GattClient> BleV2Medium::ConnectToGattServer(
api::ble_v2::BlePeripheral::UniqueId peripheral_id,
api::ble_v2::TxPowerLevel tx_power_level,
api::ble_v2::ClientGattConnectionCallback callback) {
std::unique_ptr<api::ble::GattClient> BleV2Medium::ConnectToGattServer(
api::ble::BlePeripheral::UniqueId peripheral_id,
api::ble::TxPowerLevel tx_power_level,
api::ble::ClientGattConnectionCallback callback) {
(void)peripheral_id;
(void)tx_power_level;
(void)callback;
@@ -451,14 +451,14 @@ std::unique_ptr<api::ble_v2::GattClient> BleV2Medium::ConnectToGattServer(
return nullptr;
}
std::unique_ptr<api::ble_v2::BleServerSocket> BleV2Medium::OpenServerSocket(
std::unique_ptr<api::ble::BleServerSocket> BleV2Medium::OpenServerSocket(
const std::string &service_id) {
LOG(INFO) << __func__ << ": Opening BLE server socket for service "
<< service_id;
return std::make_unique<BleV2ServerSocket>(service_id);
}
std::unique_ptr<api::ble_v2::BleL2capServerSocket>
std::unique_ptr<api::ble::BleL2capServerSocket>
BleV2Medium::OpenL2capServerSocket(const std::string &service_id) {
// return nullptr;
LOG(INFO) << __func__ << ": Opening L2CAP server socket for service "
@@ -474,9 +474,9 @@ BleV2Medium::OpenL2capServerSocket(const std::string &service_id) {
}
// This is supposed to be for a socket on top of Weave protocol.
std::unique_ptr<api::ble_v2::BleSocket> BleV2Medium::Connect(
const std::string &service_id, api::ble_v2::TxPowerLevel tx_power_level,
api::ble_v2::BlePeripheral::UniqueId peripheral_id,
std::unique_ptr<api::ble::BleSocket> BleV2Medium::Connect(
const std::string &service_id, api::ble::TxPowerLevel tx_power_level,
api::ble::BlePeripheral::UniqueId peripheral_id,
CancellationFlag *cancellation_flag) {
LOG(INFO) << __func__ << ": Not implemented on linux ";
return nullptr;
@@ -519,18 +519,18 @@ bool BleV2Medium::StartLEDiscovery() {
return true;
}
// std::unique_ptr<api::ble_v2::BleSocket> BleV2Medium::Connect(
// const std::string &service_id, api::ble_v2::TxPowerLevel tx_power_level,
// api::ble_v2::BlePeripheral &peripheral,
// std::unique_ptr<api::ble::BleSocket> BleV2Medium::Connect(
// const std::string &service_id, api::ble::TxPowerLevel tx_power_level,
// api::ble::BlePeripheral &peripheral,
// CancellationFlag *cancellation_flag) {
// LOG(WARNING) << __func__ << ": BLE socket connections not implemented on Linux";
// return nullptr;
// }
std::unique_ptr<api::ble_v2::BleL2capSocket> BleV2Medium::ConnectOverL2cap(
std::unique_ptr<api::ble::BleL2capSocket> BleV2Medium::ConnectOverL2cap(
int psm, const std::string &service_id,
api::ble_v2::TxPowerLevel tx_power_level,
api::ble_v2::BlePeripheral::UniqueId peripheral_id,
api::ble::TxPowerLevel tx_power_level,
api::ble::BlePeripheral::UniqueId peripheral_id,
CancellationFlag *cancellation_flag) {
// return nullptr;
auto device = devices_->get_device_by_unique_id(peripheral_id);
@@ -595,7 +595,7 @@ std::unique_ptr<api::ble_v2::BleL2capSocket> BleV2Medium::ConnectOverL2cap(
bool BleV2Medium::StartMultipleServicesScanning(
const std::vector<Uuid> &service_uuids,
api::ble_v2::TxPowerLevel tx_power_level, ScanCallback callback) {
api::ble::TxPowerLevel tx_power_level, ScanCallback callback) {
LOG(WARNING) << __func__
<< ": Multiple services scanning not implemented on Linux. "
<< "Use single service scanning instead.";
@@ -618,7 +618,7 @@ void BleV2Medium::AddAlternateUuidForService(uint16_t uuid,
<< uuid << ", service_id: " << service_id;
}
std::optional<api::ble_v2::BlePeripheral::UniqueId>
std::optional<api::ble::BlePeripheral::UniqueId>
BleV2Medium::RetrieveBlePeripheralIdFromNativeId(
const std::string &ble_peripheral_native_id) {
LOG(WARNING) << __func__
@@ -24,7 +24,7 @@
#include "absl/base/attributes.h"
#include "absl/container/flat_hash_map.h"
#include "absl/synchronization/mutex.h"
#include "internal/platform/implementation/ble_v2.h"
#include "internal/platform/implementation/ble.h"
// #include "internal/platform/implementation/linux/ble_gatt_client.h"
#include "ble_gatt_client.h"
#include "bluez_gatt_manager.h"
@@ -39,7 +39,7 @@
namespace nearby {
namespace linux {
class BleV2Medium final : public api::ble_v2::BleMedium {
class BleV2Medium final : public api::ble::BleMedium {
public:
BleV2Medium(const BleV2Medium &) = delete;
BleV2Medium(BleV2Medium &&) = delete;
@@ -50,52 +50,52 @@ class BleV2Medium final : public api::ble_v2::BleMedium {
~BleV2Medium() override = default;
bool StartAdvertising(
const api::ble_v2::BleAdvertisementData &advertising_data,
api::ble_v2::AdvertiseParameters advertise_set_parameters) override
const api::ble::BleAdvertisementData &advertising_data,
api::ble::AdvertiseParameters advertise_set_parameters) override
ABSL_LOCKS_EXCLUDED(cur_adv_mutex_);
std::unique_ptr<AdvertisingSession> StartAdvertising(
const api::ble_v2::BleAdvertisementData &advertising_data,
api::ble_v2::AdvertiseParameters advertise_set_parameters,
const api::ble::BleAdvertisementData &advertising_data,
api::ble::AdvertiseParameters advertise_set_parameters,
AdvertisingCallback callback) ABSL_LOCKS_EXCLUDED(advs_mutex_) override;
bool StopAdvertising() override ABSL_LOCKS_EXCLUDED(advs_mutex_);
bool StartScanning(const Uuid &service_uuid,
api::ble_v2::TxPowerLevel tx_power_level,
api::ble::TxPowerLevel tx_power_level,
ScanCallback callback) override
ABSL_LOCKS_EXCLUDED(active_adv_monitors_mutex_);
bool StopScanning() override ABSL_LOCKS_EXCLUDED(active_adv_monitors_mutex_);
std::unique_ptr<ScanningSession> StartScanning(
const Uuid &service_uuid, api::ble_v2::TxPowerLevel tx_power_level,
const Uuid &service_uuid, api::ble::TxPowerLevel tx_power_level,
ScanningCallback callback) override;
std::unique_ptr<api::ble_v2::GattServer> StartGattServer(
api::ble_v2::ServerGattConnectionCallback callback) override;
std::unique_ptr<api::ble::GattServer> StartGattServer(
api::ble::ServerGattConnectionCallback callback) override;
std::unique_ptr<api::ble_v2::GattClient> ConnectToGattServer(
api::ble_v2::BlePeripheral::UniqueId peripheral_id,
api::ble_v2::TxPowerLevel tx_power_level,
api::ble_v2::ClientGattConnectionCallback callback) override;
std::unique_ptr<api::ble::GattClient> ConnectToGattServer(
api::ble::BlePeripheral::UniqueId peripheral_id,
api::ble::TxPowerLevel tx_power_level,
api::ble::ClientGattConnectionCallback callback) override;
std::unique_ptr<api::ble_v2::BleServerSocket> OpenServerSocket(
std::unique_ptr<api::ble::BleServerSocket> OpenServerSocket(
const std::string &service_id) override;
std::unique_ptr<api::ble_v2::BleL2capServerSocket> OpenL2capServerSocket(
std::unique_ptr<api::ble::BleL2capServerSocket> OpenL2capServerSocket(
const std::string &service_id) override;
std::unique_ptr<api::ble_v2::BleSocket> Connect(
const std::string &service_id, api::ble_v2::TxPowerLevel tx_power_level,
api::ble_v2::BlePeripheral::UniqueId peripheral_id,
std::unique_ptr<api::ble::BleSocket> Connect(
const std::string &service_id, api::ble::TxPowerLevel tx_power_level,
api::ble::BlePeripheral::UniqueId peripheral_id,
CancellationFlag *cancellation_flag) override;
std::unique_ptr<api::ble_v2::BleL2capSocket> ConnectOverL2cap(
std::unique_ptr<api::ble::BleL2capSocket> ConnectOverL2cap(
int psm, const std::string &service_id,
api::ble_v2::TxPowerLevel tx_power_level,
api::ble_v2::BlePeripheral::UniqueId peripheral_id,
api::ble::TxPowerLevel tx_power_level,
api::ble::BlePeripheral::UniqueId peripheral_id,
CancellationFlag *cancellation_flag) override;
bool StartMultipleServicesScanning(const std::vector<Uuid> &service_uuids,
api::ble_v2::TxPowerLevel tx_power_level,
api::ble::TxPowerLevel tx_power_level,
ScanCallback callback) override;
bool PauseMediumScanning() override;
@@ -107,13 +107,13 @@ class BleV2Medium final : public api::ble_v2::BleMedium {
void AddAlternateUuidForService(uint16_t uuid,
const std::string &service_id) override;
std::optional<api::ble_v2::BlePeripheral::UniqueId>
std::optional<api::ble::BlePeripheral::UniqueId>
RetrieveBlePeripheralIdFromNativeId(
const std::string &ble_peripheral_native_id) override;
// bool GetRemotePeripheral(const std::string &mac_address,
// GetRemotePeripheralCallback callback) override;
// bool GetRemotePeripheral(api::ble_v2::BlePeripheral::UniqueId id,
// bool GetRemotePeripheral(api::ble::BlePeripheral::UniqueId id,
// GetRemotePeripheralCallback callback) override;
private:
@@ -18,14 +18,14 @@
#include "absl/synchronization/mutex.h"
#include "internal/platform/exception.h"
#include "internal/platform/implementation/ble_v2.h"
#include "internal/platform/implementation/ble.h"
#include "internal/platform/implementation/linux/ble_v2_socket.h"
#include "internal/platform/logging.h"
namespace nearby {
namespace linux {
std::unique_ptr<api::ble_v2::BleSocket> BleV2ServerSocket::Accept() {
std::unique_ptr<api::ble::BleSocket> BleV2ServerSocket::Accept() {
absl::MutexLock lock(&mutex_);
LOG(INFO) << "BleV2ServerSocket::Accept waiting for connection";
@@ -20,19 +20,19 @@
#include <string>
#include "absl/synchronization/mutex.h"
#include "internal/platform/implementation/ble_v2.h"
#include "internal/platform/implementation/ble.h"
#include "internal/platform/implementation/linux/ble_v2_socket.h"
namespace nearby {
namespace linux {
class BleV2ServerSocket final : public api::ble_v2::BleServerSocket {
class BleV2ServerSocket final : public api::ble::BleServerSocket {
public:
explicit BleV2ServerSocket(const std::string& service_id)
: service_id_(service_id) {}
~BleV2ServerSocket() override = default;
std::unique_ptr<api::ble_v2::BleSocket> Accept() override
std::unique_ptr<api::ble::BleSocket> Accept() override
ABSL_LOCKS_EXCLUDED(mutex_);
Exception Close() override ABSL_LOCKS_EXCLUDED(mutex_);
@@ -119,7 +119,7 @@ void BleV2Socket::BleInputStream::NotifyClose() {
}
// BleOutputStream implementation
Exception BleV2Socket::BleOutputStream::Write(const ByteArray& data) {
Exception BleV2Socket::BleOutputStream::Write(absl::string_view data) {
absl::MutexLock lock(&mutex_);
if (closed_) {
return {Exception::kIo};
@@ -154,9 +154,9 @@ void BleV2Socket::BleOutputStream::SetWriteCallback(WriteCallback callback) {
}
void BleV2Socket::SetGattServer(
std::unique_ptr<api::ble_v2::GattServer> gatt_server,
const api::ble_v2::GattCharacteristic& rx_char,
const api::ble_v2::GattCharacteristic& tx_char) {
std::unique_ptr<api::ble::GattServer> gatt_server,
const api::ble::GattCharacteristic& rx_char,
const api::ble::GattCharacteristic& tx_char) {
absl::MutexLock lock(&mutex_);
if (closed_) {
@@ -170,7 +170,7 @@ void BleV2Socket::SetGattServer(
// Set up write callback to use GATT server notifications
output_stream_.SetWriteCallback(
[this](const ByteArray& data) -> bool {
[this](absl::string_view data) -> bool {
absl::MutexLock lock(&mutex_);
if (!gatt_server_) {
LOG(ERROR) << "GATT server not available for write";
@@ -200,9 +200,9 @@ void BleV2Socket::SetGattServer(
}
void BleV2Socket::SetGattClient(
std::unique_ptr<api::ble_v2::GattClient> gatt_client,
const api::ble_v2::GattCharacteristic& rx_char,
const api::ble_v2::GattCharacteristic& tx_char) {
std::unique_ptr<api::ble::GattClient> gatt_client,
const api::ble::GattCharacteristic& rx_char,
const api::ble::GattCharacteristic& tx_char) {
absl::MutexLock lock(&mutex_);
if (closed_) {
@@ -216,7 +216,7 @@ void BleV2Socket::SetGattClient(
// Set up write callback to use GATT client writes
output_stream_.SetWriteCallback(
[this](const ByteArray& data) -> bool {
[this](absl::string_view data) -> bool {
absl::MutexLock lock(&mutex_);
if (!gatt_client_) {
LOG(ERROR) << "GATT client not available for write";
@@ -232,7 +232,7 @@ void BleV2Socket::SetGattClient(
std::string data_str(data.data(), data.size());
bool success = gatt_client_->WriteCharacteristic(
tx_char_, data_str,
api::ble_v2::GattClient::WriteType::kWithoutResponse);
api::ble::GattClient::WriteType::kWithoutResponse);
if (!success) {
LOG(WARNING) << "Failed to write to TX characteristic";
@@ -21,7 +21,7 @@
#include "absl/synchronization/mutex.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/exception.h"
#include "internal/platform/implementation/ble_v2.h"
#include "internal/platform/implementation/ble.h"
#include "internal/platform/input_stream.h"
#include "internal/platform/output_stream.h"
@@ -37,10 +37,10 @@ namespace linux {
// - Client side:
// * TX characteristic: Our OutputStream writes -> remote reads
// * RX characteristic: Remote writes (notifications) -> our InputStream reads
class BleV2Socket : public api::ble_v2::BleSocket {
class BleV2Socket : public api::ble::BleSocket {
public:
BleV2Socket() = default;
explicit BleV2Socket(api::ble_v2::BlePeripheral::UniqueId peripheral_id)
explicit BleV2Socket(api::ble::BlePeripheral::UniqueId peripheral_id)
: peripheral_id_(peripheral_id) {}
~BleV2Socket() override { Close(); }
@@ -48,7 +48,7 @@ class BleV2Socket : public api::ble_v2::BleSocket {
OutputStream& GetOutputStream() override;
Exception Close() override ABSL_LOCKS_EXCLUDED(mutex_);
api::ble_v2::BlePeripheral::UniqueId GetRemotePeripheralId() override {
api::ble::BlePeripheral::UniqueId GetRemotePeripheralId() override {
return peripheral_id_;
}
@@ -66,15 +66,15 @@ class BleV2Socket : public api::ble_v2::BleSocket {
}
// Set the GATT server and characteristics for server-side socket
void SetGattServer(std::unique_ptr<api::ble_v2::GattServer> gatt_server,
const api::ble_v2::GattCharacteristic& rx_char,
const api::ble_v2::GattCharacteristic& tx_char)
void SetGattServer(std::unique_ptr<api::ble::GattServer> gatt_server,
const api::ble::GattCharacteristic& rx_char,
const api::ble::GattCharacteristic& tx_char)
ABSL_LOCKS_EXCLUDED(mutex_);
// Set the GATT client and characteristics for client-side socket
void SetGattClient(std::unique_ptr<api::ble_v2::GattClient> gatt_client,
const api::ble_v2::GattCharacteristic& rx_char,
const api::ble_v2::GattCharacteristic& tx_char)
void SetGattClient(std::unique_ptr<api::ble::GattClient> gatt_client,
const api::ble::GattCharacteristic& rx_char,
const api::ble::GattCharacteristic& tx_char)
ABSL_LOCKS_EXCLUDED(mutex_);
private:
@@ -102,12 +102,12 @@ class BleV2Socket : public api::ble_v2::BleSocket {
BleOutputStream() = default;
~BleOutputStream() override = default;
Exception Write(const ByteArray& data) override
Exception Write(absl::string_view data) override
ABSL_LOCKS_EXCLUDED(mutex_);
Exception Flush() override;
Exception Close() override ABSL_LOCKS_EXCLUDED(mutex_);
using WriteCallback = absl::AnyInvocable<bool(const ByteArray& data)>;
using WriteCallback = absl::AnyInvocable<bool(absl::string_view data)>;
void SetWriteCallback(WriteCallback callback)
ABSL_LOCKS_EXCLUDED(mutex_);
@@ -121,15 +121,15 @@ class BleV2Socket : public api::ble_v2::BleSocket {
bool closed_ ABSL_GUARDED_BY(mutex_) = false;
BleInputStream input_stream_;
BleOutputStream output_stream_;
api::ble_v2::BlePeripheral::UniqueId peripheral_id_ = 0;
api::ble::BlePeripheral::UniqueId peripheral_id_ = 0;
// GATT resources (only one of these will be set)
std::unique_ptr<api::ble_v2::GattServer> gatt_server_ ABSL_GUARDED_BY(mutex_);
std::unique_ptr<api::ble_v2::GattClient> gatt_client_ ABSL_GUARDED_BY(mutex_);
std::unique_ptr<api::ble::GattServer> gatt_server_ ABSL_GUARDED_BY(mutex_);
std::unique_ptr<api::ble::GattClient> gatt_client_ ABSL_GUARDED_BY(mutex_);
// Characteristics for data transfer
api::ble_v2::GattCharacteristic rx_char_ ABSL_GUARDED_BY(mutex_);
api::ble_v2::GattCharacteristic tx_char_ ABSL_GUARDED_BY(mutex_);
api::ble::GattCharacteristic rx_char_ ABSL_GUARDED_BY(mutex_);
api::ble::GattCharacteristic tx_char_ ABSL_GUARDED_BY(mutex_);
};
} // namespace linux