mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 02:30:38 -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
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue