From c337b6e50eb17c07300a6986a54833d09a09901f Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 7 Nov 2024 14:14:58 +0100 Subject: [PATCH] hwapi::onCCWakeGpioChanged(): start implementation of slot for fileSystemWatcher. Seems to be enough to start only the modem, as the cc-terminal is connected to the modem. --- src/hwapi.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/hwapi.cpp b/src/hwapi.cpp index c4a6ede..df8b512 100755 --- a/src/hwapi.cpp +++ b/src/hwapi.cpp @@ -134,6 +134,75 @@ hwapi::hwapi(QObject *parent) : QObject(parent) connect(runProcess, SIGNAL(runProc_coinAttached()), this, SLOT(coinAttached())); } +void hwapi::onCCWakeGpioChanged(QString const &fileName) { + if (fileName == m_watchedFile) { + QFile f(m_watchedFile); + if (f.open(QFile::ReadWrite | QFile::Text)) { + QTextStream stream(&f); + int sleepTime = 5000; + QString const &content = stream.readAll(); + if (content.startsWith("0")) { + if (mod_isGsmPowerOn()) { + qCritical() << __func__ << ":" << __LINE__; + 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); + //} + } + } else + if (content.startsWith("1")) { + if (mod_isGsmPowerOn() == false) { + static bool mod_powerOnCalled = false; + if (mod_powerOnCalled == false) { + 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); + //} + } + } else { + qCritical() << "watched file contained" << content; + } + } + } else { + qCritical() << "ERROR watching the wrong file" << fileName; + } +} + void hwapi::hwapi_slotPayProc(void) {