Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: device/bluetooth/bluetooth_local_gatt_service_bluez.cc

Issue 1872943002: Add support for local services/characteristics/descriptors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_local_gatt_service_bluez.cc
diff --git a/device/bluetooth/bluetooth_local_gatt_service_bluez.cc b/device/bluetooth/bluetooth_local_gatt_service_bluez.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c63e2287821425943049a15e6e74d74e549f5a7c
--- /dev/null
+++ b/device/bluetooth/bluetooth_local_gatt_service_bluez.cc
@@ -0,0 +1,92 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <iostream>
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/logging.h"
+#include "device/bluetooth/bluetooth_adapter_bluez.h"
+#include "device/bluetooth/bluetooth_gatt_characteristic.h"
+#include "device/bluetooth/bluetooth_local_gatt_service_bluez.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h"
+#include "device/bluetooth/dbus/bluez_dbus_manager.h"
+
+namespace bluez {
+
+BluetoothLocalGattServiceBlueZ::BluetoothLocalGattServiceBlueZ(
+ BluetoothAdapterBlueZ* adapter,
+ const dbus::ObjectPath& object_path)
+ : BluetoothGattServiceBlueZ(adapter, object_path), weak_ptr_factory_(this) {
+ VLOG(1) << "Creating local GATT service with identifier: "
+ << object_path.value();
+}
+
+BluetoothLocalGattServiceBlueZ::~BluetoothLocalGattServiceBlueZ() {}
+
+device::BluetoothUUID BluetoothLocalGattServiceBlueZ::GetUUID() const {
+ NOTIMPLEMENTED();
+ return device::BluetoothUUID();
+}
+
+bool BluetoothLocalGattServiceBlueZ::IsLocal() const {
+ return true;
+}
+
+bool BluetoothLocalGattServiceBlueZ::IsPrimary() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+device::BluetoothDevice* BluetoothLocalGattServiceBlueZ::GetDevice() const {
+ return nullptr;
+}
+
+bool BluetoothLocalGattServiceBlueZ::AddCharacteristic(
+ device::BluetoothGattCharacteristic* characteristic) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool BluetoothLocalGattServiceBlueZ::AddIncludedService(
+ device::BluetoothGattService* service) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void BluetoothLocalGattServiceBlueZ::Register(
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ DCHECK(bluez::BluezDBusManager::Get());
+ bluez::BluezDBusManager::Get()
+ ->GetBluetoothGattManagerClient()
+ ->RegisterService(
+ object_path(), BluetoothGattManagerClient::Options(), callback,
+ base::Bind(&BluetoothLocalGattServiceBlueZ::OnRegistrationError,
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
+}
+
+void BluetoothLocalGattServiceBlueZ::Unregister(
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ DCHECK(bluez::BluezDBusManager::Get());
+ bluez::BluezDBusManager::Get()
+ ->GetBluetoothGattManagerClient()
+ ->UnregisterService(
+ object_path(), callback,
+ base::Bind(&BluetoothLocalGattServiceBlueZ::OnRegistrationError,
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
+}
+
+void BluetoothLocalGattServiceBlueZ::OnRegistrationError(
+ const ErrorCallback& error_callback,
+ const std::string& error_name,
+ const std::string& error_message) {
+ VLOG(1) << "[Un]Register Service failed: " << error_name
+ << ", message: " << error_message;
+ error_callback.Run(
+ BluetoothGattServiceBlueZ::DBusErrorToServiceError(error_name));
+}
+
+} // namespace bluez
« no previous file with comments | « device/bluetooth/bluetooth_local_gatt_service_bluez.h ('k') | device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698