summaryrefslogtreecommitdiffstats
path: root/stm32/app/ot.c
diff options
context:
space:
mode:
Diffstat (limited to 'stm32/app/ot.c')
-rw-r--r--stm32/app/ot.c84
1 files changed, 56 insertions, 28 deletions
diff --git a/stm32/app/ot.c b/stm32/app/ot.c
index e604b50..944d174 100644
--- a/stm32/app/ot.c
+++ b/stm32/app/ot.c
@@ -58,6 +58,7 @@ static unsigned ot_status_wdt;
#define OT_IDX_CH_WATER_PRESSURE 18
#define OT_IDX_RETURN_WATER_TEMP 28
+#define OT_IDX_SUPPLY_INLET_TEMP 80
@@ -70,7 +71,7 @@ static inline int parity (uint8_t v)
return (0x6996u >> ((v ^ (v >> 4)) & 0xf)) & 1;
}
-void ot_parity (uint8_t *data)
+static void ot_parity (uint8_t *data)
{
int p;
p = parity (data[0]);
@@ -202,12 +203,51 @@ void ot_rx_thm (uint8_t *msg, int error)
}
}
+static int ot_fake_read_ack (unsigned id, uint8_t *msg)
+{
+ unsigned t;
+
+ switch (id) {
+ case OT_IDX_CH_WATER_PRESSURE:
+ t = pressure_ch();
+
+ if (!t) return -1;
+
+ break;
+
+ case OT_IDX_RETURN_WATER_TEMP:
+ t = temp_ch_return();
+
+ if (!t) return -1;
+
+ break;
+
+ case OT_IDX_SUPPLY_INLET_TEMP:
+ t = temp_supply_inlet();
+
+ if (!t) return -1;
+
+ break;
+
+ default:
+ return -1;
+ }
+
+
+
+ msg[0] = OT_READ_ACK << 4;
+ msg[1] = id;
+ msg[2] = t >> 8;
+ msg[3] = t & 0xff;
+
+ return 0;
+}
+
+
void ot_rx_blr (uint8_t *msg, int error)
{
unsigned type = (msg[0] >> 4) & 7;
unsigned id = msg[1];
- uint16_t t;
- unsigned handled = 0 ;
unsigned idx;
@@ -217,30 +257,10 @@ void ot_rx_blr (uint8_t *msg, int error)
idx = OT_INDEX (in_flight_req_type, id);
-
if ((in_flight_req_type == OT_READ_DATA) && (type != OT_READ_ACK)) {
- switch (idx) {
- case OT_IDX_CH_WATER_PRESSURE:
- t = pressure_ch();
- handled = 1;
- break;
-
- case OT_IDX_RETURN_WATER_TEMP:
- t = temp_ch_return();
- handled = 1;
- break;
-
- }
-
- if (handled) {
-
- type = OT_READ_ACK;
-
- msg[0] &= 0x8f;
- msg[0] |= type << 4;
- msg[2] = t >> 8;
- msg[3] = t & 0xff;
- ot_debug ("B", msg, "");
+ if (!ot_fake_read_ack (id, msg)) {
+ ot_debug (" A", msg, " (faked)");
+ type = (msg[0] >> 4) & 7;
}
}
@@ -338,6 +358,7 @@ static void ot_force_status (void)
static void ot_30s_ticker (void)
{
uint8_t data[2];
+ uint8_t msg[4];
printf ("Q send temp set points\r\n");
@@ -354,8 +375,15 @@ static void ot_30s_ticker (void)
ot_request_ovr (OT_WRITE_DATA, OT_IDX_DHW_SETPOINT, data);
}
- ot_request_ovr (OT_READ_DATA, OT_IDX_CH_WATER_PRESSURE, NULL);
- ot_request_ovr (OT_READ_DATA, OT_IDX_RETURN_WATER_TEMP, NULL);
+
+ if (!ot_fake_read_ack (OT_IDX_CH_WATER_PRESSURE, msg))
+ ot_debug ("B", msg, " (fake reply)");
+
+ if (!ot_fake_read_ack (OT_IDX_RETURN_WATER_TEMP, msg))
+ ot_debug ("B", msg, " (fake reply)");
+
+ if (!ot_fake_read_ack (OT_IDX_SUPPLY_INLET_TEMP, msg))
+ ot_debug ("B", msg, " (fake reply)");
}