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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <map>
12 #include <queue>
13 #include <string>
14 #include <utility>
15 #include <vector>
16
17 #include "base/macros.h"
18 #include "base/memory/weak_ptr.h"
19 #include "dbus/object_path.h"
20 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
21 #include "device/bluetooth/bluetooth_uuid.h"
22 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h"
23
24 namespace device {
25
26 class BluetoothGattDescriptor;
27 class BluetoothGattService;
28
29 } // namespace device
30
31 namespace bluez {
32
33 class BluetoothGattDescriptorBlueZ;
34 class BluetoothGattServiceBlueZ;
35
36 // The BluetoothGattCharacteristicBlueZ class implements
37 // BluetoothGattCharacteristic for remote GATT characteristics for platforms
38 // that use BlueZ.
39 class BluetoothGattCharacteristicBlueZ
40 : public device::BluetoothGattCharacteristic {
41 public:
42 // device::BluetoothGattCharacteristic overrides.
43 std::string GetIdentifier() const override;
44 device::BluetoothUUID GetUUID() const override;
45 const std::vector<uint8_t>& GetValue() const override;
46 device::BluetoothGattService* GetService() const override;
47 Properties GetProperties() const override;
48 Permissions GetPermissions() const override;
49 bool IsNotifying() const override;
50 std::vector<device::BluetoothGattDescriptor*> GetDescriptors() const override;
51 device::BluetoothGattDescriptor* GetDescriptor(
52 const std::string& identifier) const override;
53 void ReadRemoteCharacteristic(const ValueCallback& callback,
54 const ErrorCallback& error_callback) override;
55 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value,
56 const base::Closure& callback,
57 const ErrorCallback& error_callback) override;
58
59 // Object path of the underlying D-Bus characteristic.
60 const dbus::ObjectPath& object_path() const { return object_path_; }
61
62 protected:
63 BluetoothGattCharacteristicBlueZ(BluetoothGattServiceBlueZ* service,
64 const dbus::ObjectPath& object_path);
65 ~BluetoothGattCharacteristicBlueZ() override;
66
67 private:
68 friend class BluetoothGattServiceBlueZ;
69
70 typedef std::pair<NotifySessionCallback, ErrorCallback>
71 PendingStartNotifyCall;
72
73 // Called by dbus:: on unsuccessful completion of a request to read or write
74 // the characteristic value.
75 void OnError(const ErrorCallback& error_callback,
76 const std::string& error_name,
77 const std::string& error_message);
78
79 // Object path of the D-Bus characteristic object.
80 dbus::ObjectPath object_path_;
81
82 // The GATT service this GATT characteristic belongs to.
83 BluetoothGattServiceBlueZ* service_;
84
85 // Mapping from GATT descriptor object paths to descriptor objects owned by
86 // this characteristic. Since the BlueZ implementation uses object paths
87 // as unique identifiers, we also use this mapping to return descriptors by
88 // identifier.
89 typedef std::map<dbus::ObjectPath, BluetoothGattDescriptorBlueZ*>
90 DescriptorMap;
91 DescriptorMap descriptors_;
92
93 // Note: This should remain the last member so it'll be destroyed and
94 // invalidate its weak pointers before any other members are destroyed.
95 base::WeakPtrFactory<BluetoothGattCharacteristicBlueZ> weak_ptr_factory_;
96
97 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicBlueZ);
98 };
99
100 } // namespace bluez
101
102 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698