From aff28342d94f9140e36a793353575d243cc789b8 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 6 Feb 2024 17:56:17 +1100 Subject: let the bluetooth stack handle its own discovery state --- src/drivers/include/bluetooth.hpp | 14 ++------------ src/drivers/include/bluetooth_types.hpp | 1 - 2 files changed, 2 insertions(+), 13 deletions(-) (limited to 'src/drivers/include') diff --git a/src/drivers/include/bluetooth.hpp b/src/drivers/include/bluetooth.hpp index 00ddb0c0..6464c8de 100644 --- a/src/drivers/include/bluetooth.hpp +++ b/src/drivers/include/bluetooth.hpp @@ -36,13 +36,6 @@ class Bluetooth { auto IsConnected() -> bool; auto ConnectedDevice() -> std::optional; - /* - * Sets whether or not the bluetooth stack is allowed to actively scan for - * new devices. - */ - auto SetDeviceDiscovery(bool) -> void; - auto IsDiscovering() -> bool; - auto KnownDevices() -> std::vector; auto SetPreferredDevice(std::optional dev) -> void; @@ -62,7 +55,6 @@ struct Disable : public tinyfsm::Event {}; struct PreferredDeviceChanged : public tinyfsm::Event {}; struct SourceChanged : public tinyfsm::Event {}; -struct DiscoveryChanged : public tinyfsm::Event {}; struct DeviceDiscovered : public tinyfsm::Event { const Device& device; }; @@ -134,7 +126,6 @@ class BluetoothState : public tinyfsm::Fsm { virtual void react(const events::Disable& ev) = 0; virtual void react(const events::PreferredDeviceChanged& ev){}; virtual void react(const events::SourceChanged& ev){}; - virtual void react(const events::DiscoveryChanged&); virtual void react(const events::ChangeVolume&) {} virtual void react(const events::DeviceDiscovered&); @@ -151,23 +142,22 @@ class BluetoothState : public tinyfsm::Fsm { static std::map sDevices_; static std::optional sPreferredDevice_; static std::optional sConnectingDevice_; - static bool sIsDiscoveryAllowed_; static std::atomic sSource_; static std::function sEventHandler_; + + auto connect(const bluetooth::MacAndName&) -> void; }; class Disabled : public BluetoothState { public: void entry() override; - void exit() override; void react(const events::Enable& ev) override; void react(const events::Disable& ev) override{}; void react(const events::internal::Gap& ev) override {} void react(const events::internal::A2dp& ev) override {} - void react(const events::DiscoveryChanged& ev) override{}; using BluetoothState::react; }; diff --git a/src/drivers/include/bluetooth_types.hpp b/src/drivers/include/bluetooth_types.hpp index 87da0ab5..74434182 100644 --- a/src/drivers/include/bluetooth_types.hpp +++ b/src/drivers/include/bluetooth_types.hpp @@ -27,7 +27,6 @@ enum class Event { kKnownDevicesChanged, kConnectionStateChanged, kPreferredDeviceChanged, - kDiscoveryChanged, }; } // namespace bluetooth -- cgit v1.2.3