diff options
Diffstat (limited to 'src/drivers/include')
| -rw-r--r-- | src/drivers/include/bluetooth.hpp | 15 | ||||
| -rw-r--r-- | src/drivers/include/bluetooth_types.hpp | 5 | ||||
| -rw-r--r-- | src/drivers/include/nvs.hpp | 4 |
3 files changed, 16 insertions, 8 deletions
diff --git a/src/drivers/include/bluetooth.hpp b/src/drivers/include/bluetooth.hpp index 4aefbc42..291d049d 100644 --- a/src/drivers/include/bluetooth.hpp +++ b/src/drivers/include/bluetooth.hpp @@ -44,8 +44,8 @@ class Bluetooth { auto KnownDevices() -> std::vector<bluetooth::Device>; - auto SetPreferredDevice(const bluetooth::mac_addr_t& mac) -> void; - auto PreferredDevice() -> std::optional<bluetooth::mac_addr_t>; + auto SetPreferredDevice(std::optional<bluetooth::MacAndName> dev) -> void; + auto PreferredDevice() -> std::optional<bluetooth::MacAndName>; auto SetSource(StreamBufferHandle_t) -> void; auto SetEventHandler(std::function<void(bluetooth::Event)> cb) -> void; @@ -107,8 +107,8 @@ class BluetoothState : public tinyfsm::Fsm<BluetoothState> { 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 preferred_device() -> std::optional<bluetooth::MacAndName>; + static auto preferred_device(std::optional<bluetooth::MacAndName>) -> void; static auto scanning() -> bool; static auto discovery() -> bool; @@ -142,8 +142,8 @@ 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 std::optional<Device> sCurrentDevice_; + static std::optional<bluetooth::MacAndName> sPreferredDevice_; + static std::optional<bluetooth::MacAndName> sConnectingDevice_; static bool sIsDiscoveryAllowed_; static std::atomic<StreamBufferHandle_t> sSource_; @@ -205,6 +205,9 @@ class Connected : public BluetoothState { void react(const events::internal::Avrc& ev) override; using BluetoothState::react; + + private: + mac_addr_t connected_to_; }; } // namespace bluetooth diff --git a/src/drivers/include/bluetooth_types.hpp b/src/drivers/include/bluetooth_types.hpp index 518771e5..87da0ab5 100644 --- a/src/drivers/include/bluetooth_types.hpp +++ b/src/drivers/include/bluetooth_types.hpp @@ -11,6 +11,11 @@ namespace bluetooth { typedef std::array<uint8_t, 6> mac_addr_t; +struct MacAndName { + mac_addr_t mac; + std::string name; +}; + struct Device { mac_addr_t address; std::pmr::string name; diff --git a/src/drivers/include/nvs.hpp b/src/drivers/include/nvs.hpp index f592b1c3..1184b72c 100644 --- a/src/drivers/include/nvs.hpp +++ b/src/drivers/include/nvs.hpp @@ -25,8 +25,8 @@ class NvsStorage { auto LockPolarity() -> bool; auto LockPolarity(bool) -> bool; - auto PreferredBluetoothDevice() -> std::optional<bluetooth::mac_addr_t>; - auto PreferredBluetoothDevice(std::optional<bluetooth::mac_addr_t>) -> bool; + auto PreferredBluetoothDevice() -> std::optional<bluetooth::MacAndName>; + auto PreferredBluetoothDevice(std::optional<bluetooth::MacAndName>) -> bool; enum class Output : uint8_t { kHeadphones = 0, |
