bluetooth_gatt_application_service_provider.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2016 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_APPLICATION_SERVICE_PROVIDER_H_
  5. #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_APPLICATION_SERVICE_PROVIDER_H_
  6. #include <map>
  7. #include <vector>
  8. #include "dbus/bus.h"
  9. #include "dbus/object_path.h"
  10. #include "device/bluetooth/bluetooth_export.h"
  11. #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h"
  12. #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h"
  13. #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h"
  14. #include "device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h"
  15. namespace bluez {
  16. class BluetoothLocalGattServiceBlueZ;
  17. // BluetoothGattApplicationServiceProvider is used to provide a D-Bus object
  18. // that the Bluetooth daemon can communicate with to register GATT service
  19. // hierarchies.
  20. class DEVICE_BLUETOOTH_EXPORT BluetoothGattApplicationServiceProvider {
  21. public:
  22. BluetoothGattApplicationServiceProvider(
  23. const BluetoothGattApplicationServiceProvider&) = delete;
  24. BluetoothGattApplicationServiceProvider& operator=(
  25. const BluetoothGattApplicationServiceProvider&) = delete;
  26. virtual ~BluetoothGattApplicationServiceProvider();
  27. // Creates individual service providers for all the attributes managed by the
  28. // object manager interface implemented by this application service provider.
  29. void CreateAttributeServiceProviders(
  30. dbus::Bus* bus,
  31. const std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>&
  32. services);
  33. // Creates the instance where |bus| is the D-Bus bus connection to export the
  34. // object onto, |object_path| is the object path that it should have, |uuid|
  35. // is the 128-bit GATT service UUID, and |includes| are a list of object paths
  36. // belonging to other exported GATT services that are included by the GATT
  37. // service being created. Make sure that all included services have been
  38. // exported before registering a GATT services with the GATT manager.
  39. static std::unique_ptr<BluetoothGattApplicationServiceProvider> Create(
  40. dbus::Bus* bus,
  41. const dbus::ObjectPath& object_path,
  42. const std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>&
  43. services);
  44. void SendValueChanged(const dbus::ObjectPath& characteristic_path,
  45. const std::vector<uint8_t>& value);
  46. protected:
  47. BluetoothGattApplicationServiceProvider();
  48. // List of GATT Service service providers managed by this object manager.
  49. std::vector<std::unique_ptr<BluetoothGattServiceServiceProvider>>
  50. service_providers_;
  51. // List of GATT Characteristic service providers managed by this object
  52. // manager.
  53. std::vector<std::unique_ptr<BluetoothGattCharacteristicServiceProvider>>
  54. characteristic_providers_;
  55. // List of GATT Descriptor service providers managed by this object manager.
  56. std::vector<std::unique_ptr<BluetoothGattDescriptorServiceProvider>>
  57. descriptor_providers_;
  58. };
  59. } // namespace bluez
  60. #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_APPLICATION_SERVICE_PROVIDER_H_