summaryrefslogtreecommitdiffstats
path: root/src/BobinkClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/BobinkClient.cpp')
-rw-r--r--src/BobinkClient.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/BobinkClient.cpp b/src/BobinkClient.cpp
index 6d1c608..7355a0c 100644
--- a/src/BobinkClient.cpp
+++ b/src/BobinkClient.cpp
@@ -6,11 +6,15 @@
#include "BobinkAuth.h"
#include <QDir>
+#include <QMetaEnum>
+#include <QOpcUaPkiConfiguration>
#include <QOpcUaUserTokenPolicy>
#include <QStandardPaths>
using namespace Qt::Literals::StringLiterals;
+static constexpr qint32 DISCOVERY_INTERVAL = 30000; // ms
+
static QString
defaultPkiDir ()
{
@@ -87,23 +91,13 @@ BobinkClient::setupClient ()
connect (m_client, &QOpcUaClient::errorChanged, this,
[this] (QOpcUaClient::ClientError error)
{
- static const QLatin1StringView names[] = {
- "NoError"_L1,
- "InvalidUrl"_L1,
- "AccessDenied"_L1,
- "ConnectionError"_L1,
- "UnknownError"_L1,
- "UnsupportedAuthenticationInformation"_L1,
- "InvalidAuthenticationInformation"_L1,
- "InvalidEndpointDescription"_L1,
- "NoMatchingUserIdentityTokenFound"_L1,
- "UnsupportedSecurityPolicy"_L1,
- "InvalidPki"_L1,
- };
- qint32 idx = static_cast<qint32> (error);
- if (idx > 0 && idx <= 10)
- emit connectionError (
- QStringLiteral ("Client error: %1").arg (names[idx]));
+ if (error == QOpcUaClient::NoError)
+ return;
+ auto me = QMetaEnum::fromType<QOpcUaClient::ClientError> ();
+ const char *key = me.valueToKey (static_cast<int> (error));
+ emit connectionError (
+ QStringLiteral ("Client error: %1")
+ .arg (key ? QLatin1StringView (key) : "Unknown"_L1));
});
}
@@ -290,6 +284,7 @@ BobinkClient::handleEndpointsReceived (
return;
}
+ // Pick the endpoint with the highest securityLevel (server-assigned score).
QOpcUaEndpointDescription best = endpoints.first ();
for (const auto &ep : endpoints)
{
@@ -381,7 +376,7 @@ BobinkClient::startDiscovery ()
return;
doDiscovery ();
- m_discoveryTimer.start (m_discoveryInterval);
+ m_discoveryTimer.start (DISCOVERY_INTERVAL);
if (!m_discovering)
{