#include "device/bluetooth/gatt_service.h"
#include "base/containers/contains.h"
#include "base/logging.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_local_gatt_characteristic.h"
#include "device/bluetooth/device.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
namespace {
std::string_view GattErrorCodeToString(
device::BluetoothGattService::GattErrorCode error_code) { … }
}
namespace bluetooth {
GattService::GattService(
mojo::PendingReceiver<mojom::GattService> pending_gatt_service_receiver,
mojo::PendingRemote<mojom::GattServiceObserver> pending_observer_remote,
const device::BluetoothUUID& service_id,
scoped_refptr<device::BluetoothAdapter> adapter,
base::OnceCallback<void(device::BluetoothUUID)> on_gatt_service_invalidated)
: … { … }
GattService::~GattService() = default;
void GattService::CreateCharacteristic(
const device::BluetoothUUID& characteristic_uuid,
const device::BluetoothGattCharacteristic::Permissions& permissions,
const device::BluetoothGattCharacteristic::Properties& properties,
CreateCharacteristicCallback callback) { … }
void GattService::Register(RegisterCallback callback) { … }
void GattService::OnCharacteristicReadRequest(
const device::BluetoothDevice* device,
const device::BluetoothLocalGattCharacteristic* characteristic,
int offset,
ValueCallback callback) { … }
void GattService::OnCharacteristicWriteRequest(
const device::BluetoothDevice* device,
const device::BluetoothLocalGattCharacteristic* characteristic,
const std::vector<uint8_t>& value,
int offset,
base::OnceClosure callback,
ErrorCallback error_callback) { … }
void GattService::OnCharacteristicPrepareWriteRequest(
const device::BluetoothDevice* device,
const device::BluetoothLocalGattCharacteristic* characteristic,
const std::vector<uint8_t>& value,
int offset,
bool has_subsequent_request,
base::OnceClosure callback,
ErrorCallback error_callback) { … }
void GattService::OnDescriptorReadRequest(
const device::BluetoothDevice* device,
const device::BluetoothLocalGattDescriptor* descriptor,
int offset,
ValueCallback callback) { … }
void GattService::OnDescriptorWriteRequest(
const device::BluetoothDevice* device,
const device::BluetoothLocalGattDescriptor* descriptor,
const std::vector<uint8_t>& value,
int offset,
base::OnceClosure callback,
ErrorCallback error_callback) { … }
void GattService::OnNotificationsStart(
const device::BluetoothDevice* device,
device::BluetoothGattCharacteristic::NotificationType notification_type,
const device::BluetoothLocalGattCharacteristic* characteristic) { … }
void GattService::OnNotificationsStop(
const device::BluetoothDevice* device,
const device::BluetoothLocalGattCharacteristic* characteristic) { … }
void GattService::OnLocalCharacteristicReadResponse(
ValueCallback callback,
mojom::LocalCharacteristicReadResultPtr read_result) { … }
void GattService::OnMojoDisconnect() { … }
void GattService::OnRegisterSuccess(RegisterCallback callback) { … }
void GattService::OnRegisterFailure(
RegisterCallback callback,
device::BluetoothGattService::GattErrorCode error_code) { … }
}