example 'meshtastic': add background mode for android (very limited for now)

This commit is contained in:
pls.153 2024-02-27 19:36:17 +01:00
parent 4a9434d7ea
commit c2890cd6c4
13 changed files with 127 additions and 237 deletions

View file

@ -3,6 +3,7 @@
#include <QSqlError>
#include <QNetworkInterface>
#include <QHostAddress>
#include <QGuiApplication>
#include <QtDebug>
#ifdef PLUGIN
@ -105,6 +106,27 @@ QT::QT() : QObject() {
[]() {
ecl_fun("lora:receiving-done");
});
#ifdef Q_OS_ANDROID
QObject::connect(ble.data(), &QtAndroidServiceReplica::sendSavedPackets,
#else
QObject::connect(ble, &BLE_ME::sendSavedPackets,
#endif
[](const QVariant& packets) {
ecl_fun("lora:process-saved-packets", packets);
});
#if (defined Q_OS_ANDROID) || (defined Q_OS_IOS)
// background mode
QObject::connect(qGuiApp, &QGuiApplication::applicationStateChanged,
[&](Qt::ApplicationState state) {
if (state == Qt::ApplicationInactive) {
ble->setBackgroundMode(true);
} else if (state == Qt::ApplicationActive) {
ble->setBackgroundMode(false);
}
});
#endif
}
// BLE
@ -129,6 +151,11 @@ QVariant QT::write2(const QVariant& bytes) {
return QVariant();
}
QVariant QT::setBackgroundMode(const QVariant& vBackground) {
// for testing
ble->setBackgroundMode(vBackground.toBool());
}
// GPS
#ifdef Q_OS_ANDROID