mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
[wifi][captive_portal][heatpumpir][es8388] Fix wrong behavior in 4 components (#14657)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ static const char *const TAG = "captive_portal.dns";
|
||||
// DNS constants
|
||||
static constexpr uint16_t DNS_PORT = 53;
|
||||
static constexpr uint16_t DNS_QR_FLAG = 1 << 15;
|
||||
static constexpr uint16_t DNS_AA_FLAG = 1 << 10;
|
||||
static constexpr uint16_t DNS_OPCODE_MASK = 0x7800;
|
||||
static constexpr uint16_t DNS_QTYPE_A = 0x0001;
|
||||
static constexpr uint16_t DNS_QCLASS_IN = 0x0001;
|
||||
@@ -162,8 +163,8 @@ void DNSServer::process_next_request() {
|
||||
}
|
||||
|
||||
// Build DNS response by modifying the request in-place
|
||||
header->flags = htons(DNS_QR_FLAG | 0x8000); // Response + Authoritative
|
||||
header->an_count = htons(1); // One answer
|
||||
header->flags = htons(DNS_QR_FLAG | DNS_AA_FLAG); // Response + Authoritative
|
||||
header->an_count = htons(1); // One answer
|
||||
|
||||
// Add answer section after the question
|
||||
size_t question_len = (ptr + sizeof(DNSQuestion)) - this->buffer_ - sizeof(DNSHeader);
|
||||
|
||||
@@ -152,7 +152,7 @@ void ES8388::dump_config() {
|
||||
|
||||
bool ES8388::set_volume(float volume) {
|
||||
volume = clamp(volume, 0.0f, 1.0f);
|
||||
uint8_t value = remap<uint8_t, float>(volume, 0.0f, 1.0f, -96, 0);
|
||||
uint8_t value = remap<uint8_t, float>(volume, 0.0f, 1.0f, 192, 0);
|
||||
ESP_LOGD(TAG, "Setting ES8388_DACCONTROL4 / ES8388_DACCONTROL5 to 0x%02X (volume: %f)", value, volume);
|
||||
ES8388_ERROR_CHECK(this->write_byte(ES8388_DACCONTROL4, value));
|
||||
ES8388_ERROR_CHECK(this->write_byte(ES8388_DACCONTROL5, value));
|
||||
@@ -163,7 +163,7 @@ bool ES8388::set_volume(float volume) {
|
||||
float ES8388::volume() {
|
||||
uint8_t value;
|
||||
ES8388_ERROR_CHECK(this->read_byte(ES8388_DACCONTROL4, &value));
|
||||
return remap<float, uint8_t>(value, -96, 0, 0.0f, 1.0f);
|
||||
return remap<float, uint8_t>(value, 192, 0, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
bool ES8388::set_mute_state_(bool mute_state) {
|
||||
|
||||
@@ -114,7 +114,7 @@ void HeatpumpIRClimate::setup() {
|
||||
this->current_temperature = state;
|
||||
|
||||
IRSenderESPHome esp_sender(this->transmitter_);
|
||||
this->heatpump_ir_->send(esp_sender, uint8_t(lround(this->current_temperature + 0.5)));
|
||||
this->heatpump_ir_->send(esp_sender, uint8_t(lround(this->current_temperature)));
|
||||
|
||||
// current temperature changed, publish state
|
||||
this->publish_state();
|
||||
|
||||
@@ -638,8 +638,6 @@ WiFiSTAConnectStatus WiFiComponent::wifi_sta_connect_status_() const {
|
||||
return WiFiSTAConnectStatus::IDLE;
|
||||
}
|
||||
bool WiFiComponent::wifi_scan_start_(bool passive) {
|
||||
static bool first_scan = false;
|
||||
|
||||
// enable STA
|
||||
if (!this->wifi_mode_(true, {}))
|
||||
return false;
|
||||
@@ -656,23 +654,13 @@ bool WiFiComponent::wifi_scan_start_(bool passive) {
|
||||
config.show_hidden = 1;
|
||||
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
|
||||
config.scan_type = passive ? WIFI_SCAN_TYPE_PASSIVE : WIFI_SCAN_TYPE_ACTIVE;
|
||||
if (first_scan) {
|
||||
if (passive) {
|
||||
config.scan_time.passive = 200;
|
||||
} else {
|
||||
config.scan_time.active.min = 100;
|
||||
config.scan_time.active.max = 200;
|
||||
}
|
||||
if (passive) {
|
||||
config.scan_time.passive = 500;
|
||||
} else {
|
||||
if (passive) {
|
||||
config.scan_time.passive = 500;
|
||||
} else {
|
||||
config.scan_time.active.min = 400;
|
||||
config.scan_time.active.max = 500;
|
||||
}
|
||||
config.scan_time.active.min = 400;
|
||||
config.scan_time.active.max = 500;
|
||||
}
|
||||
#endif
|
||||
first_scan = false;
|
||||
bool ret = wifi_station_scan(&config, &WiFiComponent::s_wifi_scan_done_callback);
|
||||
if (!ret) {
|
||||
ESP_LOGV(TAG, "wifi_station_scan failed");
|
||||
|
||||
Reference in New Issue
Block a user