bluetooth_gatt_manager_client.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_MANAGER_CLIENT_H_
  5. #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_MANAGER_CLIENT_H_
  6. #include <string>
  7. #include "base/callback.h"
  8. #include "dbus/object_path.h"
  9. #include "device/bluetooth/bluetooth_export.h"
  10. #include "device/bluetooth/dbus/bluez_dbus_client.h"
  11. namespace bluez {
  12. // BluetoothGattManagerClient is used to communicate with the GATT Service
  13. // manager object of the Bluetooth daemon.
  14. class DEVICE_BLUETOOTH_EXPORT BluetoothGattManagerClient
  15. : public BluezDBusClient {
  16. public:
  17. // Options used to register a GATT service hierarchy.
  18. struct DEVICE_BLUETOOTH_EXPORT Options {
  19. // TODO(armansito): This parameter is not yet clearly defined. Add fields
  20. // later as we know more about how this will be used.
  21. };
  22. BluetoothGattManagerClient(const BluetoothGattManagerClient&) = delete;
  23. BluetoothGattManagerClient& operator=(const BluetoothGattManagerClient&) =
  24. delete;
  25. ~BluetoothGattManagerClient() override;
  26. // The ErrorCallback is used by GATT manager methods to indicate failure. It
  27. // receives two arguments: the name of the error in |error_name| and an
  28. // optional message in |error_message|.
  29. typedef base::OnceCallback<void(const std::string& error_name,
  30. const std::string& error_message)>
  31. ErrorCallback;
  32. // Registers a GATT service implementation within the local process at the
  33. // D-Bus object path |service_path| with the remote GATT manager. The local
  34. // service must implement the GattService1 interface. Characteristic objects
  35. // must be hierarchical to their service and must use the interface
  36. // GattCharacteristic1. Similarly, characteristic descriptor objects must
  37. // implement the GattDescriptor1 interface and must be hierarchical to their
  38. // characteristic. In a successful invocation of RegisterService, the
  39. // Bluetooth daemon will discover all objects in the registered hierarchy by
  40. // using D-Bus Object Manager. Hence, the object paths and the interfaces in
  41. // the registered hierarchy must comply with the BlueZ GATT D-Bus
  42. // specification.
  43. virtual void RegisterApplication(const dbus::ObjectPath& adapter_object_path,
  44. const dbus::ObjectPath& application_path,
  45. const Options& options,
  46. base::OnceClosure callback,
  47. ErrorCallback error_callback) = 0;
  48. // Unregisters the GATT service with the D-Bus object path |service_path| from
  49. // the remote GATT manager.
  50. virtual void UnregisterApplication(
  51. const dbus::ObjectPath& adapter_object_path,
  52. const dbus::ObjectPath& application_path,
  53. base::OnceClosure callback,
  54. ErrorCallback error_callback) = 0;
  55. // Creates the instance.
  56. static BluetoothGattManagerClient* Create();
  57. // Constants used to indicate exceptional error conditions.
  58. static const char kNoResponseError[];
  59. static const char kUnknownGattManager[];
  60. protected:
  61. BluetoothGattManagerClient();
  62. };
  63. } // namespace bluez
  64. #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_MANAGER_CLIENT_H_