fixed rediscovery
This commit is contained in:
parent
a20c43c0e5
commit
a2812c0810
@ -140,15 +140,6 @@ void DevicePluginSenic::deviceRemoved(Device *device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DevicePluginSenic::verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo)
|
|
||||||
{
|
|
||||||
foreach (Device *device, myDevices()) {
|
|
||||||
if (device->paramValue(nuimoDeviceMacParamTypeId).toString() == deviceInfo.address().toString())
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginSenic::onReconnectTimeout()
|
void DevicePluginSenic::onReconnectTimeout()
|
||||||
{
|
{
|
||||||
@ -159,6 +150,7 @@ void DevicePluginSenic::onReconnectTimeout()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DevicePluginSenic::onBluetoothDiscoveryFinished()
|
void DevicePluginSenic::onBluetoothDiscoveryFinished()
|
||||||
{
|
{
|
||||||
BluetoothDiscoveryReply *reply = static_cast<BluetoothDiscoveryReply *>(sender());
|
BluetoothDiscoveryReply *reply = static_cast<BluetoothDiscoveryReply *>(sender());
|
||||||
@ -169,17 +161,21 @@ void DevicePluginSenic::onBluetoothDiscoveryFinished()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<DeviceDescriptor> deviceDescriptors;
|
QList<DeviceDescriptor> deviceDescriptors;
|
||||||
foreach (const QBluetoothDeviceInfo &deviceInfo, reply->discoveredDevices()) {
|
foreach (const QBluetoothDeviceInfo &deviceInfo, reply->discoveredDevices()) {
|
||||||
if (deviceInfo.name().contains("Nuimo")) {
|
if (deviceInfo.name().contains("Nuimo")) {
|
||||||
if (!verifyExistingDevices(deviceInfo)) {
|
DeviceDescriptor descriptor(nuimoDeviceClassId, "Nuimo", deviceInfo.name() + " (" + deviceInfo.address().toString() + ")");
|
||||||
DeviceDescriptor descriptor(nuimoDeviceClassId, "Nuimo", deviceInfo.name() + " (" + deviceInfo.address().toString() + ")");
|
ParamList params;
|
||||||
ParamList params;
|
|
||||||
params.append(Param(nuimoDeviceMacParamTypeId, deviceInfo.address().toString()));
|
foreach (Device *existingDevice, myDevices()) {
|
||||||
descriptor.setParams(params);
|
if (existingDevice->paramValue(nuimoDeviceMacParamTypeId).toString() == deviceInfo.address().toString()) {
|
||||||
deviceDescriptors.append(descriptor);
|
descriptor.setDeviceId(existingDevice->id());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
params.append(Param(nuimoDeviceMacParamTypeId, deviceInfo.address().toString()));
|
||||||
|
descriptor.setParams(params);
|
||||||
|
deviceDescriptors.append(descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +206,6 @@ void DevicePluginSenic::onSwipeDetected(const Nuimo::SwipeDirection &direction)
|
|||||||
Nuimo *nuimo = static_cast<Nuimo *>(sender());
|
Nuimo *nuimo = static_cast<Nuimo *>(sender());
|
||||||
Device *device = m_nuimos.value(nuimo);
|
Device *device = m_nuimos.value(nuimo);
|
||||||
|
|
||||||
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case Nuimo::SwipeDirectionLeft:
|
case Nuimo::SwipeDirectionLeft:
|
||||||
emitEvent(Event(nuimoPressedEventTypeId, device->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "←")));
|
emitEvent(Event(nuimoPressedEventTypeId, device->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "←")));
|
||||||
@ -260,5 +255,4 @@ void DevicePluginSenic::onPluginConfigurationChanged(const ParamTypeId ¶mTyp
|
|||||||
qCDebug(dcSenic()) << "Auto symbol mode" << (value.toBool() ? "enabled." : "disabled.");
|
qCDebug(dcSenic()) << "Auto symbol mode" << (value.toBool() ? "enabled." : "disabled.");
|
||||||
m_autoSymbolMode = value.toBool();
|
m_autoSymbolMode = value.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,8 +51,6 @@ private:
|
|||||||
PluginTimer *m_reconnectTimer = nullptr;
|
PluginTimer *m_reconnectTimer = nullptr;
|
||||||
bool m_autoSymbolMode = true;
|
bool m_autoSymbolMode = true;
|
||||||
|
|
||||||
bool verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onPluginConfigurationChanged(const ParamTypeId ¶mTypeId, const QVariant &value);
|
void onPluginConfigurationChanged(const ParamTypeId ¶mTypeId, const QVariant &value);
|
||||||
void onReconnectTimeout();
|
void onReconnectTimeout();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user