diff --git a/networkdetector/devicemonitor.cpp b/networkdetector/devicemonitor.cpp index 3680b7fc..648abd28 100644 --- a/networkdetector/devicemonitor.cpp +++ b/networkdetector/devicemonitor.cpp @@ -14,6 +14,7 @@ DeviceMonitor::DeviceMonitor(const QString &macAddress, const QString &ipAddress connect(m_arpLookupProcess, SIGNAL(finished(int)), this, SLOT(arpLookupFinished(int))); m_pingProcess = new QProcess(this); + m_pingProcess->setReadChannelMode(QProcess::MergedChannels); connect(m_pingProcess, SIGNAL(finished(int)), this, SLOT(pingFinished(int))); } @@ -29,11 +30,12 @@ void DeviceMonitor::update() void DeviceMonitor::lookupArpCache() { - m_arpLookupProcess->start("ip", {"-s", "neighbor", "list"}); + m_arpLookupProcess->start("ip", {"-4", "-s", "neighbor", "list"}); } void DeviceMonitor::ping() { +// qCDebug(dcNetworkDetector()) << "Running:" << "ping" << "-c" << "1" << m_host->address(); m_pingProcess->start("ping", {"-c", "1", m_host->address()}); } @@ -66,14 +68,14 @@ void DeviceMonitor::arpLookupFinished(int exitCode) } } else { // ARP claims the device to be stale... try to ping it. - qCDebug(dcNetworkDetector()) << "Device" << m_host->macAddress() << "found in ARP cache but is marked as" << parts.last() << ". Trying to ping it..."; + qCDebug(dcNetworkDetector()) << "Device" << m_host->macAddress() << "found in ARP cache but is marked as" << parts.last() << ". Trying to ping it on" << m_host->address(); ping(); } break; } } if (!found) { - qCDebug(dcNetworkDetector()) << "Device" << m_host->macAddress() << "not found in ARP cache. Trying to ping it..."; + qCDebug(dcNetworkDetector()) << "Device" << m_host->macAddress() << "not found in ARP cache. Trying to ping it on" << m_host->address(); ping(); } diff --git a/networkdetector/devicepluginnetworkdetector.cpp b/networkdetector/devicepluginnetworkdetector.cpp index 6cc3c822..c27a8d4d 100644 --- a/networkdetector/devicepluginnetworkdetector.cpp +++ b/networkdetector/devicepluginnetworkdetector.cpp @@ -141,9 +141,9 @@ void DevicePluginNetworkDetector::deviceReachableChanged(bool reachable) { DeviceMonitor *monitor = static_cast(sender()); Device *device = m_monitors.value(monitor); - if (device->stateValue(networkDeviceInRangeStateTypeId).toBool() != reachable) { + if (device->stateValue(networkDeviceConnectedStateTypeId).toBool() != reachable) { qCDebug(dcNetworkDetector()) << "Device" << device->paramValue(networkDeviceMacAddressParamTypeId).toString() << "reachable changed" << reachable; - device->setStateValue(networkDeviceInRangeStateTypeId, reachable); + device->setStateValue(networkDeviceConnectedStateTypeId, reachable); } } diff --git a/networkdetector/devicepluginnetworkdetector.json b/networkdetector/devicepluginnetworkdetector.json index 799ce515..49175dfd 100644 --- a/networkdetector/devicepluginnetworkdetector.json +++ b/networkdetector/devicepluginnetworkdetector.json @@ -17,6 +17,7 @@ "Device", "Sensor" ], + "interfaces": ["connectable"], "primaryStateTypeId": "cb43e1b5-4f61-4538-bfa2-c33055c542cf", "createMethods": ["user", "discovery"], "paramTypes": [ @@ -38,11 +39,12 @@ "stateTypes": [ { "id": "cb43e1b5-4f61-4538-bfa2-c33055c542cf", - "name": "inRange", + "name": "connected", "displayName": "Device in network", "displayNameEvent": "Device in network changed", "type": "bool", - "defaultValue": false + "defaultValue": false, + "cached": false } ] }