#include "device/fido/cable/fido_ble_connection.h"
#include <algorithm>
#include <ostream>
#include <utility>
#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "components/device_event_log/device_event_log.h"
#include "device/bluetooth/bluetooth_gatt_connection.h"
#include "device/bluetooth/bluetooth_gatt_notify_session.h"
#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_remote_gatt_service.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
#include "device/fido/cable/fido_ble_uuids.h"
namespace device {
namespace {
ServiceRevisionsCallback;
constexpr const char* ToString(BluetoothDevice::ConnectErrorCode error_code) { … }
constexpr const char* ToString(BluetoothGattService::GattErrorCode error_code) { … }
std::ostream& operator<<(std::ostream& os,
FidoBleConnection::ServiceRevision revision) { … }
void OnWriteRemoteCharacteristic(FidoBleConnection::WriteCallback callback) { … }
void OnWriteRemoteCharacteristicError(
FidoBleConnection::WriteCallback callback,
BluetoothGattService::GattErrorCode error_code) { … }
void OnReadServiceRevisionBitfield(
ServiceRevisionsCallback callback,
std::optional<device::BluetoothGattService::GattErrorCode> error_code,
const std::vector<uint8_t>& value) { … }
}
FidoBleConnection::FidoBleConnection(BluetoothAdapter* adapter,
std::string device_address,
BluetoothUUID service_uuid,
ReadCallback read_callback)
: … { … }
FidoBleConnection::~FidoBleConnection() { … }
BluetoothDevice* FidoBleConnection::GetBleDevice() { … }
const BluetoothDevice* FidoBleConnection::GetBleDevice() const { … }
void FidoBleConnection::Connect(ConnectionCallback callback) { … }
void FidoBleConnection::ReadControlPointLength(
ControlPointLengthCallback callback) { … }
void FidoBleConnection::WriteControlPoint(const std::vector<uint8_t>& data,
WriteCallback callback) { … }
void FidoBleConnection::OnCreateGattConnection(
std::unique_ptr<BluetoothGattConnection> connection,
std::optional<BluetoothDevice::ConnectErrorCode> error_code) { … }
void FidoBleConnection::ConnectToFidoService() { … }
void FidoBleConnection::OnReadServiceRevisions(
std::vector<ServiceRevision> service_revisions) { … }
void FidoBleConnection::WriteServiceRevision(ServiceRevision service_revision) { … }
void FidoBleConnection::OnServiceRevisionWritten(bool success) { … }
void FidoBleConnection::StartNotifySession() { … }
void FidoBleConnection::OnStartNotifySession(
std::unique_ptr<BluetoothGattNotifySession> notify_session) { … }
void FidoBleConnection::OnStartNotifySessionError(
BluetoothGattService::GattErrorCode error_code) { … }
void FidoBleConnection::DeviceAddressChanged(BluetoothAdapter* adapter,
BluetoothDevice* device,
const std::string& old_address) { … }
void FidoBleConnection::GattCharacteristicValueChanged(
BluetoothAdapter* adapter,
BluetoothRemoteGattCharacteristic* characteristic,
const std::vector<uint8_t>& value) { … }
void FidoBleConnection::GattServicesDiscovered(BluetoothAdapter* adapter,
BluetoothDevice* device) { … }
const BluetoothRemoteGattService* FidoBleConnection::GetFidoService() { … }
void FidoBleConnection::OnReadControlPointLength(
ControlPointLengthCallback callback,
std::optional<device::BluetoothGattService::GattErrorCode> error_code,
const std::vector<uint8_t>& value) { … }
}