From baee949f551584c36ca8724a375d1597f413c5f0 Mon Sep 17 00:00:00 2001 From: Stefan Kebekus Date: Tue, 14 Sep 2021 08:22:49 +0200 Subject: [PATCH] Improve support for traffic receivers that request a password, but do not need it --- CMakeLists.txt | 2 +- src/traffic/TrafficDataSource_Tcp.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 312ac36e6..cc696f48f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ option(BUILD_DOC "Build developer documentation" OFF) # Project data # -project(enroute VERSION 2.11.1) +project(enroute VERSION 2.11.2) set(APP_ID de.akaflieg_freiburg.enroute) math(EXPR PROJECT_VERSION_CODE 10000*${PROJECT_VERSION_MAJOR}+100*${PROJECT_VERSION_MINOR}+${PROJECT_VERSION_PATCH}) add_compile_definitions(PROJECT_VERSION="${PROJECT_VERSION}") diff --git a/src/traffic/TrafficDataSource_Tcp.cpp b/src/traffic/TrafficDataSource_Tcp.cpp index 485a2a4f7..4e8083e47 100644 --- a/src/traffic/TrafficDataSource_Tcp.cpp +++ b/src/traffic/TrafficDataSource_Tcp.cpp @@ -139,6 +139,22 @@ void Traffic::TrafficDataSource_Tcp::setPassword(const QString& SSID, const QStr if (SSID != passwordRequest_SSID) { return; } + + // First case: the device is already delivering data. This happens for Stratux devices + // that request a password for historical reasons, but really do not need one. + // In this case, accept the password immediately and issue a password storage request + // if appropriate + if (receivingHeartbeat()) { + // emit a password storage request if appropriate + auto* passwordDB = Global::passwordDB(); + if (!passwordDB->contains(passwordRequest_SSID) || + (passwordDB->getPassword(passwordRequest_SSID) != passwordRequest_password)) { + emit passwordStorageRequest(passwordRequest_SSID, passwordRequest_password); + } + return; + } + + // Second case: the devise is not yet delivering data. This is the normal case. passwordRequest_password = password; QTimer::singleShot(0, this, &Traffic::TrafficDataSource_Tcp::sendPassword_internal); }