summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-05-22 16:52:50 +1000
committerjacqueline <me@jacqueline.id.au>2023-05-22 16:52:50 +1000
commit82830f995c561567c84b8ea74bc270ae0b488d30 (patch)
tree8e7eeea97b9358156ef33d4650f5676e03b5fbd1 /src
parentda977aaa3feb397c426563da8897d51ebeba8d1f (diff)
downloadtangara-fw-82830f995c561567c84b8ea74bc270ae0b488d30.tar.gz
Fix some logging, add transition to missing storage
Diffstat (limited to 'src')
-rw-r--r--src/system_fsm/booting.cpp2
-rw-r--r--src/system_fsm/include/system_fsm.hpp2
-rw-r--r--src/system_fsm/running.cpp10
3 files changed, 13 insertions, 1 deletions
diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp
index a2a920c8..d9ee6e45 100644
--- a/src/system_fsm/booting.cpp
+++ b/src/system_fsm/booting.cpp
@@ -74,7 +74,7 @@ auto Booting::entry() -> void {
}
auto Booting::react(const BootComplete& ev) -> void {
- ESP_LOGE(kTag, "bootup completely successfully");
+ ESP_LOGI(kTag, "bootup completely successfully");
// It's possible that the SAMD is currently exposing the SD card as a USB
// device. Make sure we don't immediately try to claim it.
if (sSamd && sSamd->ReadUsbMscStatus() ==
diff --git a/src/system_fsm/include/system_fsm.hpp b/src/system_fsm/include/system_fsm.hpp
index c537c6de..52c808ba 100644
--- a/src/system_fsm/include/system_fsm.hpp
+++ b/src/system_fsm/include/system_fsm.hpp
@@ -37,6 +37,7 @@ class SystemState : public tinyfsm::Fsm<SystemState> {
virtual void react(const StorageUnmountRequested&) {}
virtual void react(const internal::ReadyToUnmount&) {}
virtual void react(const StorageMounted&) {}
+ virtual void react(const StorageError&) {}
protected:
static std::shared_ptr<drivers::GpioExpander> sGpioExpander;
@@ -74,6 +75,7 @@ class Running : public SystemState {
void react(const StorageUnmountRequested&) override;
void react(const internal::ReadyToUnmount&) override;
+ void react(const StorageError&) override;
using SystemState::react;
};
diff --git a/src/system_fsm/running.cpp b/src/system_fsm/running.cpp
index e55989f1..39dd8158 100644
--- a/src/system_fsm/running.cpp
+++ b/src/system_fsm/running.cpp
@@ -11,11 +11,14 @@
namespace system_fsm {
namespace states {
+static const char kTag[] = "RUN";
+
/*
* Ensure the storage and database are both available. If either of these fails
* to open, then we assume it's an issue with the underlying SD card.
*/
void Running::entry() {
+ ESP_LOGI(kTag, "mounting sd card");
auto storage_res = drivers::SdStorage::Create(sGpioExpander.get());
if (storage_res.has_error()) {
events::Dispatch<StorageError, SystemState, audio::AudioState, ui::UiState>(
@@ -24,6 +27,7 @@ void Running::entry() {
}
sStorage.reset(storage_res.value());
+ ESP_LOGI(kTag, "opening database");
auto database_res = database::Database::Open();
if (database_res.has_error()) {
events::Dispatch<StorageError, SystemState, audio::AudioState, ui::UiState>(
@@ -32,6 +36,7 @@ void Running::entry() {
}
sDatabase.reset(database_res.value());
+ ESP_LOGI(kTag, "storage loaded okay");
events::Dispatch<StorageMounted, SystemState, audio::AudioState, ui::UiState>(
StorageMounted());
}
@@ -50,5 +55,10 @@ void Running::react(const internal::ReadyToUnmount& ev) {
transit<Unmounted>();
}
+void Running::react(const StorageError& ev) {
+ ESP_LOGW(kTag, "error loading storage");
+ transit<Unmounted>();
+}
+
} // namespace states
} // namespace system_fsm