#include "device/bluetooth/emulation/fake_remote_gatt_characteristic.h"
#include <optional>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "device/bluetooth/emulation/fake_read_response.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
namespace bluetooth {
FakeRemoteGattCharacteristic::FakeRemoteGattCharacteristic(
const std::string& characteristic_id,
const device::BluetoothUUID& characteristic_uuid,
mojom::CharacteristicPropertiesPtr properties,
device::BluetoothRemoteGattService* service)
: … { … }
FakeRemoteGattCharacteristic::~FakeRemoteGattCharacteristic() = default;
std::string FakeRemoteGattCharacteristic::AddFakeDescriptor(
const device::BluetoothUUID& descriptor_uuid) { … }
bool FakeRemoteGattCharacteristic::RemoveFakeDescriptor(
const std::string& identifier) { … }
void FakeRemoteGattCharacteristic::SetNextReadResponse(
uint16_t gatt_code,
const std::optional<std::vector<uint8_t>>& value) { … }
void FakeRemoteGattCharacteristic::SetNextWriteResponse(uint16_t gatt_code) { … }
void FakeRemoteGattCharacteristic::SetNextSubscribeToNotificationsResponse(
uint16_t gatt_code) { … }
void FakeRemoteGattCharacteristic::SetNextUnsubscribeFromNotificationsResponse(
uint16_t gatt_code) { … }
bool FakeRemoteGattCharacteristic::AllResponsesConsumed() { … }
std::string FakeRemoteGattCharacteristic::GetIdentifier() const { … }
device::BluetoothUUID FakeRemoteGattCharacteristic::GetUUID() const { … }
FakeRemoteGattCharacteristic::Properties
FakeRemoteGattCharacteristic::GetProperties() const { … }
FakeRemoteGattCharacteristic::Permissions
FakeRemoteGattCharacteristic::GetPermissions() const { … }
const std::vector<uint8_t>& FakeRemoteGattCharacteristic::GetValue() const { … }
device::BluetoothRemoteGattService* FakeRemoteGattCharacteristic::GetService()
const { … }
void FakeRemoteGattCharacteristic::ReadRemoteCharacteristic(
ValueCallback callback) { … }
void FakeRemoteGattCharacteristic::WriteRemoteCharacteristic(
const std::vector<uint8_t>& value,
WriteType write_type,
base::OnceClosure callback,
ErrorCallback error_callback) { … }
void FakeRemoteGattCharacteristic::DeprecatedWriteRemoteCharacteristic(
const std::vector<uint8_t>& value,
base::OnceClosure callback,
ErrorCallback error_callback) { … }
#if BUILDFLAG(IS_CHROMEOS)
void FakeRemoteGattCharacteristic::PrepareWriteRemoteCharacteristic(
const std::vector<uint8_t>& value,
base::OnceClosure callback,
ErrorCallback error_callback) {
NOTIMPLEMENTED();
}
#endif
void FakeRemoteGattCharacteristic::SubscribeToNotifications(
device::BluetoothRemoteGattDescriptor* ccc_descriptor,
#if BUILDFLAG(IS_CHROMEOS)
NotificationType notification_type,
#endif
base::OnceClosure callback,
ErrorCallback error_callback) { … }
void FakeRemoteGattCharacteristic::UnsubscribeFromNotifications(
device::BluetoothRemoteGattDescriptor* ccc_descriptor,
base::OnceClosure callback,
ErrorCallback error_callback) { … }
void FakeRemoteGattCharacteristic::DispatchReadResponse(
ValueCallback callback) { … }
void FakeRemoteGattCharacteristic::DispatchWriteResponse(
base::OnceClosure callback,
ErrorCallback error_callback,
const std::vector<uint8_t>& value,
mojom::WriteType write_type) { … }
void FakeRemoteGattCharacteristic::DispatchSubscribeToNotificationsResponse(
base::OnceClosure callback,
ErrorCallback error_callback) { … }
void FakeRemoteGattCharacteristic::DispatchUnsubscribeFromNotificationsResponse(
base::OnceClosure callback,
ErrorCallback error_callback) { … }
}