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
checkable: true
onTriggered: connection.changed(objectName)
Component.onCompleted: if (mobile && (Qt.platform.os !== "android")) { height = 0 }
}
Com.MenuItem {
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
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

View file

@ -1,10 +1,12 @@
#include "connection.h"
#include "ble/ble_me.h"
#include "wifi/wifi_me.h"
#include <QStandardPaths>
#include <QFile>
#include <QDataStream>
#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_BLE
#ifndef NO_USB
usb->disconnect();
#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

View file

@ -3,9 +3,11 @@
#include <QObject>
#include <QVariant>
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

View file

@ -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) {

View file

@ -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

View file

@ -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
}

View file

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

View file

@ -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)))))

View file

@ -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")

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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"