summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcooljqln <cooljqln@noreply.codeberg.org>2024-02-05 23:24:42 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2024-02-05 23:24:42 +0000
commit0731a3fbcc5f68b8f36cb5e946f34fff78f0339e (patch)
treeaa58096c72443f60a2ab7d5170c644f685e94a93 /src
parent8c628590b2c7b573aa8bea18f1f0eaa48eb58102 (diff)
parentd78bbccdab6a0bc51e35e08379d4ac950917a61d (diff)
downloadtangara-fw-0731a3fbcc5f68b8f36cb5e946f34fff78f0339e.tar.gz
Merge pull request 'Add version command' (#29) from hails/tangara-fw:version-command into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/29
Diffstat (limited to 'src')
-rw-r--r--src/app_console/app_console.cpp19
-rw-r--r--src/database/database.cpp1
-rw-r--r--src/database/include/database.hpp2
3 files changed, 21 insertions, 1 deletions
diff --git a/src/app_console/app_console.cpp b/src/app_console/app_console.cpp
index 4742c940..6df63d5c 100644
--- a/src/app_console/app_console.cpp
+++ b/src/app_console/app_console.cpp
@@ -24,6 +24,7 @@
#include "audio_events.hpp"
#include "audio_fsm.hpp"
#include "database.hpp"
+#include "esp_app_desc.h"
#include "esp_console.h"
#include "esp_err.h"
#include "esp_heap_caps.h"
@@ -49,6 +50,23 @@ namespace console {
std::shared_ptr<system_fsm::ServiceLocator> AppConsole::sServices;
+int CmdVersion(int argc, char** argv) {
+ std::cout << "firmware-version=" << esp_app_get_description()->version << std::endl;
+ std::cout << "samd-version=" << AppConsole::sServices->samd().Version() << std::endl;
+ std::cout << "collation=" << AppConsole::sServices->collator().Describe().value_or("") << std::endl;
+ std::cout << "database-schema=" << uint32_t(database::kCurrentDbVersion) << std::endl;
+ return 0;
+}
+
+void RegisterVersion() {
+ esp_console_cmd_t cmd{.command = "version",
+ .help = "Displays firmware version information",
+ .hint = NULL,
+ .func = &CmdVersion,
+ .argtable = NULL};
+ esp_console_cmd_register(&cmd);
+}
+
int CmdListDir(int argc, char** argv) {
auto db = AppConsole::sServices->database().lock();
if (!db) {
@@ -666,6 +684,7 @@ void RegisterLua() {
}
auto AppConsole::RegisterExtraComponents() -> void {
+ RegisterVersion();
RegisterListDir();
RegisterPlayFile();
/*
diff --git a/src/database/database.cpp b/src/database/database.cpp
index 15e7060d..b596063c 100644
--- a/src/database/database.cpp
+++ b/src/database/database.cpp
@@ -56,7 +56,6 @@ static SingletonEnv<leveldb::EspEnv> sEnv;
static const char kDbPath[] = "/.tangara-db";
static const char kKeyDbVersion[] = "schema_version";
-static const uint8_t kCurrentDbVersion = 5;
static const char kKeyCustom[] = "U\0";
static const char kKeyCollator[] = "collator";
diff --git a/src/database/include/database.hpp b/src/database/include/database.hpp
index 783d3872..0aec4c44 100644
--- a/src/database/include/database.hpp
+++ b/src/database/include/database.hpp
@@ -35,6 +35,8 @@
namespace database {
+const uint8_t kCurrentDbVersion = 5;
+
struct SearchKey;
class Record;
class Iterator;