Connect the app to MQTT and show the connection status (iteration 2, step 4)

Dashboard creates the MQTT client and the HA device with the dummy
"Uptime" sensor (D41) in overlay and both desktop modes, connects in
started() and disconnects gracefully on aboutToQuit. The new platform
mode --desktop-novr behaves like --desktop for now (D22). The main tab
shows device, broker, connection state and last error (UI-1) through
the ConnectionStatus QML singleton.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 16:18:17 +02:00
co-authored by Claude Opus 5.5
parent 466743eff9
commit 943e90c1b1
15 changed files with 335 additions and 32 deletions
+3
View File
@@ -33,6 +33,9 @@ add_test(NAME surfaces_cli_key COMMAND tst_surfaces --graphics-api opengl)
set_tests_properties(surfaces_cli_key PROPERTIES ENVIRONMENT "VRDASH_TEST_CLI_KEY=1")
add_test(NAME surfaces_prepare_fail COMMAND tst_surfaces --graphics-api opengl)
set_tests_properties(surfaces_prepare_fail PROPERTIES ENVIRONMENT "VRDASH_TEST_PREPARE_FAIL=1")
add_test(NAME surfaces_desktop_novr COMMAND tst_surfaces)
set_tests_properties(surfaces_desktop_novr PROPERTIES
ENVIRONMENT "VRDASH_TEST_DESKTOP_NOVR=1;QT_QPA_PLATFORM=offscreen")
set_tests_properties(surfaces_opengl surfaces_vulkan surfaces_cli_key
PROPERTIES SKIP_RETURN_CODE 77)
+15 -4
View File
@@ -4,6 +4,8 @@
// scene. No SteamVR involved.
// VRDASH_TEST_PREPARE_FAIL=1: prepare() fails, so exec() must return 1
// without calling the other hooks.
// VRDASH_TEST_DESKTOP_NOVR=1: --desktop-novr instead of --snapshot; prepare()
// checks the mode and then fails (no window, no event loop).
// Exit codes: 0 pass, 1 fail, 77 skipped (no GPU context).
#include <QCommandLineOption>
@@ -46,6 +48,7 @@ class TwoSurfaceApp : public DashboardApplication {
}
QString expectedKey; // --app-key overrides setAppKey()
DashboardMode expectedMode = DashboardMode::Snapshot;
bool failPrepare = false;
int prepareCalls = 0;
int loadingCalls = 0;
@@ -58,7 +61,7 @@ class TwoSurfaceApp : public DashboardApplication {
ok &= check(loadingCalls == 0 && startedCalls == 0, "prepare() first");
ok &= check(engine() == nullptr && surfaces().isEmpty(),
"prepare() before engine and surfaces");
ok &= check(mode() == DashboardMode::Snapshot, "mode in prepare()");
ok &= check(mode() == expectedMode, "mode in prepare()");
ok &= check(appKey() == expectedKey, "app key in prepare()");
ok &= check(
isOptionSet(QStringLiteral("test-value")) &&
@@ -108,10 +111,17 @@ int main(int argc, char* argv[]) {
QDir(dir.path()).filePath(QStringLiteral("shot.png")).toStdString();
// VRDASH_TEST_CLI_KEY=1: also pass --app-key (must win over setAppKey()).
const bool cliKey = qEnvironmentVariableIntValue("VRDASH_TEST_CLI_KEY");
const bool desktopNoVr =
qEnvironmentVariableIntValue("VRDASH_TEST_DESKTOP_NOVR");
const bool failPrepare =
qEnvironmentVariableIntValue("VRDASH_TEST_PREPARE_FAIL");
std::vector<std::string> args = {argv[0], "--snapshot", snapshot,
"--test-value", "42"};
qEnvironmentVariableIntValue("VRDASH_TEST_PREPARE_FAIL") || desktopNoVr;
std::vector<std::string> args = {argv[0], "--test-value", "42"};
if (desktopNoVr) {
args.emplace_back("--desktop-novr");
} else {
args.emplace_back("--snapshot");
args.emplace_back(snapshot);
}
if (cliKey) {
args.emplace_back("--app-key");
args.emplace_back("cli.key");
@@ -125,6 +135,7 @@ int main(int argc, char* argv[]) {
app.expectedKey =
cliKey ? QStringLiteral("cli.key") : QStringLiteral("config.key");
app.failPrepare = failPrepare;
if (desktopNoVr) app.expectedMode = DashboardMode::DesktopNoVr;
const int result = app.exec();
if (failPrepare) {
bool ok = app.ok;