diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-01-17 11:48:40 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-01-17 11:48:40 +1100 |
| commit | 71b46730394979ea528d152dbe884cc35c368759 (patch) | |
| tree | 516b3af32f8822a5f900ea10fd6ffba2e3de1ebb /src/drivers/include | |
| parent | 7cdcd44e0ca10ebdc796638190ed1d9b45d99ef0 (diff) | |
| download | tangara-fw-71b46730394979ea528d152dbe884cc35c368759.tar.gz | |
all screens basically working, but bluetooth is rough
Diffstat (limited to 'src/drivers/include')
| -rw-r--r-- | src/drivers/include/bluetooth.hpp | 10 | ||||
| -rw-r--r-- | src/drivers/include/bluetooth_types.hpp | 2 | ||||
| -rw-r--r-- | src/drivers/include/nvs.hpp | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/drivers/include/bluetooth.hpp b/src/drivers/include/bluetooth.hpp index f3623fb8..4aefbc42 100644 --- a/src/drivers/include/bluetooth.hpp +++ b/src/drivers/include/bluetooth.hpp @@ -32,14 +32,20 @@ class Bluetooth { auto Disable() -> void; auto IsEnabled() -> bool; + auto IsConnected() -> bool; + auto ConnectedDevice() -> std::optional<bluetooth::Device>; + /* * 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<bluetooth::Device>; + auto SetPreferredDevice(const bluetooth::mac_addr_t& mac) -> void; + auto PreferredDevice() -> std::optional<bluetooth::mac_addr_t>; auto SetSource(StreamBufferHandle_t) -> void; auto SetEventHandler(std::function<void(bluetooth::Event)> cb) -> void; @@ -100,9 +106,11 @@ class BluetoothState : public tinyfsm::Fsm<BluetoothState> { static auto Init(NvsStorage& storage) -> void; static auto devices() -> std::vector<Device>; + static auto preferred_device() -> std::optional<mac_addr_t>; static auto preferred_device(std::optional<mac_addr_t>) -> void; + static auto scanning() -> bool; static auto discovery() -> bool; static auto discovery(bool) -> void; @@ -135,7 +143,7 @@ class BluetoothState : public tinyfsm::Fsm<BluetoothState> { static std::mutex sDevicesMutex_; static std::map<mac_addr_t, Device> sDevices_; static std::optional<mac_addr_t> sPreferredDevice_; - static mac_addr_t sCurrentDevice_; + static std::optional<Device> sCurrentDevice_; static bool sIsDiscoveryAllowed_; static std::atomic<StreamBufferHandle_t> sSource_; diff --git a/src/drivers/include/bluetooth_types.hpp b/src/drivers/include/bluetooth_types.hpp index 7e26f0d7..518771e5 100644 --- a/src/drivers/include/bluetooth_types.hpp +++ b/src/drivers/include/bluetooth_types.hpp @@ -21,6 +21,8 @@ struct Device { enum class Event { kKnownDevicesChanged, kConnectionStateChanged, + kPreferredDeviceChanged, + kDiscoveryChanged, }; } // namespace bluetooth diff --git a/src/drivers/include/nvs.hpp b/src/drivers/include/nvs.hpp index b82013b5..bf0bebab 100644 --- a/src/drivers/include/nvs.hpp +++ b/src/drivers/include/nvs.hpp @@ -67,4 +67,4 @@ class NvsStorage { nvs_handle_t handle_; }; -} // namespace drivers
\ No newline at end of file +} // namespace drivers |
