diff options
| author | jacqueline <me@jacqueline.id.au> | 2025-03-05 13:26:44 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2025-03-05 13:26:44 +1100 |
| commit | 826190edcf14980f6a31f209552ec34d7fcbb746 (patch) | |
| tree | 943651c8faca4b7e8c2dca7358d3af5e4f175368 /src | |
| parent | 1d1cae2a82f5cc2596025da7d2c3f3a49cf59012 (diff) | |
| download | tangara-fw-826190edcf14980f6a31f209552ec34d7fcbb746.tar.gz | |
Emit a 'known devices changed' event when we forget a known device
Makes the Lua UI update immediately after running the bt_forget command
added in PR #289
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/bluetooth.cpp | 6 | ||||
| -rw-r--r-- | src/drivers/include/drivers/bluetooth.hpp | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/drivers/bluetooth.cpp b/src/drivers/bluetooth.cpp index 64e45e23..1fd80c51 100644 --- a/src/drivers/bluetooth.cpp +++ b/src/drivers/bluetooth.cpp @@ -188,6 +188,8 @@ auto Bluetooth::knownDevices() -> std::vector<bluetooth::MacAndName> { auto Bluetooth::forgetKnownDevice(const bluetooth::mac_addr_t& mac) -> void { nvs_.BluetoothName(mac, {}); + std::invoke(bluetooth::BluetoothState::eventHandler(), + bluetooth::SimpleEvent::kKnownDevicesChanged); } auto Bluetooth::discoveryEnabled(bool en) -> void { @@ -414,6 +416,10 @@ auto BluetoothState::pairedDevice(std::optional<MacAndName> dev) -> void { bluetooth::events::PairedDeviceChanged{}); } +auto BluetoothState::eventHandler() -> std::function<void(Event)>& { + return sEventHandler_; +} + auto BluetoothState::discovery() -> bool { return sScanner_->enabled(); } diff --git a/src/drivers/include/drivers/bluetooth.hpp b/src/drivers/include/drivers/bluetooth.hpp index b333bd15..7ee49e2a 100644 --- a/src/drivers/include/drivers/bluetooth.hpp +++ b/src/drivers/include/drivers/bluetooth.hpp @@ -162,6 +162,8 @@ class BluetoothState : public tinyfsm::Fsm<BluetoothState> { static auto pairedDevice() -> std::optional<bluetooth::MacAndName>; static auto pairedDevice(std::optional<bluetooth::MacAndName>) -> void; + static auto eventHandler() -> std::function<void(Event)>&; + static auto discovery() -> bool; static auto discovery(bool) -> void; static auto discoveredDevices() -> std::vector<Device>; |
