Skip to content

Commit d345ad4

Browse files
committed
Work on device scanning
1 parent 947776b commit d345ad4

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/DeviceManager_advertisement.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void DeviceManager::bleDevice_updated(const QBluetoothDeviceInfo &info, QBluetoo
189189
// MQTT send
190190
SettingsManager *sm = SettingsManager::getInstance();
191191
MqttManager *mq = MqttManager::getInstance();
192-
if (sm && mq)
192+
if (sm && mq && !mac_qstr_clean.isEmpty())
193193
{
194194
QString topic = sm->getMqttTopicA() + "/" + sm->getMqttTopicB() + "/BTtoMQTT/" + mac_qstr_clean;
195195
bool status_mqtt = mq->publishData(topic, QString::fromStdString(output));
@@ -302,10 +302,12 @@ void DeviceManager::bleDevice_updated(const QBluetoothDeviceInfo &info, QBluetoo
302302
if (sm && mq && !mac_qstr_clean.isEmpty())
303303
{
304304
QString topic = sm->getMqttTopicA() + "/" + sm->getMqttTopicB() + "/BTtoMQTT/" + mac_qstr_clean;
305-
status_device = mq->publishData(topic, QString::fromStdString(output));
305+
bool status_mqtt = mq->publishData(topic, QString::fromStdString(output));
306+
if (!status_mqtt)
307+
{
308+
//qWarning() << "MQTT publishData(" << topic << ") FAILED >> " << output;
309+
}
306310
}
307-
308-
status_device = true;
309311
}
310312
}
311313
else
@@ -321,12 +323,12 @@ void DeviceManager::bleDevice_updated(const QBluetoothDeviceInfo &info, QBluetoo
321323

322324
if (m_scanning)
323325
{
324-
if (status_gateway && info.name().startsWith("OMG_"))
326+
if (!status_gateway && info.name().startsWith("OMG_"))
325327
{
326328
//qDebug() << "addBleGateway(" << info.name() << ") FROM DYNAMIC SCANNING";
327329
addBleGateway(info);
328330
}
329-
else if (status_device)
331+
else if (!status_device)
330332
{
331333
//qDebug() << "addBleDevice(" << info.name() << ") FROM DYNAMIC SCANNING";
332334
addBleDevice(info);

src/DeviceManager_theengs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ Device * DeviceManager::createTheengsDevice_fromAdv(const QBluetoothDeviceInfo &
232232
serializeJson(doc, output);
233233
qWarning() << "createTheengsDevice_fromAdv() decodeBLEJson(unknown) error:" << output.c_str();
234234
}
235+
235236
if (!deviceModelID.isEmpty() && // Do not process unkown devices
236237
!deviceProps.isEmpty() && // Do not process devices with empty properties
237238
!(deviceTypes == "RMAC" || doc["prmac"])) // Do not process devices with random macs

0 commit comments

Comments
 (0)