Fix updating of bt discovery results

pull/659/head
Michael Zanetti 2021-08-30 15:53:18 +02:00
parent 59cd1d3420
commit f89fd895a4
2 changed files with 8 additions and 1 deletions

View File

@ -87,6 +87,11 @@ void BluetoothDeviceInfos::addBluetoothDeviceInfo(BluetoothDeviceInfo *deviceInf
deviceInfo->setParent(this);
beginInsertRows(QModelIndex(), m_deviceInfos.count(), m_deviceInfos.count());
m_deviceInfos.append(deviceInfo);
connect(deviceInfo, &BluetoothDeviceInfo::deviceChanged, this, [=]{
int idx = m_deviceInfos.indexOf(deviceInfo);
QModelIndex index = this->index(idx);
emit dataChanged(index, index);
});
endInsertRows();
emit countChanged();
}

View File

@ -178,18 +178,20 @@ void BluetoothDiscovery::onBluetoothHostModeChanged(const QBluetoothLocalDevice:
void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo)
{
qCDebug(dcBtWiFiSetup()) << "BluetoothDiscovery: Device discovered:" << deviceInfo.name() << deviceInfo.address().toString() << deviceInfo.deviceUuid();
qCDebug(dcBtWiFiSetup()) << "BluetoothDiscovery: Device discovered:" << deviceInfo.name() << deviceInfo.address().toString() << deviceInfo.deviceUuid() << deviceInfo.serviceUuids();
foreach (BluetoothDeviceInfo *di, m_deviceInfos->deviceInfos()) {
// Some platforms only provide device UUID (e.g. Apple) and MAC address is 00:00:00:00:00
// Others provide only a MAC address and the UUID is null.
// If we have a UUID, use that, otherwise use the MAC for comparison
if (!deviceInfo.deviceUuid().isNull()) {
if (di->bluetoothDeviceInfo().deviceUuid() == deviceInfo.deviceUuid()) {
qCDebug(dcBtWiFiSetup()) << "Updating discovery result (UUID)";
di->setBluetoothDeviceInfo(deviceInfo);
return;
}
} else {
if (di->bluetoothDeviceInfo().address() == deviceInfo.address()) {
qCDebug(dcBtWiFiSetup()) << "Updating discovery result (MAC)";
di->setBluetoothDeviceInfo(deviceInfo);
return;
}