mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-15 14:51:14 -08:00
revision
This commit is contained in:
parent
c77d993496
commit
f9e657fa83
5 changed files with 28 additions and 22 deletions
|
|
@ -51,7 +51,16 @@ void BLE::scanServices() {
|
|||
return;
|
||||
}
|
||||
if (!currentDevice.isValid()) {
|
||||
if (initialDeviceName.isNull()) {
|
||||
currentDevice = devices.at(0);
|
||||
} else {
|
||||
for (auto device : qAsConst(devices)) {
|
||||
if (device.name().contains(initialDeviceName, Qt::CaseInsensitive)) {
|
||||
currentDevice = device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
services.clear();
|
||||
qDebug() << "connecting to device...";
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public:
|
|||
QBluetoothDeviceInfo currentDevice; // if not defined, first one discovered
|
||||
QList<QBluetoothDeviceInfo> devices;
|
||||
void setCurrentDevice(const QBluetoothDeviceInfo&);
|
||||
QString initialDeviceName; // optional
|
||||
|
||||
// custom device filter (e.g. name filter)
|
||||
virtual bool deviceFilter(const QBluetoothDeviceInfo&) { return true; }
|
||||
|
|
|
|||
|
|
@ -12,29 +12,28 @@ QObject* ini() {
|
|||
return qt;
|
||||
}
|
||||
|
||||
static QBluetoothDeviceInfo toDeviceInfo(const QVariantMap& map) {
|
||||
return QBluetoothDeviceInfo(QBluetoothAddress(map.value("address").toString()),
|
||||
map.value("name").toString(),
|
||||
0);
|
||||
}
|
||||
|
||||
QT::QT() : QObject() {
|
||||
ble = new BLE_ME;
|
||||
}
|
||||
|
||||
QVariant QT::setDevice(const QVariant& vMap) {
|
||||
auto map = vMap.value<QVariantMap>();
|
||||
ble->setCurrentDevice(toDeviceInfo(map));
|
||||
return vMap;
|
||||
QVariant QT::setDevice(const QVariant& vName) {
|
||||
auto name = vName.toString();
|
||||
for (auto device : qAsConst(ble->devices)) {
|
||||
if (device.name().contains(name, Qt::CaseInsensitive)) {
|
||||
ble->setCurrentDevice(device);
|
||||
return vName;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant QT::startDeviceDiscovery(const QVariant& vMap) {
|
||||
auto map = vMap.value<QVariantMap>();
|
||||
if (!map.isEmpty()) {
|
||||
ble->currentDevice = toDeviceInfo(map);
|
||||
QVariant QT::startDeviceDiscovery(const QVariant& vName) {
|
||||
auto name = vName.toString();
|
||||
if (!name.isNull()) {
|
||||
ble->initialDeviceName = name;
|
||||
}
|
||||
ble->startDeviceDiscovery();
|
||||
return vMap;
|
||||
return vName;
|
||||
}
|
||||
|
||||
QVariant QT::read2() {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
(in-package :app)
|
||||
|
||||
;; set here the name and address of your 2 devices
|
||||
;; set here the 4 character short name of your 2 devices
|
||||
;; (see debug output during device discovery)
|
||||
|
||||
(defvar *device-1* '(:name "Meshtastic_128c" :address "F4:12:FA:9D:12:8D"))
|
||||
(defvar *device-2* '(:name "Meshtastic_1c9c" :address "F4:12:FA:9D:1C:9D"))
|
||||
(defvar *device-1* "128c")
|
||||
(defvar *device-2* "1c9c")
|
||||
|
||||
(defun ini ()
|
||||
(qt:ini)
|
||||
|
|
|
|||
|
|
@ -22,11 +22,8 @@
|
|||
#:start-config
|
||||
#:read-radio
|
||||
#:received-from-radio
|
||||
#:receiving-done
|
||||
#:send-message
|
||||
#:send-to-radio
|
||||
#:set-fixed-pin
|
||||
#:set-ready
|
||||
#:url-to-channel))
|
||||
|
||||
(defpackage :messages
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue