diff options
author | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-10-04 12:32:42 +0200 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-10-04 11:36:57 +0000 |
commit | 3302a40a4e4a83d53493a832bc9b8486b3ad549a (patch) | |
tree | 3f6b005318ade05dfb41d7aff1f3bbb5cd28f90b /tradeshow | |
parent | 21350aac26961e48e2610f157725a2a8873b285b (diff) |
iot-sensortag: Add Uuid fallback for device id
All Android test devices report localhost as hostname. That causes the
remote display to not show any other android device, but also have
multiple localhost devices report data.
Change-Id: I144800d876faf35bc9ff8e526be31d9c322032dc
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'tradeshow')
-rw-r--r-- | tradeshow/iot-sensortag/mqttupdate.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tradeshow/iot-sensortag/mqttupdate.cpp b/tradeshow/iot-sensortag/mqttupdate.cpp index f574965..45ea238 100644 --- a/tradeshow/iot-sensortag/mqttupdate.cpp +++ b/tradeshow/iot-sensortag/mqttupdate.cpp @@ -55,6 +55,7 @@ #include "demodataproviderpool.h" #include "mqttdataproviderpool.h" +#include <QtCore/QUuid> #include <QtMqtt/QtMqtt> #include <QSysInfo> @@ -85,7 +86,11 @@ void MqttUpdate::setDataProviderPool(DataProviderPool *provider) if (!provider) return; - const QString hostname = QSysInfo::machineHostName(); + QString hostname = QSysInfo::machineHostName(); + if (hostname == QLatin1String("localhost")) { + hostname = QUuid::createUuid().toString(); + qCDebug(boot2QtDemos) << "localhost not unique. New ID:" << hostname; + } m_handler = new MqttEventHandler(hostname + QLatin1String(" - ") + provider->id()); m_handler->m_providerPool = m_providerPool; |