mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 10:31:34 -08:00
example 'meshtastic': revisions of WiFi mode, add warning for iOS
This commit is contained in:
parent
3375444e83
commit
c45d53b3c5
17 changed files with 89 additions and 73 deletions
|
|
@ -37,7 +37,9 @@ Item {
|
|||
loader.item.open()
|
||||
}
|
||||
|
||||
function input(title, label, callback, text, maxLength, inputMask, from, to, value) {
|
||||
function input(label, callback, text, placeholderText,
|
||||
maxLength, inputMask, numbersOnly,
|
||||
from, to, value) {
|
||||
loader.active = false // force reload
|
||||
if (rootItem.mobile) {
|
||||
loader.source = "InputMobile.qml"
|
||||
|
|
@ -45,18 +47,19 @@ Item {
|
|||
loader.source = "Input.qml"
|
||||
}
|
||||
loader.active = true
|
||||
loader.item.title = title
|
||||
loader.item.label = label
|
||||
loader.item.callback = callback
|
||||
loader.item.text = text
|
||||
loader.item.placeholderText = placeholderText
|
||||
loader.item.maxLength = maxLength
|
||||
loader.item.inputMask = inputMask
|
||||
loader.item.numbersOnly = numbersOnly
|
||||
loader.item.from = from
|
||||
loader.item.to = to
|
||||
loader.item.value = value
|
||||
var keyboard = (text !== "")
|
||||
rootItem.showKeyboard(keyboard)
|
||||
var keyboard = (text !== "") || (placeholderText !== "")
|
||||
loader.item.open()
|
||||
if (keyboard) loader.item.setFocus()
|
||||
Qt.callLater(rootItem.showKeyboard, keyboard)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ Dialog {
|
|||
|
||||
property alias label: label.text
|
||||
property alias text: edit.text
|
||||
property alias placeholderText: edit.placeholderText
|
||||
property alias inputMask: edit.inputMask
|
||||
property alias maxLength: edit.maximumLength
|
||||
property alias from: spinBox.from
|
||||
property alias to: spinBox.to
|
||||
property alias value: spinBox.value
|
||||
property bool numbersOnly
|
||||
property string callback
|
||||
|
||||
function setFocus() { edit.forceActiveFocus() }
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ Dialog {
|
|||
|
||||
property alias label: label.text
|
||||
property alias text: edit.text
|
||||
property alias placeholderText: edit.placeholderText
|
||||
property alias inputMask: edit.inputMask
|
||||
property alias maxLength: edit.maximumLength
|
||||
property alias from: spinBox.from
|
||||
property alias to: spinBox.to
|
||||
property alias value: spinBox.value
|
||||
property bool numbersOnly
|
||||
property string callback
|
||||
|
||||
function setFocus() { edit.forceActiveFocus() }
|
||||
|
|
@ -36,6 +38,7 @@ Dialog {
|
|||
objectName: "dialog_line_edit"
|
||||
width: parent.width
|
||||
visible: !spinBox.visible
|
||||
inputMethodHints: numbersOnly ? Qt.ImhFormattedNumbersOnly : Qt.ImhNone
|
||||
}
|
||||
|
||||
SpinBox {
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ Item {
|
|||
Com.MenuItem {
|
||||
objectName: "WIFI"
|
||||
text: "WiFi"
|
||||
palette.windowText: (Qt.platform.os === "ios") ? "crimson" : palette.windowText
|
||||
autoExclusive: true
|
||||
checkable: true
|
||||
onTriggered: connection.changed(objectName)
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ android {
|
|||
|
||||
ios {
|
||||
QT -= serialport
|
||||
DEFINES += INI_ASDF NO_USB NO_WIFI
|
||||
DEFINES += INI_ASDF NO_USB
|
||||
DEFINES -= DESKTOP_APP
|
||||
INCLUDEPATH = $$(ECL_IOS)/include
|
||||
ECL_VERSION = $$lower($$system($ECL_IOS/../ecl-ios-host/bin/ecl -v))
|
||||
|
|
@ -180,11 +180,9 @@ SOURCES += \
|
|||
|
||||
ios {
|
||||
HEADERS -= \
|
||||
cpp/connection/usb/usb_me.h \
|
||||
cpp/connection/wifi/wifi_me.h
|
||||
cpp/connection/usb/usb_me.h
|
||||
SOURCES -= \
|
||||
cpp/connection/usb/usb_me.cpp \
|
||||
cpp/connection/wifi/wifi_me.cpp
|
||||
cpp/connection/usb/usb_me.cpp
|
||||
}
|
||||
|
||||
RESOURCES += $$files(qml/*)
|
||||
|
|
|
|||
|
|
@ -108,7 +108,9 @@ void BLE_ME::searchCharacteristics() {
|
|||
if (!con->backgroundMode) {
|
||||
QVariantList vNames;
|
||||
for (auto name : qAsConst(names)) { vNames << name; }
|
||||
emitter->setReady(QVariant(QVariantList() << true << currentDevice.name().right(4) << QVariant(vNames)));
|
||||
emitter->setReady(QVariant(QVariantList() << true
|
||||
<< currentDevice.name().right(4)
|
||||
<< QVariant(vNames)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -119,7 +121,8 @@ void BLE_ME::characteristicChanged(const QLowEnergyCharacteristic&,
|
|||
if (con->backgroundMode) {
|
||||
read();
|
||||
} else {
|
||||
emitter->receivedFromRadio(QVariant(QVariantList() << data << QString("notified")));
|
||||
emitter->receivedFromRadio(QVariant(QVariantList() << data
|
||||
<< QString("notified")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "connection.h"
|
||||
#include "ble/ble_me.h"
|
||||
#include "wifi/wifi_me.h"
|
||||
#include <QStandardPaths>
|
||||
#include <QFile>
|
||||
#include <QDataStream>
|
||||
|
|
@ -8,10 +9,6 @@
|
|||
#include "usb/usb_me.h"
|
||||
#endif
|
||||
|
||||
#ifndef NO_WIFI
|
||||
#include "wifi/wifi_me.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "../android_service/qtandroidservice_ro.h"
|
||||
#if (QT_VERSION < 0x060000)
|
||||
|
|
@ -30,12 +27,10 @@ Connection::Connection(QtAndroidService* service) {
|
|||
#else
|
||||
Connection::Connection() {
|
||||
ble = new BLE_ME(this);
|
||||
wifi = new WiFi_ME(this);
|
||||
#ifndef NO_USB
|
||||
usb = new USB_ME(this);
|
||||
#endif
|
||||
#ifndef NO_WIFI
|
||||
wifi = new WiFi_ME(this);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -50,17 +45,13 @@ void Connection::startDeviceDiscovery(const QVariant& var) {
|
|||
#ifndef NO_USB
|
||||
usb->disconnect();
|
||||
#endif
|
||||
#ifndef NO_WIFI
|
||||
wifi->disconnect();
|
||||
#endif
|
||||
ble->startDeviceDiscovery(var.toString());
|
||||
break;
|
||||
case USB:
|
||||
ble->disconnect();
|
||||
#ifndef NO_WIFI
|
||||
wifi->disconnect();
|
||||
#endif
|
||||
#ifndef NO_USB
|
||||
ble->disconnect();
|
||||
wifi->disconnect();
|
||||
usb->connectToRadio();
|
||||
#endif
|
||||
break;
|
||||
|
|
@ -69,9 +60,7 @@ void Connection::startDeviceDiscovery(const QVariant& var) {
|
|||
#ifndef NO_USB
|
||||
usb->disconnect();
|
||||
#endif
|
||||
#ifndef NO_WIFI
|
||||
wifi->connectToRadio(var.toString());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -82,13 +71,17 @@ void Connection::stopDeviceDiscovery() {
|
|||
|
||||
void Connection::disconnect() {
|
||||
switch (type) {
|
||||
case BLE: ble->disconnect(); break;
|
||||
case BLE:
|
||||
ble->disconnect();
|
||||
break;
|
||||
case USB:
|
||||
#ifndef NO_USB
|
||||
case USB: usb->disconnect(); break;
|
||||
#endif
|
||||
#ifndef NO_WIFI
|
||||
case WiFi: wifi->disconnect(); break;
|
||||
usb->disconnect();
|
||||
#endif
|
||||
break;
|
||||
case WiFi:
|
||||
wifi->disconnect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,13 +96,17 @@ void Connection::read2() {
|
|||
void Connection::write2(const QVariant& vBytes) {
|
||||
QByteArray bytes = vBytes.toByteArray();
|
||||
switch (type) {
|
||||
case BLE: ble->write(bytes); break;
|
||||
case BLE:
|
||||
ble->write(bytes);
|
||||
break;
|
||||
case USB:
|
||||
#ifndef NO_USB
|
||||
case USB: usb->write2(bytes); break;
|
||||
#endif
|
||||
#ifndef NO_WIFI
|
||||
case WiFi: wifi->write2(bytes); break;
|
||||
usb->write2(bytes);
|
||||
#endif
|
||||
break;
|
||||
case WiFi:
|
||||
wifi->write2(bytes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@
|
|||
#include <QVariant>
|
||||
|
||||
class BLE_ME;
|
||||
class WiFi_ME;
|
||||
|
||||
#ifndef NO_USB
|
||||
class USB_ME;
|
||||
#endif
|
||||
#ifndef NO_WIFI
|
||||
class WiFi_ME;
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
class QtAndroidService;
|
||||
|
|
@ -32,11 +30,9 @@ public:
|
|||
|
||||
Type type = BLE;
|
||||
BLE_ME* ble = nullptr;
|
||||
WiFi_ME* wifi = nullptr;
|
||||
#ifndef NO_USB
|
||||
USB_ME* usb = nullptr;
|
||||
#endif
|
||||
#ifndef NO_WIFI
|
||||
WiFi_ME* wifi = nullptr;
|
||||
#endif
|
||||
bool backgroundMode = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -470,7 +470,6 @@
|
|||
(when (radio-ready-p)
|
||||
(app:input-dialog
|
||||
(tr "Channel name:") 'channel-name-changed
|
||||
:title (tr "Name")
|
||||
:text *channel-name*
|
||||
:max-length #.(float 12)))
|
||||
(values))
|
||||
|
|
@ -487,10 +486,9 @@
|
|||
(qlater 'set-primary-channel))))
|
||||
(values))
|
||||
|
||||
(defun edit-device-filter () ; see QML
|
||||
(defun edit-device-filter () ; see QML (currently not used)
|
||||
(app:input-dialog
|
||||
(tr "Device filter:") 'device-filter-changed
|
||||
:title (tr "Filter")
|
||||
:text (or (app:setting :device-filter) "meshtastic"))
|
||||
(values))
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@
|
|||
|
||||
(defun background-mode-changed (mode) ; see Qt
|
||||
(setf *background-mode* mode)
|
||||
;; needed for iOS which disconnects in background mode
|
||||
(when (and (not *background-mode*)
|
||||
(eql :wifi radios:*connection*))
|
||||
(lora:start-device-discovery))
|
||||
(values))
|
||||
|
||||
;;; settings
|
||||
|
|
@ -139,13 +143,15 @@
|
|||
(qjs |confirm| ui:*dialogs*
|
||||
text (x:callback-name callback)))
|
||||
|
||||
(defun input-dialog (label callback &key (title "")
|
||||
(text "") (max-length #.(float 32767)) (input-mask "")
|
||||
from to value)
|
||||
(defun input-dialog (label callback
|
||||
&key (text "") (placeholder-text "")
|
||||
(max-length #.(float 32767)) (input-mask "") numbers-only
|
||||
from to value)
|
||||
(qjs |input| ui:*dialogs*
|
||||
title label (x:callback-name callback)
|
||||
text max-length input-mask ; string (line edit)
|
||||
from to value)) ; integer (spin box)
|
||||
label (x:callback-name callback)
|
||||
text placeholder-text ; string (line edit)
|
||||
max-length input-mask numbers-only
|
||||
from to value)) ; integer (spin box)
|
||||
|
||||
;;; backup/restore all app data
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@
|
|||
(defun font-size-dialog ()
|
||||
(app:input-dialog
|
||||
(tr "Message font size:") 'font-size-changed
|
||||
:title (tr "Size")
|
||||
:from 10.0
|
||||
:to 48.0
|
||||
:value (float (or (app:setting :message-font-size)
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@
|
|||
(progn
|
||||
(app:input-dialog
|
||||
(tr "Radio WiFi IP:") 'wifi-ip-changed
|
||||
:title (tr "IP")
|
||||
:text (wifi-ip)
|
||||
:input-mask "000.000.000.000")
|
||||
:placeholder-text "IP"
|
||||
:numbers-only t)
|
||||
nil)))
|
||||
(defun wifi-ip-changed* (ok)
|
||||
(when ok
|
||||
|
|
|
|||
|
|
@ -53,7 +53,20 @@ If your radio is not found, it may help to turn it off/on again.
|
|||
</p>
|
||||
%1
|
||||
%2
|
||||
<h4>WiFi</h4>
|
||||
%3
|
||||
<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>
|
||||
<img src='../../img/group.png' width=60 height=60>
|
||||
<br>Group
|
||||
|
|
@ -141,20 +154,8 @@ To autmatically restore data from a backup on the desktop, put the backup files
|
|||
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>"
|
||||
.arg((Qt.platform.os === "ios")
|
||||
? "<p><i><font color=crimson><b>Warning:</b></font> WiFi will disconnect in background mode, and only re-connect when app is brought back to foreground (iOS only).</i></p>"
|
||||
: "")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ Item {
|
|||
loader.item.open()
|
||||
}
|
||||
|
||||
function input(title, label, callback, text, maxLength, inputMask, from, to, value) {
|
||||
function input(label, callback, text, placeholderText,
|
||||
maxLength, inputMask, numbersOnly,
|
||||
from, to, value) {
|
||||
loader.active = false // force reload
|
||||
if (rootItem.mobile) {
|
||||
loader.source = "InputMobile.qml"
|
||||
|
|
@ -45,18 +47,19 @@ Item {
|
|||
loader.source = "Input.qml"
|
||||
}
|
||||
loader.active = true
|
||||
loader.item.title = title
|
||||
loader.item.label = label
|
||||
loader.item.callback = callback
|
||||
loader.item.text = text
|
||||
loader.item.placeholderText = placeholderText
|
||||
loader.item.maxLength = maxLength
|
||||
loader.item.inputMask = inputMask
|
||||
loader.item.numbersOnly = numbersOnly
|
||||
loader.item.from = from
|
||||
loader.item.to = to
|
||||
loader.item.value = value
|
||||
var keyboard = (text !== "")
|
||||
rootItem.showKeyboard(keyboard)
|
||||
var keyboard = (text !== "") || (placeholderText !== "")
|
||||
loader.item.open()
|
||||
if (keyboard) loader.item.setFocus()
|
||||
Qt.callLater(rootItem.showKeyboard, keyboard)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ Dialog {
|
|||
|
||||
property alias label: label.text
|
||||
property alias text: edit.text
|
||||
property alias placeholderText: edit.placeholderText
|
||||
property alias inputMask: edit.inputMask
|
||||
property alias maxLength: edit.maximumLength
|
||||
property alias from: spinBox.from
|
||||
property alias to: spinBox.to
|
||||
property alias value: spinBox.value
|
||||
property bool numbersOnly
|
||||
property string callback
|
||||
|
||||
function setFocus() { edit.forceActiveFocus() }
|
||||
|
|
|
|||
|
|
@ -9,11 +9,13 @@ Dialog {
|
|||
|
||||
property alias label: label.text
|
||||
property alias text: edit.text
|
||||
property alias placeholderText: edit.placeholderText
|
||||
property alias inputMask: edit.inputMask
|
||||
property alias maxLength: edit.maximumLength
|
||||
property alias from: spinBox.from
|
||||
property alias to: spinBox.to
|
||||
property alias value: spinBox.value
|
||||
property bool numbersOnly
|
||||
property string callback
|
||||
|
||||
function setFocus() { edit.forceActiveFocus() }
|
||||
|
|
@ -35,6 +37,7 @@ Dialog {
|
|||
objectName: "dialog_line_edit"
|
||||
width: parent.width
|
||||
visible: !spinBox.visible
|
||||
inputMethodHints: numbersOnly ? Qt.ImhFormattedNumbersOnly : Qt.ImhNone
|
||||
}
|
||||
|
||||
SpinBox {
|
||||
|
|
|
|||
|
|
@ -82,14 +82,15 @@ Item {
|
|||
checkable: true
|
||||
enabled: (Qt.platform.os !== "android") && (Qt.platform.os !== "ios")
|
||||
onTriggered: connection.changed(objectName)
|
||||
height: enabled ? height : 0
|
||||
}
|
||||
Com.MenuItem {
|
||||
objectName: "WIFI"
|
||||
text: "WiFi"
|
||||
autoExclusive: true
|
||||
checkable: true
|
||||
enabled: (Qt.platform.os !== "ios")
|
||||
onTriggered: connection.changed(objectName)
|
||||
Component.onCompleted: if (Qt.platform.os === "ios") { palette.windowText = "crimson" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue