diff --git a/examples/meshtastic-qt6/qml/main.qml b/examples/meshtastic-qt6/qml/main.qml index e3b7c75..e04dd6e 100644 --- a/examples/meshtastic-qt6/qml/main.qml +++ b/examples/meshtastic-qt6/qml/main.qml @@ -84,7 +84,6 @@ Item { autoExclusive: true checkable: true onTriggered: connection.changed(objectName) - Component.onCompleted: if (mobile && (Qt.platform.os !== "android")) { height = 0 } } Com.MenuItem { objectName: "WIFI" diff --git a/examples/meshtastic/app.pro b/examples/meshtastic/app.pro index bf5b09b..d036cc1 100644 --- a/examples/meshtastic/app.pro +++ b/examples/meshtastic/app.pro @@ -1,3 +1,6 @@ +# to set manually (when no BLE available) +#CONFIG += no_ble + LISP_FILES = $$files(lisp/*) app.asd make.lisp exists(/etc/sailfish-release) { @@ -65,7 +68,6 @@ win32 { sfos { QT -= serialport CONFIG += no_usb - DEFINES += NO_USB } android { @@ -146,6 +148,14 @@ ios { QMAKE_BUNDLE_DATA += launch } +no_ble { + DEFINES += NO_BLE + QT -= bluetooth +} +no_usb { + DEFINES += NO_USB +} + 32bit { android { equals(QT_MAJOR_VERSION, 6) { @@ -188,16 +198,21 @@ SOURCES += \ !android { HEADERS += \ cpp/connection/connection.h \ - cpp/connection/ble/ble.h \ - cpp/connection/ble/ble_me.h \ cpp/connection/wifi/wifi_me.h SOURCES += \ cpp/connection/connection.cpp \ - cpp/connection/ble/ble.cpp \ - cpp/connection/ble/ble_me.cpp \ cpp/connection/wifi/wifi_me.cpp + !no_ble { + HEADERS += \ + cpp/connection/ble/ble.h \ + cpp/connection/ble/ble_me.h + SOURCES += \ + cpp/connection/ble/ble.cpp \ + cpp/connection/ble/ble_me.cpp + } + !no_usb { HEADERS += \ cpp/connection/usb/usb_me.h diff --git a/examples/meshtastic/cpp/connection/connection.cpp b/examples/meshtastic/cpp/connection/connection.cpp index 3f18edd..e535130 100644 --- a/examples/meshtastic/cpp/connection/connection.cpp +++ b/examples/meshtastic/cpp/connection/connection.cpp @@ -1,10 +1,12 @@ #include "connection.h" -#include "ble/ble_me.h" #include "wifi/wifi_me.h" #include #include #include +#ifndef NO_BLE + #include "ble/ble_me.h" +#endif #ifndef NO_USB #ifdef Q_OS_ANDROID #include "usb/usb_me.android.h" @@ -31,7 +33,9 @@ Connection::Connection(QtAndroidService* service) { } #else Connection::Connection() { +#ifndef NO_BLE ble = new BLE_ME(this); +#endif #ifndef NO_USB usb = new USB_ME(this); #endif @@ -47,21 +51,27 @@ void Connection::setConnectionType(const QVariant& var) { void Connection::startDeviceDiscovery(const QVariant& var) { switch (type) { case BLE: -#ifndef NO_USB +#ifndef NO_BLE + #ifndef NO_USB usb->disconnect(); -#endif + #endif wifi->disconnect(); ble->startDeviceDiscovery(var.toString()); +#endif break; case USB: #ifndef NO_USB + #ifndef NO_BLE ble->disconnect(); + #endif wifi->disconnect(); usb->connectToRadio(); #endif break; case WiFi: +#ifndef NO_BLE ble->disconnect(); +#endif #ifndef NO_USB usb->disconnect(); #endif @@ -71,13 +81,17 @@ void Connection::startDeviceDiscovery(const QVariant& var) { } void Connection::stopDeviceDiscovery() { +#ifndef NO_BLE ble->stopDeviceDiscovery(); +#endif } void Connection::disconnect() { switch (type) { case BLE: +#ifndef NO_BLE ble->disconnect(); +#endif break; case USB: #ifndef NO_USB @@ -91,18 +105,24 @@ void Connection::disconnect() { } void Connection::setDeviceFilter(const QVariant& vName) { +#ifndef NO_BLE ble->setDeviceFilter(vName.toString()); +#endif } void Connection::read2() { +#ifndef NO_BLE ble->read(); +#endif } void Connection::write2(const QVariant& vBytes) { QByteArray bytes = vBytes.toByteArray(); switch (type) { case BLE: +#ifndef NO_BLE ble->write(bytes); +#endif break; case USB: #ifndef NO_USB diff --git a/examples/meshtastic/cpp/connection/connection.h b/examples/meshtastic/cpp/connection/connection.h index 82eb47e..b3b084a 100644 --- a/examples/meshtastic/cpp/connection/connection.h +++ b/examples/meshtastic/cpp/connection/connection.h @@ -3,9 +3,11 @@ #include #include -class BLE_ME; class WiFi_ME; +#ifndef NO_BLE + class BLE_ME; +#endif #ifndef NO_USB class USB_ME; #endif @@ -28,9 +30,13 @@ public: BLE, USB, WiFi }; + WiFi_ME* wifi = nullptr; +#ifndef NO_BLE Type type = BLE; BLE_ME* ble = nullptr; - WiFi_ME* wifi = nullptr; +#else + Type type = USB; +#endif #ifndef NO_USB USB_ME* usb = nullptr; #endif diff --git a/examples/meshtastic/cpp/qt.cpp b/examples/meshtastic/cpp/qt.cpp index 5c8a194..c38903e 100644 --- a/examples/meshtastic/cpp/qt.cpp +++ b/examples/meshtastic/cpp/qt.cpp @@ -152,6 +152,17 @@ QVariant QT::wifiConnectable(const QVariant& vIP) { return QVariant(); } +QVariant QT::hasFeature(const QVariant& vName) { + auto name = vName.toString().toLower(); +#ifndef NO_BLE + if (name == "ble") return true; +#endif +#ifndef NO_USB + if (name == "usb") return true; +#endif + return QVariant(); +} + // SQLite QVariant QT::iniDb(const QVariant& vName) { diff --git a/examples/meshtastic/cpp/qt.h b/examples/meshtastic/cpp/qt.h index cd85a94..f7c9a58 100644 --- a/examples/meshtastic/cpp/qt.h +++ b/examples/meshtastic/cpp/qt.h @@ -31,6 +31,7 @@ public: Q_INVOKABLE QVariant read2(); Q_INVOKABLE QVariant write2(const QVariant&); Q_INVOKABLE QVariant wifiConnectable(const QVariant&); + Q_INVOKABLE QVariant hasFeature(const QVariant&); // GPS #ifdef Q_OS_ANDROID diff --git a/examples/meshtastic/cpp/qt.pro b/examples/meshtastic/cpp/qt.pro index b8c40d9..ff02b8f 100644 --- a/examples/meshtastic/cpp/qt.pro +++ b/examples/meshtastic/cpp/qt.pro @@ -1,3 +1,6 @@ +# to set manually (when no BLE available) +#CONFIG += no_ble + QT += sql network bluetooth serialport TEMPLATE = lib CONFIG += c++17 plugin release no_keywords @@ -9,22 +12,32 @@ TARGET = qt OBJECTS_DIR = ./tmp/ MOC_DIR = ./tmp/ +no_ble { + DEFINES += NO_BLE + QT -= bluetooth +} + HEADERS += \ connection/connection.h \ - connection/ble/ble.h \ - connection/ble/ble_me.h \ connection/usb/usb_me.h \ connection/wifi/wifi_me.h \ qt.h SOURCES += \ connection/connection.cpp \ - connection/ble/ble.cpp \ - connection/ble/ble_me.cpp \ connection/usb/usb_me.cpp \ connection/wifi/wifi_me.cpp \ qt.cpp +!no_ble { + HEADERS += \ + connection/ble/ble.h \ + connection/ble/ble_me.h + SOURCES += \ + connection/ble/ble.cpp \ + connection/ble/ble_me.cpp +} + linux { LIBS += -L../../../platforms/linux/lib } diff --git a/examples/meshtastic/lisp/qt.lisp b/examples/meshtastic/lisp/qt.lisp index 017d611..2af9be9 100644 --- a/examples/meshtastic/lisp/qt.lisp +++ b/examples/meshtastic/lisp/qt.lisp @@ -4,6 +4,7 @@ #:*cpp* #:data-path #:disconnect + #:has-feature #:ini #:ini-db #:ini-positioning diff --git a/examples/meshtastic/lisp/radios.lisp b/examples/meshtastic/lisp/radios.lisp index 8ef7c65..4df88d8 100644 --- a/examples/meshtastic/lisp/radios.lisp +++ b/examples/meshtastic/lisp/radios.lisp @@ -7,6 +7,10 @@ (setf *connection* (or (app:setting :connection) :ble)) (set-connection-type) + (unless (qt:has-feature qt:*cpp* "ble") + (q> |height| ui:*ble* 0)) + (unless (qt:has-feature qt:*cpp* "usb") + (q> |height| ui:*usb* 0)) (q> |checked| (symbol-name *connection*) t) (q> |model| ui:*region* (cons "-" (mapcar 'symbol-name (rest (lora:keywords :region-code))))) diff --git a/examples/meshtastic/lisp/ui-vars.lisp b/examples/meshtastic/lisp/ui-vars.lisp index bd622ef..2409c96 100644 --- a/examples/meshtastic/lisp/ui-vars.lisp +++ b/examples/meshtastic/lisp/ui-vars.lisp @@ -4,6 +4,7 @@ (:use :cl) (:export #:*add-manual-marker* + #:*ble* #:*busy* #:*channel-name* #:*dialogs* @@ -36,11 +37,13 @@ #:*remove-marker* #:*share-location* #:*toast* - #:*unread-messages*)) + #:*unread-messages* + #:*usb*)) (in-package :ui) (defparameter *add-manual-marker* "add_manual_marker") +(defparameter *ble* "BLE") (defparameter *busy* "busy") (defparameter *channel-name* "channel_name") (defparameter *dialogs* "dialogs") @@ -74,4 +77,5 @@ (defparameter *share-location* "share_location") (defparameter *toast* "toast") (defparameter *unread-messages* "unread_messages") +(defparameter *usb* "USB") diff --git a/examples/meshtastic/platforms/android/src/org/cl/meshtastic/MeActivity.java b/examples/meshtastic/platforms/android/src/org/cl/meshtastic/MeActivity.java index cecf795..c9e764f 100644 --- a/examples/meshtastic/platforms/android/src/org/cl/meshtastic/MeActivity.java +++ b/examples/meshtastic/platforms/android/src/org/cl/meshtastic/MeActivity.java @@ -16,7 +16,7 @@ public class MeActivity extends QtActivity // GPS // location hack: needed to not lose initial position with non moving - // devices (on android Qt seems not to capture inital location values) + // devices (seems necessary on android when using Qt/QML) public double position_lat = 0.0; public double position_lon = 0.0; diff --git a/examples/meshtastic/platforms/windows/setup.nsi b/examples/meshtastic/platforms/windows/setup.nsi index 75cbda0..28f2bf6 100644 --- a/examples/meshtastic/platforms/windows/setup.nsi +++ b/examples/meshtastic/platforms/windows/setup.nsi @@ -1,7 +1,7 @@ Unicode True !include "MUI2.nsh" Name "Mesh SMS" - OutFile "out\Setup-Mesh-SMS-0.9.3.exe" + OutFile "out\Setup-Mesh-SMS-0.9.4.exe" InstallDir "$PROGRAMFILES\Mesh SMS" Var STARTMENU_FOLDER !define MUI_ABORTWARNING diff --git a/examples/meshtastic/qml/ext/messages/Messages.qml b/examples/meshtastic/qml/ext/messages/Messages.qml index b08088c..9637eb4 100644 --- a/examples/meshtastic/qml/ext/messages/Messages.qml +++ b/examples/meshtastic/qml/ext/messages/Messages.qml @@ -258,7 +258,8 @@ Rectangle { height: width source: "../../img/emoji.png" opacity: 0.55 - visible: edit.focus && (Qt.platform.os !== "android") && (Qt.platform.os !== "ios") + // on android/iOS/Windows native emojis work out of the box + visible: edit.focus && ((Qt.platform.os === "linux") || (Qt.platform.os === "osx")) MouseArea { anchors.fill: parent diff --git a/examples/meshtastic/qml/main.qml b/examples/meshtastic/qml/main.qml index c6f53be..ab4f3f6 100644 --- a/examples/meshtastic/qml/main.qml +++ b/examples/meshtastic/qml/main.qml @@ -83,7 +83,6 @@ Item { autoExclusive: true checkable: true onTriggered: connection.changed(objectName) - Component.onCompleted: if (mobile && (Qt.platform.os !== "android")) { height = 0 } } Com.MenuItem { objectName: "WIFI"