mirror of
https://github.com/esphome/esphome.git
synced 2026-02-28 01:44:20 -07:00
[shelly_dimmer] Fix millis overflow in ACK timeout check (#14288)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -149,7 +149,7 @@ stm32_err_t stm32_get_ack_timeout(const stm32_unique_ptr &stm, uint32_t timeout)
|
||||
do {
|
||||
yield();
|
||||
if (!stream->available()) {
|
||||
if (millis() < start_time + timeout)
|
||||
if (millis() - start_time < timeout)
|
||||
continue;
|
||||
ESP_LOGD(TAG, "Failed to read ACK timeout=%i", timeout);
|
||||
return STM32_ERR_UNKNOWN;
|
||||
@@ -212,7 +212,7 @@ stm32_err_t stm32_resync(const stm32_unique_ptr &stm) {
|
||||
static_assert(sizeof(buf) == BUFFER_SIZE, "Buf expected to be 2 bytes");
|
||||
|
||||
uint8_t ack;
|
||||
while (t1 < t0 + STM32_RESYNC_TIMEOUT) {
|
||||
while (t1 - t0 < STM32_RESYNC_TIMEOUT) {
|
||||
stream->write_array(buf, BUFFER_SIZE);
|
||||
stream->flush();
|
||||
if (!stream->read_array(&ack, 1)) {
|
||||
|
||||
Reference in New Issue
Block a user