summaryrefslogtreecommitdiffstats
path: root/src/HvacCanHelper.h
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2023-08-24 15:39:24 -0400
committerScott Murray <scott.murray@konsulko.com>2023-08-24 15:42:30 -0400
commit0a1426d097688912188bcb59ff59d9c596e82b4d (patch)
tree8032edef0f8a6c3bbebe8f4382486f679bb2143f /src/HvacCanHelper.h
parentf0ac80936b73a44131564c4f65ecc0c9a9db7d39 (diff)
Rework to switch to using KUKSA.val databroker
Rework to use the "VAL" gRPC API from the KUKSA.val databroker instead of the older server's WebSocket interface. Some source files have been renamed to match the class naming to provide a bit more consistency. Bug-AGL: SPEC-4762 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ib1ec31af439a9b2d5244e2232ea7be1ed9a2574c
Diffstat (limited to 'src/HvacCanHelper.h')
-rw-r--r--src/HvacCanHelper.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/HvacCanHelper.h b/src/HvacCanHelper.h
new file mode 100644
index 0000000..0787834
--- /dev/null
+++ b/src/HvacCanHelper.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2022,2023 Konsulko Group
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef _HVAC_CAN_HELPER_H
+#define _HVAC_CAN_HELPER_H
+
+#include <cstdint>
+#include <string>
+#include <linux/can.h>
+
+class HvacCanHelper
+{
+public:
+ HvacCanHelper();
+
+ ~HvacCanHelper();
+
+ void set_left_temperature(uint8_t temp);
+
+ void set_right_temperature(uint8_t temp);
+
+ void set_fan_speed(uint8_t temp);
+
+private:
+ uint8_t convert_temp(uint8_t value) {
+ int result = ((0xF0 - 0x10) / 15) * (value - 15) + 0x10;
+ if (result < 0x10)
+ result = 0x10;
+ if (result > 0xF0)
+ result = 0xF0;
+
+ return (uint8_t) result;
+ }
+
+ void read_config();
+
+ void can_open();
+
+ void can_close();
+
+ void can_update();
+
+ std::string m_port;
+ unsigned m_verbose;
+ bool m_config_valid;
+ bool m_active;
+ int m_can_socket;
+ struct sockaddr_can m_can_addr;
+
+ uint8_t m_temp_left;
+ uint8_t m_temp_right;
+ uint8_t m_fan_speed;
+};
+
+#endif // _HVAC_CAN_HELPER_H