summaryrefslogtreecommitdiff
path: root/src/system_fsm/booting.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-09-22 15:48:41 +1000
committerjacqueline <me@jacqueline.id.au>2023-09-22 21:19:19 +1000
commitb192975cb1eeb4e6b7c7bf53cdf42701c55f034a (patch)
tree39755851543d596f2630704be9efb56be1f39bfc /src/system_fsm/booting.cpp
parentcbd99b2134c6c471708deb409a4b0fcc4c31516d (diff)
downloadtangara-fw-b192975cb1eeb4e6b7c7bf53cdf42701c55f034a.tar.gz
make bluetooth pairing ui functional
Diffstat (limited to 'src/system_fsm/booting.cpp')
-rw-r--r--src/system_fsm/booting.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp
index 006ed395..28cd8cf6 100644
--- a/src/system_fsm/booting.cpp
+++ b/src/system_fsm/booting.cpp
@@ -11,6 +11,7 @@
#include "audio_fsm.hpp"
#include "battery.hpp"
#include "bluetooth.hpp"
+#include "bluetooth_types.hpp"
#include "core/lv_obj.h"
#include "display_init.hpp"
#include "esp_err.h"
@@ -41,6 +42,12 @@ namespace states {
static const char kTag[] = "BOOT";
+static auto bt_event_cb(drivers::bluetooth::Event ev) -> void {
+ if (ev == drivers::bluetooth::Event::kKnownDevicesChanged) {
+ events::Ui().Dispatch(BluetoothDevicesChanged{});
+ }
+}
+
auto Booting::entry() -> void {
ESP_LOGI(kTag, "beginning tangara boot");
sServices.reset(new ServiceLocator());
@@ -71,9 +78,15 @@ auto Booting::entry() -> void {
sServices->track_queue(std::make_unique<audio::TrackQueue>());
sServices->tag_parser(std::make_unique<database::TagParserImpl>());
- // ESP_LOGI(kTag, "starting bluetooth");
- // sBluetooth.reset(new drivers::Bluetooth(sNvs.get()));
- // sBluetooth->Enable();
+ ESP_LOGI(kTag, "init bluetooth");
+ sServices->bluetooth(std::make_unique<drivers::Bluetooth>(sServices->nvs()));
+ sServices->bluetooth().SetEventHandler(bt_event_cb);
+
+ if (sServices->nvs().OutputMode().get() ==
+ drivers::NvsStorage::Output::kBluetooth) {
+ ESP_LOGI(kTag, "enabling bluetooth");
+ sServices->bluetooth().Enable();
+ }
BootComplete ev{.services = sServices};
events::Audio().Dispatch(ev);