mirror of
https://github.com/esphome/esphome.git
synced 2024-12-10 14:45:56 +01:00
parent
a825ef59d4
commit
12cdeca48a
@ -133,8 +133,10 @@ bool HitachiClimate::get_swing_v_() {
|
||||
}
|
||||
|
||||
void HitachiClimate::set_swing_h_(uint8_t position) {
|
||||
if (position > HITACHI_AC344_SWINGH_LEFT_MAX)
|
||||
return set_swing_h_(HITACHI_AC344_SWINGH_MIDDLE);
|
||||
if (position > HITACHI_AC344_SWINGH_LEFT_MAX) {
|
||||
set_swing_h_(HITACHI_AC344_SWINGH_MIDDLE);
|
||||
return;
|
||||
}
|
||||
set_bits(&remote_state_[HITACHI_AC344_SWINGH_BYTE], HITACHI_AC344_SWINGH_OFFSET, HITACHI_AC344_SWINGH_SIZE, position);
|
||||
set_button_(HITACHI_AC344_BUTTON_SWINGH);
|
||||
}
|
||||
|
@ -133,8 +133,10 @@ bool HitachiClimate::get_swing_v_() {
|
||||
}
|
||||
|
||||
void HitachiClimate::set_swing_h_(uint8_t position) {
|
||||
if (position > HITACHI_AC424_SWINGH_LEFT_MAX)
|
||||
return set_swing_h_(HITACHI_AC424_SWINGH_MIDDLE);
|
||||
if (position > HITACHI_AC424_SWINGH_LEFT_MAX) {
|
||||
set_swing_h_(HITACHI_AC424_SWINGH_MIDDLE);
|
||||
return;
|
||||
}
|
||||
set_bits(&remote_state_[HITACHI_AC424_SWINGH_BYTE], HITACHI_AC424_SWINGH_OFFSET, HITACHI_AC424_SWINGH_SIZE, position);
|
||||
set_button_(HITACHI_AC424_BUTTON_SWINGH);
|
||||
}
|
||||
|
@ -313,8 +313,9 @@ void ILI9XXXDisplay::draw_pixels_at(int x_start, int y_start, int w, int h, cons
|
||||
// do color conversion pixel-by-pixel into the buffer and draw it later. If this is happening the user has not
|
||||
// configured the renderer well.
|
||||
if (this->rotation_ != display::DISPLAY_ROTATION_0_DEGREES || bitness != display::COLOR_BITNESS_565 || !big_endian) {
|
||||
return display::Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset,
|
||||
x_pad);
|
||||
display::Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset,
|
||||
x_pad);
|
||||
return;
|
||||
}
|
||||
this->set_addr_window_(x_start, y_start, x_start + w - 1, y_start + h - 1);
|
||||
// x_ and y_offset are offsets into the source buffer, unrelated to our own offsets into the display.
|
||||
|
@ -146,7 +146,8 @@ void QspiDbi::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8
|
||||
return;
|
||||
if (bitness != display::COLOR_BITNESS_565 || order != this->color_mode_ ||
|
||||
big_endian != (this->bit_order_ == spi::BIT_ORDER_MSB_FIRST)) {
|
||||
return Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, x_pad);
|
||||
Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, x_pad);
|
||||
return;
|
||||
} else if (this->draw_from_origin_) {
|
||||
auto stride = x_offset + w + x_pad;
|
||||
for (int y = 0; y != h; y++) {
|
||||
|
@ -483,7 +483,7 @@ void ST7735::spi_master_write_color_(uint16_t color, uint16_t size) {
|
||||
}
|
||||
|
||||
this->dc_pin_->digital_write(true);
|
||||
return write_array(byte, size * 2);
|
||||
write_array(byte, size * 2);
|
||||
}
|
||||
|
||||
} // namespace st7735
|
||||
|
@ -252,7 +252,7 @@ void ST7789V::write_color_(uint16_t color, uint16_t size) {
|
||||
}
|
||||
|
||||
this->dc_pin_->digital_write(true);
|
||||
return write_array(byte, size * 2);
|
||||
write_array(byte, size * 2);
|
||||
}
|
||||
|
||||
size_t ST7789V::get_buffer_length_() {
|
||||
|
@ -434,7 +434,8 @@ static bool process_rolling_code(Provider &provider, uint8_t *&buf, const uint8_
|
||||
void UDPComponent::process_(uint8_t *buf, const size_t len) {
|
||||
auto ping_key_seen = !this->ping_pong_enable_;
|
||||
if (len < 8) {
|
||||
return ESP_LOGV(TAG, "Bad length %zu", len);
|
||||
ESP_LOGV(TAG, "Bad length %zu", len);
|
||||
return;
|
||||
}
|
||||
char namebuf[256]{};
|
||||
uint8_t byte;
|
||||
@ -442,31 +443,40 @@ void UDPComponent::process_(uint8_t *buf, const size_t len) {
|
||||
const uint8_t *end = buf + len;
|
||||
FuData rdata{};
|
||||
auto magic = get_uint16(buf);
|
||||
if (magic != MAGIC_NUMBER && magic != MAGIC_PING)
|
||||
return ESP_LOGV(TAG, "Bad magic %X", magic);
|
||||
if (magic != MAGIC_NUMBER && magic != MAGIC_PING) {
|
||||
ESP_LOGV(TAG, "Bad magic %X", magic);
|
||||
return;
|
||||
}
|
||||
|
||||
auto hlen = *buf++;
|
||||
if (hlen > len - 3) {
|
||||
return ESP_LOGV(TAG, "Bad hostname length %u > %zu", hlen, len - 3);
|
||||
ESP_LOGV(TAG, "Bad hostname length %u > %zu", hlen, len - 3);
|
||||
return;
|
||||
}
|
||||
memcpy(namebuf, buf, hlen);
|
||||
if (strcmp(this->name_, namebuf) == 0) {
|
||||
return ESP_LOGV(TAG, "Ignoring our own data");
|
||||
ESP_LOGV(TAG, "Ignoring our own data");
|
||||
return;
|
||||
}
|
||||
buf += hlen;
|
||||
if (magic == MAGIC_PING)
|
||||
return this->process_ping_request_(namebuf, buf, end - buf);
|
||||
if (magic == MAGIC_PING) {
|
||||
this->process_ping_request_(namebuf, buf, end - buf);
|
||||
return;
|
||||
}
|
||||
if (round4(len) != len) {
|
||||
return ESP_LOGW(TAG, "Bad length %zu", len);
|
||||
ESP_LOGW(TAG, "Bad length %zu", len);
|
||||
return;
|
||||
}
|
||||
hlen = round4(hlen + 3);
|
||||
buf = start_ptr + hlen;
|
||||
if (buf == end) {
|
||||
return ESP_LOGV(TAG, "No data after header");
|
||||
ESP_LOGV(TAG, "No data after header");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->providers_.count(namebuf) == 0) {
|
||||
return ESP_LOGVV(TAG, "Unknown hostname %s", namebuf);
|
||||
ESP_LOGVV(TAG, "Unknown hostname %s", namebuf);
|
||||
return;
|
||||
}
|
||||
auto &provider = this->providers_[namebuf];
|
||||
// if encryption not used with this host, ping check is pointless since it would be easily spoofed.
|
||||
@ -489,7 +499,8 @@ void UDPComponent::process_(uint8_t *buf, const size_t len) {
|
||||
if (!process_rolling_code(provider, buf, end))
|
||||
return;
|
||||
} else if (byte != DATA_KEY) {
|
||||
return ESP_LOGV(TAG, "Expected rolling_key or data_key, got %X", byte);
|
||||
ESP_LOGV(TAG, "Expected rolling_key or data_key, got %X", byte);
|
||||
return;
|
||||
}
|
||||
while (buf < end) {
|
||||
byte = *buf++;
|
||||
@ -497,7 +508,8 @@ void UDPComponent::process_(uint8_t *buf, const size_t len) {
|
||||
continue;
|
||||
if (byte == PING_KEY) {
|
||||
if (end - buf < 4) {
|
||||
return ESP_LOGV(TAG, "PING_KEY requires 4 more bytes");
|
||||
ESP_LOGV(TAG, "PING_KEY requires 4 more bytes");
|
||||
return;
|
||||
}
|
||||
auto key = get_uint32(buf);
|
||||
if (key == this->ping_key_) {
|
||||
@ -515,21 +527,25 @@ void UDPComponent::process_(uint8_t *buf, const size_t len) {
|
||||
}
|
||||
if (byte == BINARY_SENSOR_KEY) {
|
||||
if (end - buf < 3) {
|
||||
return ESP_LOGV(TAG, "Binary sensor key requires at least 3 more bytes");
|
||||
ESP_LOGV(TAG, "Binary sensor key requires at least 3 more bytes");
|
||||
return;
|
||||
}
|
||||
rdata.u32 = *buf++;
|
||||
} else if (byte == SENSOR_KEY) {
|
||||
if (end - buf < 6) {
|
||||
return ESP_LOGV(TAG, "Sensor key requires at least 6 more bytes");
|
||||
ESP_LOGV(TAG, "Sensor key requires at least 6 more bytes");
|
||||
return;
|
||||
}
|
||||
rdata.u32 = get_uint32(buf);
|
||||
} else {
|
||||
return ESP_LOGW(TAG, "Unknown key byte %X", byte);
|
||||
ESP_LOGW(TAG, "Unknown key byte %X", byte);
|
||||
return;
|
||||
}
|
||||
|
||||
hlen = *buf++;
|
||||
if (end - buf < hlen) {
|
||||
return ESP_LOGV(TAG, "Name length of %u not available", hlen);
|
||||
ESP_LOGV(TAG, "Name length of %u not available", hlen);
|
||||
return;
|
||||
}
|
||||
memset(namebuf, 0, sizeof namebuf);
|
||||
memcpy(namebuf, buf, hlen);
|
||||
|
@ -67,7 +67,7 @@ bool Component::cancel_retry(const std::string &name) { // NOLINT
|
||||
}
|
||||
|
||||
void Component::set_timeout(const std::string &name, uint32_t timeout, std::function<void()> &&f) { // NOLINT
|
||||
return App.scheduler.set_timeout(this, name, timeout, std::move(f));
|
||||
App.scheduler.set_timeout(this, name, timeout, std::move(f));
|
||||
}
|
||||
|
||||
bool Component::cancel_timeout(const std::string &name) { // NOLINT
|
||||
|
Loading…
Reference in New Issue
Block a user