summaryrefslogtreecommitdiffstats
path: root/radio/RadioGrpcClient.h
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2023-01-03 00:58:28 -0500
committerScott Murray <scott.murray@konsulko.com>2023-01-19 00:36:27 +0000
commit9a7e2c5420cae0669c149d5dddbcd99a8fac0038 (patch)
tree7793553de5d8359c8dfdb2a204df41b0288a3a81 /radio/RadioGrpcClient.h
parent888eca5ba20672448624a418ebad573dd4d640e6 (diff)
Rework radio support for new gRPC API
Update the stubbed out radio support library to use the new gRPC API. The "Radio" Qt wrapper object has been renamed to "RadioClient" to avoid conflicting with the generated gRPC API code. This somewhat aligns with the naming that has been used with the AppLauncher support. Bug-AGL: SPEC-4665 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I642f9b9b62d6981cf5231ecea4caddba713f493a (cherry picked from commit 22ad8cbaad00d89361cbd92023dd20a807bcf5cb)
Diffstat (limited to 'radio/RadioGrpcClient.h')
-rw-r--r--radio/RadioGrpcClient.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/radio/RadioGrpcClient.h b/radio/RadioGrpcClient.h
new file mode 100644
index 0000000..603253a
--- /dev/null
+++ b/radio/RadioGrpcClient.h
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: Apache-2.0
+/*
+ * Copyright (C) 2023 Konsulko Group
+ */
+
+#ifndef RADIO_GRPC_CLIENT_H
+#define RADIO_GRPC_CLIENT_H
+
+#include <QObject>
+#include <QList>
+#include <QMap>
+#include <QThread>
+#include <grpcpp/grpcpp.h>
+
+#include "radio.grpc.pb.h"
+
+using grpc::Channel;
+
+class RadioStatusEventReader : public QObject
+{
+ Q_OBJECT
+public:
+ RadioStatusEventReader(std::shared_ptr<automotivegradelinux::Radio::Stub> &stub,
+ QObject *parent = Q_NULLPTR) : QObject(parent), stub_(stub) {}
+
+public slots:
+ void GetStatusEvents();
+
+signals:
+ void bandUpdate(int band);
+ void frequencyUpdate(int frequency);
+ void playingUpdate(bool status);
+ void scanningUpdate(bool scanning);
+
+ void finished();
+
+private:
+ std::shared_ptr<automotivegradelinux::Radio::Stub> stub_;
+};
+
+class RadioGrpcClient : public QObject
+{
+ Q_OBJECT
+
+public:
+ RadioGrpcClient(QObject *parent = Q_NULLPTR);
+
+ void SetBand(unsigned int band);
+ void SetFrequency(unsigned int frequency);
+ void Start();
+ void Stop();
+ void ScanForward();
+ void ScanBackward();
+ void ScanStop();
+ void GetBandParameters(unsigned int band,
+ unsigned int &min,
+ unsigned int &max,
+ unsigned int &step);
+
+private:
+ std::shared_ptr<automotivegradelinux::Radio::Stub> stub_;
+
+ QThread m_event_thread;
+
+};
+
+#endif // RADIO_GRPC_CLIENT_H