summaryrefslogtreecommitdiffstats
path: root/vehicle-signals/vehiclesignals.h
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2023-08-24 15:21:40 -0400
committerScott Murray <scott.murray@konsulko.com>2023-08-24 15:58:58 -0400
commite6e998428529bb788e2412e84757ad9a0b71fb32 (patch)
tree732447f581be177a0b181cb1de00c481b82bbda6 /vehicle-signals/vehiclesignals.h
parent1234b2771bc45a885df54a779dfb8a125f315f93 (diff)
Rework vehicle signals support to use KUKSA.val databroker
Rework the VehicleSignals class and its use in the Navigation and Hvac classes to switch from using the original KUKSA.val server via WebSockets to the KUKSA.val databroker's gRPC "VAL" API. Notable changes: - The VehicleSignals API has changed a bit with respect to setting signals, callers now need to pass the new value as the type that matches the signal as opposed to always passing a string, and optionally indicate if an actuator's target or value is being set. Subscribe operations now also allow subscribing for either actuator targets or values. - It is possible that the values returned by get and subscribe operations will be changed to using QVariant instead of QStrings in a future follow up, but that has not been done in these changes. - The connected signal from VehicleSignals still has roughly the same meaning, but the authorize function and authorized signals are to some degree redundant now. They have been kept for compatibility, but may be removed in a follow up set of changes. - The section header in the .ini files expected by the VehicleSignalsConfig class has been changed from "vis-client" to "kuksa-client" since the databroker is not a VIS server, and to some degree forcing an update on the part of clients is useful since their authorization tokens also need to change. - The client key and certificate support has been removed from the VehicleSignalsConfig class, as they are no longer used in either the server or databroker as of KUKSA.val 0.4.0. A new optional parameter, "tls-server-name", has been added to work with the new TLS support behavior. It can be used to override the expected host name for connecting to a non-local databroker instance. - The Navigation constructor now takes an additional parameter to indicate whether the instance acts as a router or a client. The underlying need for this stems from an application acting as a router needing to subscribe to the destination setting actuator targets. Bug-AGL: SPEC-4762 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I253480ae2abf068dc6e41a495454960ed5c0feaf
Diffstat (limited to 'vehicle-signals/vehiclesignals.h')
-rw-r--r--vehicle-signals/vehiclesignals.h87
1 files changed, 26 insertions, 61 deletions
diff --git a/vehicle-signals/vehiclesignals.h b/vehicle-signals/vehiclesignals.h
index fd5fe9c..734cb27 100644
--- a/vehicle-signals/vehiclesignals.h
+++ b/vehicle-signals/vehiclesignals.h
@@ -1,63 +1,19 @@
/*
- * Copyright (C) 2022 Konsulko Group
+ * Copyright (C) 2022,2023 Konsulko Group
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * SPDX-License-Identifier: Apache-2.0
*/
#ifndef VEHICLESIGNALS_H
#define VEHICLESIGNALS_H
#include <QObject>
-#include <QWebSocket>
-// Class to read/hold VIS server configuration
+#include "VehicleSignalsConfig.h"
-class VehicleSignalsConfig
-{
-public:
- explicit VehicleSignalsConfig(const QString &hostname,
- const unsigned port,
- const QByteArray &clientKey,
- const QByteArray &clientCert,
- const QByteArray &caCert,
- const QString &authToken,
- bool verifyPeer = true);
- explicit VehicleSignalsConfig(const QString &appname);
- ~VehicleSignalsConfig() {};
-
- QString hostname() { return m_hostname; };
- unsigned port() { return m_port; };
- QByteArray clientKey() { return m_clientKey; };
- QByteArray clientCert() { return m_clientCert; };
- QByteArray caCert() { return m_caCert; };
- QString authToken() { return m_authToken; };
- bool verifyPeer() { return m_verifyPeer; };
- bool valid() { return m_valid; };
- unsigned verbose() { return m_verbose; };
+class QtKuksaClient;
-private:
- QString m_hostname;
- unsigned m_port;
- QByteArray m_clientKey;
- QByteArray m_clientCert;
- QByteArray m_caCert;
- QString m_authToken;
- bool m_verifyPeer;
- bool m_valid;
- unsigned m_verbose;
-};
-
-// VIS signaling interface class
+// VSS signal interface class
class VehicleSignals : public QObject
{
@@ -70,30 +26,39 @@ public:
Q_INVOKABLE void connect();
Q_INVOKABLE void authorize();
- Q_INVOKABLE void get(const QString &path);
- Q_INVOKABLE void set(const QString &path, const QString &value);
- Q_INVOKABLE void subscribe(const QString &path);
+ Q_INVOKABLE void get(const QString &path, const bool actuator = false);
+
+ Q_INVOKABLE void set(const QString &path, const QString &value, const bool actuator = false);
+ Q_INVOKABLE void set(const QString &path, const qint32 value, const bool actuator = false);
+ Q_INVOKABLE void set(const QString &path, const qint64 value, const bool actuator = false);
+ Q_INVOKABLE void set(const QString &path, const quint32 value, const bool actuator = false);
+ Q_INVOKABLE void set(const QString &path, const quint64 value, const bool actuator = false);
+ Q_INVOKABLE void set(const QString &path, const float value, const bool actuator = false);
+ Q_INVOKABLE void set(const QString &path, const double value, const bool actuator = false);
+
+ Q_INVOKABLE void subscribe(const QString &path, const bool actuator = false);
+ Q_INVOKABLE void subscribe(const QMap<QString, bool> &signals_);
signals:
void connected();
void authorized();
- void getSuccessResponse(QString path, QString value, QString timestamp);
- void signalNotification(QString path, QString value, QString timestamp);
void disconnected();
+ void getSuccessResponse(QString path, QString value, QString timestamp);
+ void setErrorResponse(QString path, QString error);
+ void signalNotification(QString path, QString value, QString timestamp);
private slots:
void onConnected();
- void onError(QAbstractSocket::SocketError error);
- void reconnect();
- void onDisconnected();
- void onTextMessageReceived(QString message);
+ void onGetResponse(QString path, QString value, QString timestamp);
+ void onSetResponse(QString path, QString error);
+ void onSubscribeResponse(QString path, QString value, QString timestamp);
+ void onSubscribeDone(const QMap<QString, bool> &signals_, bool canceled);
private:
VehicleSignalsConfig m_config;
- QWebSocket m_websocket;
- std::atomic<unsigned int> m_request_id;
+ QtKuksaClient *m_broker;
- bool parseData(const QJsonObject &response, QString &path, QString &value, QString &timestamp);
+ void resubscribe(const QMap<QString, bool> &signals_);
};
#endif // VEHICLESIGNALS_H