mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 02:30:38 -08:00
example 'meshtastic': review WiFi mode
This commit is contained in:
parent
df62fd4a21
commit
5e16e9594e
7 changed files with 90 additions and 45 deletions
|
|
@ -59,7 +59,7 @@ win32 {
|
||||||
|
|
||||||
android {
|
android {
|
||||||
QT += remoteobjects
|
QT += remoteobjects
|
||||||
DEFINES += INI_ASDF
|
DEFINES += INI_ASDF NO_USB
|
||||||
DEFINES -= DESKTOP_APP
|
DEFINES -= DESKTOP_APP
|
||||||
INCLUDEPATH = $$ECL/include
|
INCLUDEPATH = $$ECL/include
|
||||||
ECL_VERSION = $$lower($$system($$ECL/../ecl-android-host/bin/ecl -v))
|
ECL_VERSION = $$lower($$system($$ECL/../ecl-android-host/bin/ecl -v))
|
||||||
|
|
@ -105,7 +105,8 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
ios {
|
ios {
|
||||||
DEFINES += INI_ASDF
|
QT -= serialport
|
||||||
|
DEFINES += INI_ASDF NO_USB NO_WIFI
|
||||||
DEFINES -= DESKTOP_APP
|
DEFINES -= DESKTOP_APP
|
||||||
INCLUDEPATH = $$(ECL_IOS)/include
|
INCLUDEPATH = $$(ECL_IOS)/include
|
||||||
ECL_VERSION = $$lower($$system($ECL_IOS/../ecl-ios-host/bin/ecl -v))
|
ECL_VERSION = $$lower($$system($ECL_IOS/../ecl-ios-host/bin/ecl -v))
|
||||||
|
|
@ -177,6 +178,15 @@ SOURCES += \
|
||||||
cpp/connection/wifi/wifi_me.cpp
|
cpp/connection/wifi/wifi_me.cpp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ios {
|
||||||
|
HEADERS -= \
|
||||||
|
cpp/connection/usb/usb_me.h \
|
||||||
|
cpp/connection/wifi/wifi_me.h
|
||||||
|
SOURCES -= \
|
||||||
|
cpp/connection/usb/usb_me.cpp \
|
||||||
|
cpp/connection/wifi/wifi_me.cpp
|
||||||
|
}
|
||||||
|
|
||||||
RESOURCES += $$files(qml/*)
|
RESOURCES += $$files(qml/*)
|
||||||
RESOURCES += $$files(i18n/*.qm)
|
RESOURCES += $$files(i18n/*.qm)
|
||||||
RESOURCES += $$files(lisp/proto/meshtastic/*.lisp)
|
RESOURCES += $$files(lisp/proto/meshtastic/*.lisp)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
QT += core bluetooth remoteobjects
|
QT += core bluetooth network remoteobjects
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += c++17 dll
|
CONFIG += c++17 dll
|
||||||
|
DEFINES += NO_USB
|
||||||
INCLUDEPATH += $$PWD
|
INCLUDEPATH += $$PWD
|
||||||
TARGET = service
|
TARGET = service
|
||||||
DESTDIR = ../../build-android
|
DESTDIR = ../../build-android
|
||||||
OBJECTS_DIR = ./tmp
|
OBJECTS_DIR = ./tmp
|
||||||
MOC_DIR = ./tmp
|
MOC_DIR = ./tmp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,22 @@
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "ble/ble_me.h"
|
#include "ble/ble_me.h"
|
||||||
#include "wifi/wifi_me.h"
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#ifndef NO_USB
|
||||||
|
#include "usb/usb_me.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_WIFI
|
||||||
|
#include "wifi/wifi_me.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
#include "../android_service/qtandroidservice_ro.h"
|
#include "../android_service/qtandroidservice_ro.h"
|
||||||
#if (QT_VERSION < 0x060000)
|
#if (QT_VERSION < 0x060000)
|
||||||
#include <QAndroidService>
|
#include <QAndroidService>
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#include "usb/usb_me.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
|
|
@ -25,8 +30,12 @@ Connection::Connection(QtAndroidService* service) {
|
||||||
#else
|
#else
|
||||||
Connection::Connection() {
|
Connection::Connection() {
|
||||||
ble = new BLE_ME(this);
|
ble = new BLE_ME(this);
|
||||||
|
#ifndef NO_USB
|
||||||
usb = new USB_ME(this);
|
usb = new USB_ME(this);
|
||||||
|
#endif
|
||||||
|
#ifndef NO_WIFI
|
||||||
wifi = new WiFi_ME(this);
|
wifi = new WiFi_ME(this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -38,25 +47,31 @@ void Connection::setConnectionType(const QVariant& var) {
|
||||||
void Connection::startDeviceDiscovery(const QVariant& var) {
|
void Connection::startDeviceDiscovery(const QVariant& var) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BLE:
|
case BLE:
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef NO_USB
|
||||||
usb->disconnect();
|
usb->disconnect();
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef NO_WIFI
|
||||||
wifi->disconnect();
|
wifi->disconnect();
|
||||||
|
#endif
|
||||||
ble->startDeviceDiscovery(var.toString());
|
ble->startDeviceDiscovery(var.toString());
|
||||||
break;
|
break;
|
||||||
case USB:
|
case USB:
|
||||||
ble->disconnect();
|
ble->disconnect();
|
||||||
|
#ifndef NO_WIFI
|
||||||
wifi->disconnect();
|
wifi->disconnect();
|
||||||
#ifndef Q_OS_ANDROID
|
#endif
|
||||||
|
#ifndef NO_USB
|
||||||
usb->connectToRadio();
|
usb->connectToRadio();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case WiFi:
|
case WiFi:
|
||||||
ble->disconnect();
|
ble->disconnect();
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef NO_USB
|
||||||
usb->disconnect();
|
usb->disconnect();
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef NO_WIFI
|
||||||
wifi->connectToRadio(var.toString());
|
wifi->connectToRadio(var.toString());
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,10 +83,12 @@ void Connection::stopDeviceDiscovery() {
|
||||||
void Connection::disconnect() {
|
void Connection::disconnect() {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BLE: ble->disconnect(); break;
|
case BLE: ble->disconnect(); break;
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef NO_USB
|
||||||
case USB: usb->disconnect(); break;
|
case USB: usb->disconnect(); break;
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef NO_WIFI
|
||||||
case WiFi: wifi->disconnect(); break;
|
case WiFi: wifi->disconnect(); break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,17 +103,13 @@ void Connection::read2() {
|
||||||
void Connection::write2(const QVariant& vBytes) {
|
void Connection::write2(const QVariant& vBytes) {
|
||||||
QByteArray bytes = vBytes.toByteArray();
|
QByteArray bytes = vBytes.toByteArray();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BLE:
|
case BLE: ble->write(bytes); break;
|
||||||
ble->write(bytes);
|
#ifndef NO_USB
|
||||||
break;
|
case USB: usb->write2(bytes); break;
|
||||||
case USB:
|
#endif
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef NO_WIFI
|
||||||
usb->write2(bytes);
|
case WiFi: wifi->write2(bytes); break;
|
||||||
#endif
|
#endif
|
||||||
break;
|
|
||||||
case WiFi:
|
|
||||||
wifi->write2(bytes);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,13 @@
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
class BLE_ME;
|
class BLE_ME;
|
||||||
class USB_ME;
|
|
||||||
class WiFi_ME;
|
#ifndef NO_USB
|
||||||
|
class USB_ME;
|
||||||
|
#endif
|
||||||
|
#ifndef NO_WIFI
|
||||||
|
class WiFi_ME;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
class QtAndroidService;
|
class QtAndroidService;
|
||||||
|
|
@ -27,8 +32,12 @@ public:
|
||||||
|
|
||||||
Type type = BLE;
|
Type type = BLE;
|
||||||
BLE_ME* ble = nullptr;
|
BLE_ME* ble = nullptr;
|
||||||
|
#ifndef NO_USB
|
||||||
USB_ME* usb = nullptr;
|
USB_ME* usb = nullptr;
|
||||||
|
#endif
|
||||||
|
#ifndef NO_WIFI
|
||||||
WiFi_ME* wifi = nullptr;
|
WiFi_ME* wifi = nullptr;
|
||||||
|
#endif
|
||||||
bool backgroundMode = false;
|
bool backgroundMode = false;
|
||||||
|
|
||||||
void setConnectionType(const QVariant&);
|
void setConnectionType(const QVariant&);
|
||||||
|
|
|
||||||
|
|
@ -106,12 +106,16 @@ QT::QT() : QObject() {
|
||||||
// background mode
|
// background mode
|
||||||
QObject::connect(qGuiApp, &QGuiApplication::applicationStateChanged,
|
QObject::connect(qGuiApp, &QGuiApplication::applicationStateChanged,
|
||||||
[&](Qt::ApplicationState state) {
|
[&](Qt::ApplicationState state) {
|
||||||
|
static bool ok = false; // for startup
|
||||||
if (state == Qt::ApplicationInactive) {
|
if (state == Qt::ApplicationInactive) {
|
||||||
|
ok = true;
|
||||||
con->setBackgroundMode(true);
|
con->setBackgroundMode(true);
|
||||||
ecl_fun("app:background-mode-changed", true);
|
ecl_fun("app:background-mode-changed", true);
|
||||||
} else if (state == Qt::ApplicationActive) {
|
} else if (state == Qt::ApplicationActive) {
|
||||||
con->setBackgroundMode(false);
|
if (ok) {
|
||||||
ecl_fun("app:background-mode-changed", false);
|
con->setBackgroundMode(false);
|
||||||
|
ecl_fun("app:background-mode-changed", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -52,21 +52,8 @@ To manually restart device discovery, press-and-hold on the radio icon.
|
||||||
If your radio is not found, it may help to turn it off/on again.
|
If your radio is not found, it may help to turn it off/on again.
|
||||||
</p>
|
</p>
|
||||||
%1
|
%1
|
||||||
<h4>USB</h4>
|
%2
|
||||||
Desktop only. You may need to install serial drivers first, and you need to use a data USB cable.
|
%3
|
||||||
<h4>WiFi</h4>
|
|
||||||
<p>
|
|
||||||
Use the Python CLI to setup your connection like this:
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
meshtastic \
|
|
||||||
--set network.wifi_enabled true \
|
|
||||||
--set network.wifi_ssid \"<name>\" \
|
|
||||||
--set network.wifi_psk \"<password>\"
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
The app will ask for your radio IP, which can be found on its screen as soon as it is connected to WiFi.
|
|
||||||
</p>
|
|
||||||
<h3>
|
<h3>
|
||||||
<img src='../../img/group.png' width=60 height=60>
|
<img src='../../img/group.png' width=60 height=60>
|
||||||
<br>Group
|
<br>Group
|
||||||
|
|
@ -146,9 +133,29 @@ Eventual backups are saved in above path under <code>backups/</code>. On the des
|
||||||
<p>
|
<p>
|
||||||
To autmatically restore data from a backup on the desktop, put the backup files directly in above path (that is, under <code>.../cl-meshtastic/</code>) and restart the app. The data will be restored and the (obsolete) backup files will be deleted.
|
To autmatically restore data from a backup on the desktop, put the backup files directly in above path (that is, under <code>.../cl-meshtastic/</code>) and restart the app. The data will be restored and the (obsolete) backup files will be deleted.
|
||||||
</p>".arg((Qt.platform.os === "android")
|
</p>".arg((Qt.platform.os === "android")
|
||||||
? "<p>On some devices it may be necessary to first unpair your radio, then press-and-hold on the radio icon (to restart device discovery).</p><p><i>N.B: If you previously used a radio with the official app, you'll need to set the radio to 'None (disabled)' in the official app first, otherwise it will not show up in this app.</i></p>"
|
? "<p>On some devices it may be necessary to first unpair your radio, then press-and-hold on the radio icon (to restart device discovery).</p><p><i>N.B: If you previously used a radio with the official app, you'll need to disable the radio in the official app first, otherwise it will not show up in this app.</i></p>"
|
||||||
|
: "")
|
||||||
|
.arg(((Qt.platform.os !== "android") && (Qt.platform.os !== "ios"))
|
||||||
|
? "<h4>USB</h4>
|
||||||
|
<p>
|
||||||
|
You may need to install serial drivers first, and you need to use a data USB cable.
|
||||||
|
</p>"
|
||||||
|
: "")
|
||||||
|
.arg((Qt.platform.os !== "ios")
|
||||||
|
? "<h4>WiFi</h4>
|
||||||
|
<p>
|
||||||
|
Use the Python CLI to setup your connection like this:
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
meshtastic \
|
||||||
|
--set network.wifi_enabled true \
|
||||||
|
--set network.wifi_ssid \"<name>\" \
|
||||||
|
--set network.wifi_psk \"<password>\"
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
The app will ask for your radio IP, which can be found on its screen as soon as it is connected to WiFi.
|
||||||
|
</p>"
|
||||||
: "")
|
: "")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ Item {
|
||||||
text: "WiFi"
|
text: "WiFi"
|
||||||
autoExclusive: true
|
autoExclusive: true
|
||||||
checkable: true
|
checkable: true
|
||||||
|
enabled: (Qt.platform.os !== "ios")
|
||||||
onTriggered: connection.changed(objectName)
|
onTriggered: connection.changed(objectName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue