From 3302a40a4e4a83d53493a832bc9b8486b3ad549a Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 4 Oct 2017 12:32:42 +0200 Subject: 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 --- tradeshow/iot-sensortag/mqttupdate.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 #include #include @@ -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; -- cgit v1.2.3