From 9e522e8fa3b48f9f4d5caebbd2e086b0efef1577 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Sun, 29 Jan 2023 16:58:20 +1000 Subject: [PATCH] fix determination of the current weekday. (#17812) the result of c logical expressions is 0 or 1, not the values of the operands. --- tasmota/tasmota_xdrv_driver/xdrv_65_tuyamcubr.ino | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_65_tuyamcubr.ino b/tasmota/tasmota_xdrv_driver/xdrv_65_tuyamcubr.ino index 48697e41e..e6b471750 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_65_tuyamcubr.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_65_tuyamcubr.ino @@ -862,6 +862,11 @@ tuyamcubr_recv_time(struct tuyamcubr_softc *sc, uint8_t v, const uint8_t *data, size_t datalen) { struct tuyamcubr_time tm; + uint8_t weekday; + + weekday = RtcTime.day_of_week - 1; + if (weekday == 0) + weekday = 7; /* check datalen? should be 0 */ @@ -872,7 +877,7 @@ tuyamcubr_recv_time(struct tuyamcubr_softc *sc, uint8_t v, tm.hour = RtcTime.hour; tm.minute = RtcTime.minute; tm.second = RtcTime.second; - tm.weekday = (RtcTime.day_of_week - 1) || 7; + tm.weekday = weekday; tuyamcubr_send(sc, TUYAMCUBR_CMD_TIME, &tm, sizeof(tm)); }