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

Unified Diff: device/bluetooth/bluetooth_gatt_characteristic_bluez.h

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_gatt_characteristic_bluez.h
diff --git a/device/bluetooth/bluetooth_gatt_characteristic_bluez.h b/device/bluetooth/bluetooth_gatt_characteristic_bluez.h
new file mode 100644
index 0000000000000000000000000000000000000000..cb9e3f734a29bc350ff94dfa5a14617a529a7c0d
--- /dev/null
+++ b/device/bluetooth/bluetooth_gatt_characteristic_bluez.h
@@ -0,0 +1,102 @@
+// Copyright 2014 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.
+
+#ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_
+#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <map>
+#include <queue>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "dbus/object_path.h"
+#include "device/bluetooth/bluetooth_gatt_characteristic.h"
+#include "device/bluetooth/bluetooth_uuid.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h"
+
+namespace device {
+
+class BluetoothGattDescriptor;
+class BluetoothGattService;
+
+} // namespace device
+
+namespace bluez {
+
+class BluetoothGattDescriptorBlueZ;
+class BluetoothGattServiceBlueZ;
+
+// The BluetoothGattCharacteristicBlueZ class implements
+// BluetoothGattCharacteristic for remote GATT characteristics for platforms
+// that use BlueZ.
+class BluetoothGattCharacteristicBlueZ
+ : public device::BluetoothGattCharacteristic {
+ public:
+ // device::BluetoothGattCharacteristic overrides.
+ std::string GetIdentifier() const override;
+ device::BluetoothUUID GetUUID() const override;
+ const std::vector<uint8_t>& GetValue() const override;
+ device::BluetoothGattService* GetService() const override;
+ Properties GetProperties() const override;
+ Permissions GetPermissions() const override;
+ bool IsNotifying() const override;
+ std::vector<device::BluetoothGattDescriptor*> GetDescriptors() const override;
+ device::BluetoothGattDescriptor* GetDescriptor(
+ const std::string& identifier) const override;
+ void ReadRemoteCharacteristic(const ValueCallback& callback,
+ const ErrorCallback& error_callback) override;
+ void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) override;
+
+ // Object path of the underlying D-Bus characteristic.
+ const dbus::ObjectPath& object_path() const { return object_path_; }
+
+ protected:
+ BluetoothGattCharacteristicBlueZ(BluetoothGattServiceBlueZ* service,
+ const dbus::ObjectPath& object_path);
+ ~BluetoothGattCharacteristicBlueZ() override;
+
+ private:
+ friend class BluetoothGattServiceBlueZ;
+
+ typedef std::pair<NotifySessionCallback, ErrorCallback>
+ PendingStartNotifyCall;
+
+ // Called by dbus:: on unsuccessful completion of a request to read or write
+ // the characteristic value.
+ void OnError(const ErrorCallback& error_callback,
+ const std::string& error_name,
+ const std::string& error_message);
+
+ // Object path of the D-Bus characteristic object.
+ dbus::ObjectPath object_path_;
+
+ // The GATT service this GATT characteristic belongs to.
+ BluetoothGattServiceBlueZ* service_;
+
+ // Mapping from GATT descriptor object paths to descriptor objects owned by
+ // this characteristic. Since the BlueZ implementation uses object paths
+ // as unique identifiers, we also use this mapping to return descriptors by
+ // identifier.
+ typedef std::map<dbus::ObjectPath, BluetoothGattDescriptorBlueZ*>
+ DescriptorMap;
+ DescriptorMap descriptors_;
+
+ // Note: This should remain the last member so it'll be destroyed and
+ // invalidate its weak pointers before any other members are destroyed.
+ base::WeakPtrFactory<BluetoothGattCharacteristicBlueZ> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicBlueZ);
+};
+
+} // namespace bluez
+
+#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_

Powered by Google App Engine
This is Rietveld 408576698