summaryrefslogtreecommitdiff
path: root/src/drivers/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/include')
-rw-r--r--src/drivers/include/bluetooth.hpp9
-rw-r--r--src/drivers/include/bluetooth_types.hpp5
2 files changed, 12 insertions, 2 deletions
diff --git a/src/drivers/include/bluetooth.hpp b/src/drivers/include/bluetooth.hpp
index fc72d393..1489b790 100644
--- a/src/drivers/include/bluetooth.hpp
+++ b/src/drivers/include/bluetooth.hpp
@@ -26,15 +26,17 @@ namespace drivers {
*/
class Bluetooth {
public:
- Bluetooth(NvsStorage* storage);
+ Bluetooth(NvsStorage& storage);
auto Enable() -> bool;
auto Disable() -> void;
+ auto IsEnabled() -> bool;
auto KnownDevices() -> std::vector<bluetooth::Device>;
auto SetPreferredDevice(const bluetooth::mac_addr_t& mac) -> void;
auto SetSource(StreamBufferHandle_t) -> void;
+ auto SetEventHandler(std::function<void(bluetooth::Event)> cb) -> void;
};
namespace bluetooth {
@@ -64,7 +66,7 @@ struct Avrc : public tinyfsm::Event {
class BluetoothState : public tinyfsm::Fsm<BluetoothState> {
public:
- static auto Init(NvsStorage* storage) -> void;
+ static auto Init(NvsStorage& storage) -> void;
static auto devices() -> std::vector<Device>;
static auto preferred_device() -> std::optional<mac_addr_t>;
@@ -73,6 +75,8 @@ class BluetoothState : public tinyfsm::Fsm<BluetoothState> {
static auto source() -> StreamBufferHandle_t;
static auto source(StreamBufferHandle_t) -> void;
+ static auto event_handler(std::function<void(Event)>) -> void;
+
virtual ~BluetoothState(){};
virtual void entry() {}
@@ -96,6 +100,7 @@ class BluetoothState : public tinyfsm::Fsm<BluetoothState> {
static mac_addr_t sCurrentDevice_;
static std::atomic<StreamBufferHandle_t> sSource_;
+ static std::function<void(Event)> sEventHandler_;
};
class Disabled : public BluetoothState {
diff --git a/src/drivers/include/bluetooth_types.hpp b/src/drivers/include/bluetooth_types.hpp
index 03100651..12ed5cb3 100644
--- a/src/drivers/include/bluetooth_types.hpp
+++ b/src/drivers/include/bluetooth_types.hpp
@@ -16,5 +16,10 @@ struct Device {
int8_t signal_strength;
};
+enum class Event {
+ kKnownDevicesChanged,
+ kConnectionStateChanged,
+};
+
} // namespace bluetooth
} // namespace drivers