mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-15 06:41:25 -08:00
example 'meshtastic': minor update (define device to be used)
This commit is contained in:
parent
9ee7030350
commit
c77d993496
11 changed files with 90 additions and 35 deletions
|
|
@ -27,7 +27,7 @@ void BLE::startDeviceDiscovery() {
|
|||
|
||||
void BLE::addDevice(const QBluetoothDeviceInfo& device) {
|
||||
if (deviceFilter(device)) {
|
||||
qDebug() << "device added: " << device.name();
|
||||
qDebug() << "device added:" << device.name() << device.address().toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ void BLE::serviceScanDone() {
|
|||
|
||||
void BLE::connectToService(const QString& uuid) {
|
||||
QLowEnergyService* service = nullptr;
|
||||
for (auto s: qAsConst(services)) {
|
||||
for (auto s : qAsConst(services)) {
|
||||
if (s->serviceUuid().toString() == uuid) {
|
||||
service = s;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -12,13 +12,29 @@ 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::startDeviceDiscovery() {
|
||||
QVariant QT::setDevice(const QVariant& vMap) {
|
||||
auto map = vMap.value<QVariantMap>();
|
||||
ble->setCurrentDevice(toDeviceInfo(map));
|
||||
return vMap;
|
||||
}
|
||||
|
||||
QVariant QT::startDeviceDiscovery(const QVariant& vMap) {
|
||||
auto map = vMap.value<QVariantMap>();
|
||||
if (!map.isEmpty()) {
|
||||
ble->currentDevice = toDeviceInfo(map);
|
||||
}
|
||||
ble->startDeviceDiscovery();
|
||||
return QVariant();
|
||||
return vMap;
|
||||
}
|
||||
|
||||
QVariant QT::read2() {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ class QT : public QObject {
|
|||
|
||||
public:
|
||||
// BLE_ME
|
||||
Q_INVOKABLE QVariant startDeviceDiscovery();
|
||||
Q_INVOKABLE QVariant setDevice(const QVariant&);
|
||||
Q_INVOKABLE QVariant startDeviceDiscovery(const QVariant& = QVariant());
|
||||
Q_INVOKABLE QVariant read2();
|
||||
Q_INVOKABLE QVariant write2(const QVariant&);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue