bluetooth_low_energy_scan_session.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2021 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_BLUETOOTH_LOW_ENERGY_SCAN_SESSION_H_
  5. #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_SCAN_SESSION_H_
  6. #include "device/bluetooth/bluetooth_export.h"
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. namespace device {
  9. class BluetoothDevice;
  10. class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyScanSession {
  11. public:
  12. enum class ErrorCode {
  13. kFailed,
  14. };
  15. // Interface for reacting to BluetoothLowEnergyScanSession events.
  16. class Delegate {
  17. public:
  18. Delegate& operator=(const Delegate&) = delete;
  19. virtual ~Delegate() = default;
  20. // Notifies that a scanning session has started. If there is an |error_code|
  21. // the session failed to start.
  22. virtual void OnSessionStarted(
  23. BluetoothLowEnergyScanSession* scan_session,
  24. absl::optional<BluetoothLowEnergyScanSession::ErrorCode>
  25. error_code) = 0;
  26. // Notifies that a device matching the filter criteria has been found.
  27. virtual void OnDeviceFound(BluetoothLowEnergyScanSession* scan_session,
  28. BluetoothDevice* device) = 0;
  29. // Notifies that a previously found device has been lost.
  30. virtual void OnDeviceLost(BluetoothLowEnergyScanSession* scan_session,
  31. BluetoothDevice* device) = 0;
  32. // Notifies that the scan session was unexpectedly invalidated. This could
  33. // be due to a firmware crash on the bluetooth chipset, etc.
  34. virtual void OnSessionInvalidated(
  35. BluetoothLowEnergyScanSession* scan_session) = 0;
  36. };
  37. BluetoothLowEnergyScanSession(const BluetoothLowEnergyScanSession&) = delete;
  38. BluetoothLowEnergyScanSession& operator=(
  39. const BluetoothLowEnergyScanSession&) = delete;
  40. virtual ~BluetoothLowEnergyScanSession();
  41. protected:
  42. BluetoothLowEnergyScanSession();
  43. };
  44. } // namespace device
  45. #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_SCAN_SESSION_H_