example 'meshtastic': add option to exclude BLE support; revisions

This commit is contained in:
pls.153 2024-06-19 15:16:26 +02:00
parent 8a9fb55850
commit fed3fe1671
14 changed files with 94 additions and 20 deletions

View file

@ -84,7 +84,6 @@ Item {
autoExclusive: true autoExclusive: true
checkable: true checkable: true
onTriggered: connection.changed(objectName) onTriggered: connection.changed(objectName)
Component.onCompleted: if (mobile && (Qt.platform.os !== "android")) { height = 0 }
} }
Com.MenuItem { Com.MenuItem {
objectName: "WIFI" objectName: "WIFI"

View file

@ -1,3 +1,6 @@
# to set manually (when no BLE available)
#CONFIG += no_ble
LISP_FILES = $$files(lisp/*) app.asd make.lisp LISP_FILES = $$files(lisp/*) app.asd make.lisp
exists(/etc/sailfish-release) { exists(/etc/sailfish-release) {
@ -65,7 +68,6 @@ win32 {
sfos { sfos {
QT -= serialport QT -= serialport
CONFIG += no_usb CONFIG += no_usb
DEFINES += NO_USB
} }
android { android {
@ -146,6 +148,14 @@ ios {
QMAKE_BUNDLE_DATA += launch QMAKE_BUNDLE_DATA += launch
} }
no_ble {
DEFINES += NO_BLE
QT -= bluetooth
}
no_usb {
DEFINES += NO_USB
}
32bit { 32bit {
android { android {
equals(QT_MAJOR_VERSION, 6) { equals(QT_MAJOR_VERSION, 6) {
@ -188,16 +198,21 @@ SOURCES += \
!android { !android {
HEADERS += \ HEADERS += \
cpp/connection/connection.h \ cpp/connection/connection.h \
cpp/connection/ble/ble.h \
cpp/connection/ble/ble_me.h \
cpp/connection/wifi/wifi_me.h cpp/connection/wifi/wifi_me.h
SOURCES += \ SOURCES += \
cpp/connection/connection.cpp \ cpp/connection/connection.cpp \
cpp/connection/ble/ble.cpp \
cpp/connection/ble/ble_me.cpp \
cpp/connection/wifi/wifi_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 { !no_usb {
HEADERS += \ HEADERS += \
cpp/connection/usb/usb_me.h cpp/connection/usb/usb_me.h

View file

@ -1,10 +1,12 @@
#include "connection.h" #include "connection.h"
#include "ble/ble_me.h"
#include "wifi/wifi_me.h" #include "wifi/wifi_me.h"
#include <QStandardPaths> #include <QStandardPaths>
#include <QFile> #include <QFile>
#include <QDataStream> #include <QDataStream>
#ifndef NO_BLE
#include "ble/ble_me.h"
#endif
#ifndef NO_USB #ifndef NO_USB
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
#include "usb/usb_me.android.h" #include "usb/usb_me.android.h"
@ -31,7 +33,9 @@ Connection::Connection(QtAndroidService* service) {
} }
#else #else
Connection::Connection() { Connection::Connection() {
#ifndef NO_BLE
ble = new BLE_ME(this); ble = new BLE_ME(this);
#endif
#ifndef NO_USB #ifndef NO_USB
usb = new USB_ME(this); usb = new USB_ME(this);
#endif #endif
@ -47,21 +51,27 @@ 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 NO_BLE
#ifndef NO_USB #ifndef NO_USB
usb->disconnect(); usb->disconnect();
#endif #endif
wifi->disconnect(); wifi->disconnect();
ble->startDeviceDiscovery(var.toString()); ble->startDeviceDiscovery(var.toString());
#endif
break; break;
case USB: case USB:
#ifndef NO_USB #ifndef NO_USB
#ifndef NO_BLE
ble->disconnect(); ble->disconnect();
#endif
wifi->disconnect(); wifi->disconnect();
usb->connectToRadio(); usb->connectToRadio();
#endif #endif
break; break;
case WiFi: case WiFi:
#ifndef NO_BLE
ble->disconnect(); ble->disconnect();
#endif
#ifndef NO_USB #ifndef NO_USB
usb->disconnect(); usb->disconnect();
#endif #endif
@ -71,13 +81,17 @@ void Connection::startDeviceDiscovery(const QVariant& var) {
} }
void Connection::stopDeviceDiscovery() { void Connection::stopDeviceDiscovery() {
#ifndef NO_BLE
ble->stopDeviceDiscovery(); ble->stopDeviceDiscovery();
#endif
} }
void Connection::disconnect() { void Connection::disconnect() {
switch (type) { switch (type) {
case BLE: case BLE:
#ifndef NO_BLE
ble->disconnect(); ble->disconnect();
#endif
break; break;
case USB: case USB:
#ifndef NO_USB #ifndef NO_USB
@ -91,18 +105,24 @@ void Connection::disconnect() {
} }
void Connection::setDeviceFilter(const QVariant& vName) { void Connection::setDeviceFilter(const QVariant& vName) {
#ifndef NO_BLE
ble->setDeviceFilter(vName.toString()); ble->setDeviceFilter(vName.toString());
#endif
} }
void Connection::read2() { void Connection::read2() {
#ifndef NO_BLE
ble->read(); ble->read();
#endif
} }
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:
#ifndef NO_BLE
ble->write(bytes); ble->write(bytes);
#endif
break; break;
case USB: case USB:
#ifndef NO_USB #ifndef NO_USB

View file

@ -3,9 +3,11 @@
#include <QObject> #include <QObject>
#include <QVariant> #include <QVariant>
class BLE_ME;
class WiFi_ME; class WiFi_ME;
#ifndef NO_BLE
class BLE_ME;
#endif
#ifndef NO_USB #ifndef NO_USB
class USB_ME; class USB_ME;
#endif #endif
@ -28,9 +30,13 @@ public:
BLE, USB, WiFi BLE, USB, WiFi
}; };
WiFi_ME* wifi = nullptr;
#ifndef NO_BLE
Type type = BLE; Type type = BLE;
BLE_ME* ble = nullptr; BLE_ME* ble = nullptr;
WiFi_ME* wifi = nullptr; #else
Type type = USB;
#endif
#ifndef NO_USB #ifndef NO_USB
USB_ME* usb = nullptr; USB_ME* usb = nullptr;
#endif #endif

View file

@ -152,6 +152,17 @@ QVariant QT::wifiConnectable(const QVariant& vIP) {
return QVariant(); 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 // SQLite
QVariant QT::iniDb(const QVariant& vName) { QVariant QT::iniDb(const QVariant& vName) {

View file

@ -31,6 +31,7 @@ public:
Q_INVOKABLE QVariant read2(); Q_INVOKABLE QVariant read2();
Q_INVOKABLE QVariant write2(const QVariant&); Q_INVOKABLE QVariant write2(const QVariant&);
Q_INVOKABLE QVariant wifiConnectable(const QVariant&); Q_INVOKABLE QVariant wifiConnectable(const QVariant&);
Q_INVOKABLE QVariant hasFeature(const QVariant&);
// GPS // GPS
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID

View file

@ -1,3 +1,6 @@
# to set manually (when no BLE available)
#CONFIG += no_ble
QT += sql network bluetooth serialport QT += sql network bluetooth serialport
TEMPLATE = lib TEMPLATE = lib
CONFIG += c++17 plugin release no_keywords CONFIG += c++17 plugin release no_keywords
@ -9,22 +12,32 @@ TARGET = qt
OBJECTS_DIR = ./tmp/ OBJECTS_DIR = ./tmp/
MOC_DIR = ./tmp/ MOC_DIR = ./tmp/
no_ble {
DEFINES += NO_BLE
QT -= bluetooth
}
HEADERS += \ HEADERS += \
connection/connection.h \ connection/connection.h \
connection/ble/ble.h \
connection/ble/ble_me.h \
connection/usb/usb_me.h \ connection/usb/usb_me.h \
connection/wifi/wifi_me.h \ connection/wifi/wifi_me.h \
qt.h qt.h
SOURCES += \ SOURCES += \
connection/connection.cpp \ connection/connection.cpp \
connection/ble/ble.cpp \
connection/ble/ble_me.cpp \
connection/usb/usb_me.cpp \ connection/usb/usb_me.cpp \
connection/wifi/wifi_me.cpp \ connection/wifi/wifi_me.cpp \
qt.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 { linux {
LIBS += -L../../../platforms/linux/lib LIBS += -L../../../platforms/linux/lib
} }

View file

@ -4,6 +4,7 @@
#:*cpp* #:*cpp*
#:data-path #:data-path
#:disconnect #:disconnect
#:has-feature
#:ini #:ini
#:ini-db #:ini-db
#:ini-positioning #:ini-positioning

View file

@ -7,6 +7,10 @@
(setf *connection* (or (app:setting :connection) (setf *connection* (or (app:setting :connection)
:ble)) :ble))
(set-connection-type) (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> |checked| (symbol-name *connection*) t)
(q> |model| ui:*region* (q> |model| ui:*region*
(cons "-" (mapcar 'symbol-name (rest (lora:keywords :region-code))))) (cons "-" (mapcar 'symbol-name (rest (lora:keywords :region-code)))))

View file

@ -4,6 +4,7 @@
(:use :cl) (:use :cl)
(:export (:export
#:*add-manual-marker* #:*add-manual-marker*
#:*ble*
#:*busy* #:*busy*
#:*channel-name* #:*channel-name*
#:*dialogs* #:*dialogs*
@ -36,11 +37,13 @@
#:*remove-marker* #:*remove-marker*
#:*share-location* #:*share-location*
#:*toast* #:*toast*
#:*unread-messages*)) #:*unread-messages*
#:*usb*))
(in-package :ui) (in-package :ui)
(defparameter *add-manual-marker* "add_manual_marker") (defparameter *add-manual-marker* "add_manual_marker")
(defparameter *ble* "BLE")
(defparameter *busy* "busy") (defparameter *busy* "busy")
(defparameter *channel-name* "channel_name") (defparameter *channel-name* "channel_name")
(defparameter *dialogs* "dialogs") (defparameter *dialogs* "dialogs")
@ -74,4 +77,5 @@
(defparameter *share-location* "share_location") (defparameter *share-location* "share_location")
(defparameter *toast* "toast") (defparameter *toast* "toast")
(defparameter *unread-messages* "unread_messages") (defparameter *unread-messages* "unread_messages")
(defparameter *usb* "USB")

View file

@ -16,7 +16,7 @@ public class MeActivity extends QtActivity
// GPS // GPS
// location hack: needed to not lose initial position with non moving // 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_lat = 0.0;
public double position_lon = 0.0; public double position_lon = 0.0;

View file

@ -1,7 +1,7 @@
Unicode True Unicode True
!include "MUI2.nsh" !include "MUI2.nsh"
Name "Mesh SMS" 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" InstallDir "$PROGRAMFILES\Mesh SMS"
Var STARTMENU_FOLDER Var STARTMENU_FOLDER
!define MUI_ABORTWARNING !define MUI_ABORTWARNING

View file

@ -258,7 +258,8 @@ Rectangle {
height: width height: width
source: "../../img/emoji.png" source: "../../img/emoji.png"
opacity: 0.55 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 { MouseArea {
anchors.fill: parent anchors.fill: parent

View file

@ -83,7 +83,6 @@ Item {
autoExclusive: true autoExclusive: true
checkable: true checkable: true
onTriggered: connection.changed(objectName) onTriggered: connection.changed(objectName)
Component.onCompleted: if (mobile && (Qt.platform.os !== "android")) { height = 0 }
} }
Com.MenuItem { Com.MenuItem {
objectName: "WIFI" objectName: "WIFI"