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
custom
jacqueline 2 months ago
parent 1d1cae2a82
commit 826190edcf
  1. 6
      src/drivers/bluetooth.cpp
  2. 2
      src/drivers/include/drivers/bluetooth.hpp

@ -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();
}

@ -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>;

Loading…
Cancel
Save