From 91a0f88cd9db6febccc438262219343e4b445802 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Mon, 11 Nov 2024 16:20:15 +0100 Subject: [PATCH] hwapi::onCCWakeGpioChanged(): when switching cc-terminal off, send 0 to watch-file (watched by a filesystem watcher). when switching cc-terminal on, send 1 to watch-file (watched by a filesystem watcher). --- src/hwapi.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/hwapi.cpp b/src/hwapi.cpp index 69e66a3..22f9c2c 100755 --- a/src/hwapi.cpp +++ b/src/hwapi.cpp @@ -146,11 +146,25 @@ void hwapi::onCCWakeGpioChanged(QString const &fileName) { qCritical() << __func__ << ":" << __LINE__ << "switching terminal off..."; mod_switchWake(false); mod_switchPower(false); + f.close(); + f.setFileName(m_watchedFile); + // to turn off cc-terminal, the content must be "0" + if (f.open(QFile::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { + QTextStream s(&f); + s << "switching terminal off"; + } } else if (content.startsWith("1")) { qCritical() << __func__ << ":" << __LINE__ << "switching terminal on..."; mod_switchPower(true); mod_switchWake(true); + f.close(); + f.setFileName(m_watchedFile); + // to turn on cc-terminal, the content must be "1" + if (f.open(QFile::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { + QTextStream s(&f); + s << "switching terminal on"; + } } else { qCritical() << "watched file contained" << content; }