summaryrefslogtreecommitdiffstats
path: root/radio/RadioGrpcClient.h
blob: 603253ad6587f0458835c0f2e64127e2c88cd8da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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