Use QSettings to get watch.txt file path.

onCCWakeGpioChanged():

	remove obsolete code.
This commit is contained in:
Gerhard Hoffmann 2024-11-08 12:06:19 +01:00
parent fe1351fcca
commit c31b38917a

View File

@ -16,6 +16,7 @@
#include <QThread>
#include <QDebug>
#include <QFileSystemWatcher>
#include <QSettings>
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)