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.
5 #ifndef CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_
10 #include "base/basictypes.h"
11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/dbus_client.h"
13 #include "dbus/object_path.h"
14 #include "dbus/property.h"
18 // BluetoothGattCharacteristicClient is used to communicate with remote GATT
19 // characteristic objects exposed by the Bluetooth daemon.
20 class CHROMEOS_EXPORT BluetoothGattCharacteristicClient
: public DBusClient
{
22 // Structure of properties associated with GATT characteristics.
23 struct Properties
: public dbus::PropertySet
{
24 // The 128-bit characteristic UUID. [read-only]
25 dbus::Property
<std::string
> uuid
;
27 // Object path of the GATT service the characteristic belongs to.
29 dbus::Property
<dbus::ObjectPath
> service
;
31 // Characteristic value read from the remote Bluetooth device. Setting the
32 // value sends a write request to the remote device. [read-write]
33 dbus::Property
<std::vector
<uint8
> > value
;
35 // List of flags representing the GATT "Characteristic Properties bit field"
36 // and properties read from the GATT "Characteristic Extended Properties"
37 // descriptor bit field. [read-only, optional]
38 dbus::Property
<std::vector
<std::string
> > flags
;
40 Properties(dbus::ObjectProxy
* object_proxy
,
41 const std::string
& interface_name
,
42 const PropertyChangedCallback
& callback
);
43 virtual ~Properties();
46 // Interface for observing changes from a remote GATT characteristic.
49 virtual ~Observer() {}
51 // Called when the GATT characteristic with object path |object_path| is
52 // added to the system.
53 virtual void GattCharacteristicAdded(const dbus::ObjectPath
& object_path
) {}
55 // Called when the GATT characteristic with object path |object_path| is
56 // removed from the system.
57 virtual void GattCharacteristicRemoved(
58 const dbus::ObjectPath
& object_path
) {}
60 // Called when the GATT characteristic with object path |object_path| has a
61 // change in the value of the property named |property_name|.
62 virtual void GattCharacteristicPropertyChanged(
63 const dbus::ObjectPath
& object_path
,
64 const std::string
& property_name
) {}
67 virtual ~BluetoothGattCharacteristicClient();
69 // Adds and removes observers for events on all remote GATT characteristics.
70 // Check the |object_path| parameter of observer methods to determine which
71 // GATT characteristic is issuing the event.
72 virtual void AddObserver(Observer
* observer
) = 0;
73 virtual void RemoveObserver(Observer
* observer
) = 0;
75 // Returns the list of GATT characteristic object paths known to the system.
76 virtual std::vector
<dbus::ObjectPath
> GetCharacteristics() = 0;
78 // Obtain the properties for the GATT characteristic with object path
79 // |object_path|. Values should be copied if needed.
80 virtual Properties
* GetProperties(const dbus::ObjectPath
& object_path
) = 0;
82 // Creates the instance.
83 static BluetoothGattCharacteristicClient
* Create();
86 BluetoothGattCharacteristicClient();
89 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicClient
);
92 } // namespace chromeos
94 #endif // CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_