mirror of
https://github.com/esphome/esphome.git
synced 2025-04-12 22:00:30 +01:00
commit
53fda0e96d
@ -15,6 +15,8 @@ namespace audio {
|
||||
|
||||
static const uint32_t READ_WRITE_TIMEOUT_MS = 20;
|
||||
|
||||
static const uint32_t CONNECTION_TIMEOUT_MS = 5000;
|
||||
|
||||
// The number of times the http read times out with no data before throwing an error
|
||||
static const uint32_t ERROR_COUNT_NO_DATA_READ_TIMEOUT = 100;
|
||||
|
||||
@ -97,7 +99,7 @@ esp_err_t AudioReader::start(const std::string &uri, AudioFileType &file_type) {
|
||||
client_config.user_data = this;
|
||||
client_config.buffer_size = HTTP_STREAM_BUFFER_SIZE;
|
||||
client_config.keep_alive_enable = true;
|
||||
client_config.timeout_ms = 5000; // Shouldn't trigger watchdog resets if caller runs in a task
|
||||
client_config.timeout_ms = CONNECTION_TIMEOUT_MS; // Shouldn't trigger watchdog resets if caller runs in a task
|
||||
|
||||
#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE
|
||||
if (uri.find("https:") != std::string::npos) {
|
||||
@ -189,7 +191,7 @@ esp_err_t AudioReader::start(const std::string &uri, AudioFileType &file_type) {
|
||||
file_type = this->audio_file_type_;
|
||||
}
|
||||
|
||||
this->no_data_read_count_ = 0;
|
||||
this->last_data_read_ms_ = millis();
|
||||
|
||||
this->output_transfer_buffer_ = AudioSinkTransferBuffer::create(this->buffer_size_);
|
||||
if (this->output_transfer_buffer_ == nullptr) {
|
||||
@ -271,8 +273,7 @@ AudioReaderState AudioReader::http_read_() {
|
||||
|
||||
if (received_len > 0) {
|
||||
this->output_transfer_buffer_->increase_buffer_length(received_len);
|
||||
|
||||
this->no_data_read_count_ = 0;
|
||||
this->last_data_read_ms_ = millis();
|
||||
} else if (received_len < 0) {
|
||||
// HTTP read error
|
||||
this->cleanup_connection_();
|
||||
@ -280,12 +281,11 @@ AudioReaderState AudioReader::http_read_() {
|
||||
} else {
|
||||
if (bytes_to_read > 0) {
|
||||
// Read timed out
|
||||
++this->no_data_read_count_;
|
||||
if (this->no_data_read_count_ >= ERROR_COUNT_NO_DATA_READ_TIMEOUT) {
|
||||
// Timed out with no data read too many times, so the http read has failed
|
||||
if ((millis() - this->last_data_read_ms_) > CONNECTION_TIMEOUT_MS) {
|
||||
this->cleanup_connection_();
|
||||
return AudioReaderState::FAILED;
|
||||
}
|
||||
|
||||
delay(READ_WRITE_TIMEOUT_MS);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class AudioReader {
|
||||
void cleanup_connection_();
|
||||
|
||||
size_t buffer_size_;
|
||||
uint32_t no_data_read_count_;
|
||||
uint32_t last_data_read_ms_;
|
||||
|
||||
esp_http_client_handle_t client_{nullptr};
|
||||
|
||||
|
@ -176,9 +176,9 @@ void ESP32BLETracker::loop() {
|
||||
https://github.com/espressif/esp-idf/issues/6688
|
||||
|
||||
*/
|
||||
if (!connecting && !disconnecting && xSemaphoreTake(this->scan_end_lock_, 0L)) {
|
||||
if (!connecting && xSemaphoreTake(this->scan_end_lock_, 0L)) {
|
||||
if (this->scan_continuous_) {
|
||||
if (!promote_to_connecting && !this->scan_start_failed_ && !this->scan_set_param_failed_) {
|
||||
if (!disconnecting && !promote_to_connecting && !this->scan_start_failed_ && !this->scan_set_param_failed_) {
|
||||
this->start_scan_(false);
|
||||
} else {
|
||||
// We didn't start the scan, so we need to release the lock
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "ltr390.h"
|
||||
#include <bitset>
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include <bitset>
|
||||
|
||||
namespace esphome {
|
||||
namespace ltr390 {
|
||||
@ -91,7 +91,12 @@ void LTR390Component::read_uvs_() {
|
||||
uint32_t uv = *val;
|
||||
|
||||
if (this->uvi_sensor_ != nullptr) {
|
||||
this->uvi_sensor_->publish_state((uv / this->sensitivity_uv_) * this->wfac_);
|
||||
// Set sensitivity by linearly scaling against known value in the datasheet
|
||||
float gain_scale_uv = GAINVALUES[this->gain_uv_] / GAIN_MAX;
|
||||
float intg_scale_uv = (RESOLUTIONVALUE[this->res_uv_] * 100) / INTG_MAX;
|
||||
float sensitivity_uv = SENSITIVITY_MAX * gain_scale_uv * intg_scale_uv;
|
||||
|
||||
this->uvi_sensor_->publish_state((uv / sensitivity_uv) * this->wfac_);
|
||||
}
|
||||
|
||||
if (this->uv_sensor_ != nullptr) {
|
||||
@ -166,11 +171,6 @@ void LTR390Component::setup() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set sensitivity by linearly scaling against known value in the datasheet
|
||||
float gain_scale_uv = GAINVALUES[this->gain_uv_] / GAIN_MAX;
|
||||
float intg_scale_uv = (RESOLUTIONVALUE[this->res_uv_] * 100) / INTG_MAX;
|
||||
this->sensitivity_uv_ = SENSITIVITY_MAX * gain_scale_uv * intg_scale_uv;
|
||||
|
||||
// Set sensor read state
|
||||
this->reading_ = false;
|
||||
|
||||
|
@ -77,7 +77,6 @@ class LTR390Component : public PollingComponent, public i2c::I2CDevice {
|
||||
LTR390GAIN gain_uv_;
|
||||
LTR390RESOLUTION res_als_;
|
||||
LTR390RESOLUTION res_uv_;
|
||||
float sensitivity_uv_;
|
||||
float wfac_;
|
||||
|
||||
sensor::Sensor *light_sensor_{nullptr};
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2025.2.1"
|
||||
__version__ = "2025.2.2"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||
|
@ -13,7 +13,7 @@ platformio==6.1.16 # When updating platformio, also update Dockerfile
|
||||
esptool==4.7.0
|
||||
click==8.1.7
|
||||
esphome-dashboard==20250212.0
|
||||
aioesphomeapi==29.1.1
|
||||
aioesphomeapi==29.3.2
|
||||
zeroconf==0.145.1
|
||||
puremagic==1.27
|
||||
ruamel.yaml==0.18.6 # dashboard_import
|
||||
|
Loading…
x
Reference in New Issue
Block a user