From c31b38917ada684448834cb4b7fc26f8a9764787 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 8 Nov 2024 12:06:19 +0100 Subject: [PATCH] Use QSettings to get watch.txt file path. onCCWakeGpioChanged(): remove obsolete code. --- src/hwapi.cpp | 66 ++++++++------------------------------------------- 1 file changed, 10 insertions(+), 56 deletions(-) diff --git a/src/hwapi.cpp b/src/hwapi.cpp index 846c915..69e66a3 100755 --- a/src/hwapi.cpp +++ b/src/hwapi.cpp @@ -16,6 +16,7 @@ #include #include #include +#include static uint32_t hwapi_lastStartAmount; @@ -58,9 +59,10 @@ hwapi::hwapi(QObject *parent) : QObject(parent) #error "SLAVE LIB COMPILED INTO MASTER" #endif + QSettings settings("/opt/app/ATBAPP/ATBQT.ini", QSettings::IniFormat); + m_watchedFile = settings.value("AsyncPOS_CCPlugin/terminal_watch_file", + "/opt/app/ATBAPP/watch.txt").toString(); - // m_sysfs_remout_out = "/sys/class/leds/wakeupctrl_cc/brightness"; - m_watchedFile = "/tmp/watch.txt"; m_fileSystemWatcher.reset(new QFileSystemWatcher()); if (!m_fileSystemWatcher->addPath(m_watchedFile)) { qCritical() << "cannot add path for" << m_watchedFile; @@ -135,67 +137,20 @@ hwapi::hwapi(QObject *parent) : QObject(parent) } void hwapi::onCCWakeGpioChanged(QString const &fileName) { - qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().toString(Qt::ISODateWithMs); if (fileName == m_watchedFile) { QFile f(m_watchedFile); if (f.open(QFile::ReadOnly | QFile::Text)) { QTextStream stream(&f); - //int sleepTime = 5000; QString const &content = stream.readAll(); if (content.startsWith("0")) { - //if (mod_isGsmPowerOn()) { - qCritical() << __func__ << ":" << __LINE__ << "OFF"; - mod_switchWake(false); - mod_switchPower(false); - //if (mod_isGsmPowerOn()) { // try again - // qCritical() << __func__ << ":" << __LINE__; - // stream << "0"; - // QThread::msleep(sleepTime); - //} - //} - - if (cred_isCreditPowerOn()) { // try again - //qCritical() << __func__ << ":" << __LINE__; - //credit_switchWake(false); - //credit_switchPower(false); - //if (cred_isCreditPowerOn()) { // try again - // qCritical() << __func__ << ":" << __LINE__; - // stream << "0"; - // QThread::msleep(sleepTime); - //} - } + qCritical() << __func__ << ":" << __LINE__ << "switching terminal off..."; + mod_switchWake(false); + mod_switchPower(false); } else if (content.startsWith("1")) { - //if (mod_isGsmPowerOn() == false) { - // static bool mod_powerOnCalled = false; - // if (mod_powerOnCalled == false) { - qCritical() << __func__ << ":" << __LINE__ << "ON"; - mod_switchPower(true); - mod_switchWake(true); - // mod_powerOnCalled = true; - // } - //if (mod_isGsmPowerOn() == false) { // try again - // mod_switchWake(true); - // qCritical() << __func__ << ":" << __LINE__; - // stream << "1"; - // QThread::msleep(sleepTime); - //} - //} - - if (cred_isCreditPowerOn() == false) { - // static bool cred_powerOnCalled = false; - //if (cred_powerOnCalled == false) { - // credit_switchPower(true); - // credit_switchWake(true); - // cred_powerOnCalled = true; - //} - //if (cred_isCreditPowerOn() == false) { // try again - // credit_switchWake(true); - // qCritical() << __func__ << ":" << __LINE__; - // stream << "1"; - // QThread::msleep(sleepTime); - //} - } + qCritical() << __func__ << ":" << __LINE__ << "switching terminal on..."; + mod_switchPower(true); + mod_switchWake(true); } else { qCritical() << "watched file contained" << content; } @@ -203,7 +158,6 @@ void hwapi::onCCWakeGpioChanged(QString const &fileName) { } else { qCritical() << "ERROR watching the wrong file" << fileName; } - qCritical() << __func__ << ":" << __LINE__ << QDateTime::currentDateTime().toString(Qt::ISODateWithMs); } void hwapi::hwapi_slotPayProc(void)