Fix updating of bt discovery results
This commit is contained in:
parent
59cd1d3420
commit
f89fd895a4
@ -87,6 +87,11 @@ void BluetoothDeviceInfos::addBluetoothDeviceInfo(BluetoothDeviceInfo *deviceInf
|
|||||||
deviceInfo->setParent(this);
|
deviceInfo->setParent(this);
|
||||||
beginInsertRows(QModelIndex(), m_deviceInfos.count(), m_deviceInfos.count());
|
beginInsertRows(QModelIndex(), m_deviceInfos.count(), m_deviceInfos.count());
|
||||||
m_deviceInfos.append(deviceInfo);
|
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();
|
endInsertRows();
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -178,18 +178,20 @@ void BluetoothDiscovery::onBluetoothHostModeChanged(const QBluetoothLocalDevice:
|
|||||||
|
|
||||||
void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo)
|
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()) {
|
foreach (BluetoothDeviceInfo *di, m_deviceInfos->deviceInfos()) {
|
||||||
// Some platforms only provide device UUID (e.g. Apple) and MAC address is 00:00:00:00:00
|
// 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.
|
// 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 we have a UUID, use that, otherwise use the MAC for comparison
|
||||||
if (!deviceInfo.deviceUuid().isNull()) {
|
if (!deviceInfo.deviceUuid().isNull()) {
|
||||||
if (di->bluetoothDeviceInfo().deviceUuid() == deviceInfo.deviceUuid()) {
|
if (di->bluetoothDeviceInfo().deviceUuid() == deviceInfo.deviceUuid()) {
|
||||||
|
qCDebug(dcBtWiFiSetup()) << "Updating discovery result (UUID)";
|
||||||
di->setBluetoothDeviceInfo(deviceInfo);
|
di->setBluetoothDeviceInfo(deviceInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (di->bluetoothDeviceInfo().address() == deviceInfo.address()) {
|
if (di->bluetoothDeviceInfo().address() == deviceInfo.address()) {
|
||||||
|
qCDebug(dcBtWiFiSetup()) << "Updating discovery result (MAC)";
|
||||||
di->setBluetoothDeviceInfo(deviceInfo);
|
di->setBluetoothDeviceInfo(deviceInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user