Compare commits
3 Commits
c337b6e50e
...
palanga-sw
Author | SHA1 | Date | |
---|---|---|---|
91a0f88cd9 | |||
c31b38917a | |||
fe1351fcca |
@@ -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;
|
||||
@@ -137,62 +139,31 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
|
||||
void hwapi::onCCWakeGpioChanged(QString const &fileName) {
|
||||
if (fileName == m_watchedFile) {
|
||||
QFile f(m_watchedFile);
|
||||
if (f.open(QFile::ReadWrite | QFile::Text)) {
|
||||
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__;
|
||||
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);
|
||||
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")) {
|
||||
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);
|
||||
//}
|
||||
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;
|
||||
|
Reference in New Issue
Block a user