21constexpr uint16_t SETPOINT_LOW_BYTE_MASK = 0xFF;
24constexpr size_t PAYLOAD_LEN_NO_VALUE = 4;
26constexpr size_t PAYLOAD_LEN_ONE_VALUE = 5;
32constexpr float DEGREES_TO_TENTHS = 10.0F;
35enum class HeatingValueKind : uint8_t {
48struct HeatingFunctionDescriptor {
52 HeatingValueKind kind;
63constexpr HeatingFunctionDescriptor HEATING_FUNCTIONS[] = {
76 for (
const auto &d : HEATING_FUNCTIONS) {
90 return "set_temperature";
94 return "set_presence";
98 return "midnight_sync";
104 const HeatingFunctionDescriptor *d = descriptor_for(fn);
112 out[1] = d->direction;
114 out[3] = d->register_low;
117 case HeatingValueKind::NONE:
118 return PAYLOAD_LEN_NO_VALUE;
120 case HeatingValueKind::TEMPERATURE: {
123 if (!std::isfinite(value) || value < HEATING_TEMP_MIN_C || value >
HEATING_TEMP_MAX_C)
136 const auto tenths =
static_cast<uint16_t
>(std::round(value * DEGREES_TO_TENTHS));
137 out[4] =
static_cast<uint8_t
>(tenths & SETPOINT_LOW_BYTE_MASK);
138 out[PAYLOAD_LEN_TEMPERATURE - 1] =
static_cast<uint8_t
>(tenths >>
BITS_PER_BYTE);
139 return PAYLOAD_LEN_TEMPERATURE;
142 case HeatingValueKind::MODE:
148 out[4] =
static_cast<uint8_t
>(value);
149 return PAYLOAD_LEN_ONE_VALUE;
151 case HeatingValueKind::BINARY:
153 if (value != 0.0F && value != 1.0F)
155 out[4] =
static_cast<uint8_t
>(value);
156 return PAYLOAD_LEN_ONE_VALUE;
static constexpr uint8_t BITS_PER_BYTE
Number of bits in one protocol byte.
constexpr size_t HEATING_PAYLOAD_MAX_SIZE
Largest payload any function produces — SET_TEMPERATURE's 6-byte form (iohcCozyDevice2W....
size_t encode_heating_payload(HeatingFunction fn, float value, uint8_t out[HEATING_PAYLOAD_MAX_SIZE])
Encode one heating function into a CMD_WRITE_PRIVATE (0x20) payload.
HeatingFunction
Heating functions, one per user-pressable radiator button in the reference.
@ MIDNIGHT_SYNC
Reads register 0x0130 — the comfort/eco/auto setpoint block (iohcCozyDevice2W.cpp:248; AtlanticThermo...
@ POWER_ON
Wake / retrieve paired devices (iohcCozyDevice2W.cpp:105).
@ SET_PRESENCE
Presence / absence (iohcCozyDevice2W.cpp:195).
@ SET_TEMPERATURE
Setpoint in degrees Celsius (iohcCozyDevice2W.cpp:125).
@ SET_MODE
Operating mode (iohcCozyDevice2W.cpp:155).
@ SET_WINDOW
Open-window / frost-protection (iohcCozyDevice2W.cpp:218).
constexpr uint8_t HEATING_REGISTER_HIGH_BYTE
Payload byte at index 2 — the high byte of the 16-bit register number, constant 0x01 (registers are 0...
constexpr float HEATING_TEMP_MAX_C
Highest setpoint this codec will encode.
const char * heating_function_name(HeatingFunction fn)
Stable lowercase name for a heating function ("power_on", "set_temperature", ...).
@ OFF
Off / standby; note the value is 0x04, not 0x03 (that is the reference's commented-out "special" mode...
@ PROG
Program mode; device runs its own stored weekly schedule (iohcCozyDevice2W.cpp:160).
@ MANUAL
Manual mode; follows the last SET_TEMPERATURE setpoint (iohcCozyDevice2W.cpp:159).
@ AUTO
Automatic mode; device manages the setpoint itself (iohcCozyDevice2W.cpp:158).
constexpr uint8_t HEATING_PAYLOAD_PREFIX
Leading payload byte, common to every function (iohcCozyDevice2W.cpp:105 et al.).
@ NONE
target_fw is unknown, or its required bootloader matches bootloader_version.
Pure codec for IO-Homecontrol 2W heating/climate functions (CMD_WRITE_PRIVATE 0x20).
Fundamental IO-Homecontrol frame and crypto size constants.