blob: 44cb2cc22caabe020ec8482eb59ab390cf5c74e5 (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
* Copyright (C) 2022,2023 Konsulko Group
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _HVAC_SERVICE_H
#define _HVAC_SERVICE_H
#include <mutex>
#include <glib.h>
#include "KuksaConfig.h"
#include "KuksaClient.h"
#include "HvacCanHelper.h"
#include "HvacLedHelper.h"
class HvacService
{
public:
HvacService(const KuksaConfig &config, GMainLoop *loop = NULL);
~HvacService();
// Callback for KuksaClient subscribe API reconnect
static gboolean resubscribe_cb(gpointer data) {
struct resubscribe_data *d = (struct resubscribe_data*) data;
if (d && d->self) {
((HvacService*) d->self)->Resubscribe(d->request);
}
return FALSE;
}
private:
struct resubscribe_data {
HvacService *self;
const SubscribeRequest *request;
};
GMainLoop *m_loop;
KuksaConfig m_config;
KuksaClient *m_broker;
HvacCanHelper m_can_helper;
HvacLedHelper m_led_helper;
std::mutex m_hvac_state_mutex;
bool m_IsAirConditioningActive = false;
bool m_IsFrontDefrosterActive = false;
bool m_IsRearDefrosterActive = false;
bool m_IsRecirculationActive = false;
void HandleSignalChange(const std::string &path, const Datapoint &dp);
void HandleSignalSetError(const std::string &path, const Error &error);
void HandleSubscribeDone(const SubscribeRequest *request, const Status &status);
void Resubscribe(const SubscribeRequest *request);
void set_left_temperature(uint8_t temp);
void set_right_temperature(uint8_t temp);
void set_left_fan_speed(uint8_t temp);
void set_right_fan_speed(uint8_t temp);
void set_fan_speed(uint8_t temp);
void set_ac_active(bool active);
void set_front_defrost_active(bool active);
void set_rear_defrost_active(bool active);
void set_recirculation_active(bool active);
};
#endif // _HVAC_SERVICE_H
|