mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
Prepare some components for idf >= 5 (#5061)
This commit is contained in:
parent
959d1944fd
commit
3eff7e76aa
10 changed files with 32 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "airthings_listener.h"
|
#include "airthings_listener.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
#ifdef USE_ESP32
|
#ifdef USE_ESP32
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ bool AirthingsListener::parse_device(const esp32_ble_tracker::ESPBTDevice &devic
|
||||||
sn |= ((uint32_t) it.data[2] << 16);
|
sn |= ((uint32_t) it.data[2] << 16);
|
||||||
sn |= ((uint32_t) it.data[3] << 24);
|
sn |= ((uint32_t) it.data[3] << 24);
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Found AirThings device Serial:%u (MAC: %s)", sn, device.address_str().c_str());
|
ESP_LOGD(TAG, "Found AirThings device Serial:%" PRIu32 " (MAC: %s)", sn, device.address_str().c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "bedjet_hub.h"
|
#include "bedjet_hub.h"
|
||||||
#include "bedjet_child.h"
|
#include "bedjet_child.h"
|
||||||
#include "bedjet_const.h"
|
#include "bedjet_const.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace bedjet {
|
namespace bedjet {
|
||||||
|
@ -373,7 +374,7 @@ void BedJetHub::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t ga
|
||||||
if (this->last_notify_ == 0 || delta > MIN_NOTIFY_THROTTLE || this->force_refresh_) {
|
if (this->last_notify_ == 0 || delta > MIN_NOTIFY_THROTTLE || this->force_refresh_) {
|
||||||
// Set reentrant flag to prevent processing multiple packets.
|
// Set reentrant flag to prevent processing multiple packets.
|
||||||
this->processing_ = true;
|
this->processing_ = true;
|
||||||
ESP_LOGVV(TAG, "[%s] Decoding packet: last=%d, delta=%d, force=%s", this->get_name().c_str(),
|
ESP_LOGVV(TAG, "[%s] Decoding packet: last=%" PRId32 ", delta=%" PRId32 ", force=%s", this->get_name().c_str(),
|
||||||
this->last_notify_, delta, this->force_refresh_ ? "y" : "n");
|
this->last_notify_, delta, this->force_refresh_ ? "y" : "n");
|
||||||
bool needs_extra = this->codec_->decode_notify(param->notify.value, param->notify.value_len);
|
bool needs_extra = this->codec_->decode_notify(param->notify.value, param->notify.value_len);
|
||||||
|
|
||||||
|
@ -523,11 +524,11 @@ void BedJetHub::dispatch_status_() {
|
||||||
|
|
||||||
ESP_LOGI(TAG, "[%s] Still waiting for first GATT notify event.", this->get_name().c_str());
|
ESP_LOGI(TAG, "[%s] Still waiting for first GATT notify event.", this->get_name().c_str());
|
||||||
} else if (diff > NOTIFY_WARN_THRESHOLD) {
|
} else if (diff > NOTIFY_WARN_THRESHOLD) {
|
||||||
ESP_LOGW(TAG, "[%s] Last GATT notify was %d seconds ago.", this->get_name().c_str(), diff / 1000);
|
ESP_LOGW(TAG, "[%s] Last GATT notify was %" PRId32 " seconds ago.", this->get_name().c_str(), diff / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->timeout_ > 0 && diff > this->timeout_ && this->parent()->enabled) {
|
if (this->timeout_ > 0 && diff > this->timeout_ && this->parent()->enabled) {
|
||||||
ESP_LOGW(TAG, "[%s] Timed out after %d sec. Retrying...", this->get_name().c_str(), this->timeout_);
|
ESP_LOGW(TAG, "[%s] Timed out after %" PRId32 " sec. Retrying...", this->get_name().c_str(), this->timeout_);
|
||||||
// set_enabled(false) will only close the connection if state != IDLE.
|
// set_enabled(false) will only close the connection if state != IDLE.
|
||||||
this->parent()->set_state(espbt::ClientState::CONNECTING);
|
this->parent()->set_state(espbt::ClientState::CONNECTING);
|
||||||
this->parent()->set_enabled(false);
|
this->parent()->set_enabled(false);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cinttypes>
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
@ -166,7 +167,7 @@ std::string ESPBTUUID::to_string() const {
|
||||||
case ESP_UUID_LEN_16:
|
case ESP_UUID_LEN_16:
|
||||||
return str_snprintf("0x%02X%02X", 6, this->uuid_.uuid.uuid16 >> 8, this->uuid_.uuid.uuid16 & 0xff);
|
return str_snprintf("0x%02X%02X", 6, this->uuid_.uuid.uuid16 >> 8, this->uuid_.uuid.uuid16 & 0xff);
|
||||||
case ESP_UUID_LEN_32:
|
case ESP_UUID_LEN_32:
|
||||||
return str_snprintf("0x%02X%02X%02X%02X", 10, this->uuid_.uuid.uuid32 >> 24,
|
return str_snprintf("0x%02" PRIX32 "%02" PRIX32 "%02" PRIX32 "%02" PRIX32, 10, (this->uuid_.uuid.uuid32 >> 24),
|
||||||
(this->uuid_.uuid.uuid32 >> 16 & 0xff), (this->uuid_.uuid.uuid32 >> 8 & 0xff),
|
(this->uuid_.uuid.uuid32 >> 16 & 0xff), (this->uuid_.uuid.uuid32 >> 8 & 0xff),
|
||||||
this->uuid_.uuid.uuid32 & 0xff);
|
this->uuid_.uuid.uuid32 & 0xff);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <freertos/FreeRTOSConfig.h>
|
#include <freertos/FreeRTOSConfig.h>
|
||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
#ifdef USE_OTA
|
#ifdef USE_OTA
|
||||||
#include "esphome/components/ota/ota_component.h"
|
#include "esphome/components/ota/ota_component.h"
|
||||||
|
@ -614,7 +615,7 @@ uint64_t ESPBTDevice::address_uint64() const { return esp32_ble::ble_addr_to_uin
|
||||||
|
|
||||||
void ESP32BLETracker::dump_config() {
|
void ESP32BLETracker::dump_config() {
|
||||||
ESP_LOGCONFIG(TAG, "BLE Tracker:");
|
ESP_LOGCONFIG(TAG, "BLE Tracker:");
|
||||||
ESP_LOGCONFIG(TAG, " Scan Duration: %u s", this->scan_duration_);
|
ESP_LOGCONFIG(TAG, " Scan Duration: %" PRIu32 " s", this->scan_duration_);
|
||||||
ESP_LOGCONFIG(TAG, " Scan Interval: %.1f ms", this->scan_interval_ * 0.625f);
|
ESP_LOGCONFIG(TAG, " Scan Interval: %.1f ms", this->scan_interval_ * 0.625f);
|
||||||
ESP_LOGCONFIG(TAG, " Scan Window: %.1f ms", this->scan_window_ * 0.625f);
|
ESP_LOGCONFIG(TAG, " Scan Window: %.1f ms", this->scan_window_ * 0.625f);
|
||||||
ESP_LOGCONFIG(TAG, " Scan Type: %s", this->scan_active_ ? "ACTIVE" : "PASSIVE");
|
ESP_LOGCONFIG(TAG, " Scan Type: %s", this->scan_active_ ? "ACTIVE" : "PASSIVE");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ina226.h"
|
#include "ina226.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ina226 {
|
namespace ina226 {
|
||||||
|
@ -68,7 +69,7 @@ void INA226Component::setup() {
|
||||||
|
|
||||||
auto calibration = uint32_t(0.00512 / (lsb * this->shunt_resistance_ohm_ / 1000000.0f));
|
auto calibration = uint32_t(0.00512 / (lsb * this->shunt_resistance_ohm_ / 1000000.0f));
|
||||||
|
|
||||||
ESP_LOGV(TAG, " Using LSB=%u calibration=%u", lsb, calibration);
|
ESP_LOGV(TAG, " Using LSB=%" PRIu32 " calibration=%" PRIu32, lsb, calibration);
|
||||||
|
|
||||||
if (!this->write_byte_16(INA226_REGISTER_CALIBRATION, calibration)) {
|
if (!this->write_byte_16(INA226_REGISTER_CALIBRATION, calibration)) {
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace max31865 {
|
namespace max31865 {
|
||||||
|
@ -45,14 +46,15 @@ void MAX31865Sensor::update() {
|
||||||
config = this->read_register_(CONFIGURATION_REG);
|
config = this->read_register_(CONFIGURATION_REG);
|
||||||
fault_detect_time = micros() - start_time;
|
fault_detect_time = micros() - start_time;
|
||||||
if ((fault_detect_time >= 6000) && (config & 0b00001100)) {
|
if ((fault_detect_time >= 6000) && (config & 0b00001100)) {
|
||||||
ESP_LOGE(TAG, "Fault detection incomplete (0x%02X) after %uμs (datasheet spec is 600μs max)! Aborting read.",
|
ESP_LOGE(TAG,
|
||||||
|
"Fault detection incomplete (0x%02X) after %" PRIu32 "μs (datasheet spec is 600μs max)! Aborting read.",
|
||||||
config, fault_detect_time);
|
config, fault_detect_time);
|
||||||
this->publish_state(NAN);
|
this->publish_state(NAN);
|
||||||
this->status_set_error();
|
this->status_set_error();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} while (config & 0b00001100);
|
} while (config & 0b00001100);
|
||||||
ESP_LOGV(TAG, "Fault detection completed in %uμs.", fault_detect_time);
|
ESP_LOGV(TAG, "Fault detection completed in %" PRIu32 "μs.", fault_detect_time);
|
||||||
|
|
||||||
// Start 1-shot conversion
|
// Start 1-shot conversion
|
||||||
this->write_config_(0b11100000, 0b10100000);
|
this->write_config_(0b11100000, 0b10100000);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "sen5x.h"
|
#include "sen5x.h"
|
||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace sen5x {
|
namespace sen5x {
|
||||||
|
@ -140,15 +141,15 @@ void SEN5XComponent::setup() {
|
||||||
this->pref_ = global_preferences->make_preference<Sen5xBaselines>(hash, true);
|
this->pref_ = global_preferences->make_preference<Sen5xBaselines>(hash, true);
|
||||||
|
|
||||||
if (this->pref_.load(&this->voc_baselines_storage_)) {
|
if (this->pref_.load(&this->voc_baselines_storage_)) {
|
||||||
ESP_LOGI(TAG, "Loaded VOC baseline state0: 0x%04X, state1: 0x%04X", this->voc_baselines_storage_.state0,
|
ESP_LOGI(TAG, "Loaded VOC baseline state0: 0x%04" PRIX32 ", state1: 0x%04" PRIX32,
|
||||||
voc_baselines_storage_.state1);
|
this->voc_baselines_storage_.state0, voc_baselines_storage_.state1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize storage timestamp
|
// Initialize storage timestamp
|
||||||
this->seconds_since_last_store_ = 0;
|
this->seconds_since_last_store_ = 0;
|
||||||
|
|
||||||
if (this->voc_baselines_storage_.state0 > 0 && this->voc_baselines_storage_.state1 > 0) {
|
if (this->voc_baselines_storage_.state0 > 0 && this->voc_baselines_storage_.state1 > 0) {
|
||||||
ESP_LOGI(TAG, "Setting VOC baseline from save state0: 0x%04X, state1: 0x%04X",
|
ESP_LOGI(TAG, "Setting VOC baseline from save state0: 0x%04" PRIX32 ", state1: 0x%04" PRIX32,
|
||||||
this->voc_baselines_storage_.state0, voc_baselines_storage_.state1);
|
this->voc_baselines_storage_.state0, voc_baselines_storage_.state1);
|
||||||
uint16_t states[4];
|
uint16_t states[4];
|
||||||
|
|
||||||
|
@ -252,7 +253,7 @@ void SEN5XComponent::dump_config() {
|
||||||
ESP_LOGCONFIG(TAG, " Firmware version: %d", this->firmware_version_);
|
ESP_LOGCONFIG(TAG, " Firmware version: %d", this->firmware_version_);
|
||||||
ESP_LOGCONFIG(TAG, " Serial number %02d.%02d.%02d", serial_number_[0], serial_number_[1], serial_number_[2]);
|
ESP_LOGCONFIG(TAG, " Serial number %02d.%02d.%02d", serial_number_[0], serial_number_[1], serial_number_[2]);
|
||||||
if (this->auto_cleaning_interval_.has_value()) {
|
if (this->auto_cleaning_interval_.has_value()) {
|
||||||
ESP_LOGCONFIG(TAG, " Auto cleaning interval %d seconds", auto_cleaning_interval_.value());
|
ESP_LOGCONFIG(TAG, " Auto cleaning interval %" PRId32 " seconds", auto_cleaning_interval_.value());
|
||||||
}
|
}
|
||||||
if (this->acceleration_mode_.has_value()) {
|
if (this->acceleration_mode_.has_value()) {
|
||||||
switch (this->acceleration_mode_.value()) {
|
switch (this->acceleration_mode_.value()) {
|
||||||
|
@ -302,8 +303,8 @@ void SEN5XComponent::update() {
|
||||||
this->voc_baselines_storage_.state1 = state1;
|
this->voc_baselines_storage_.state1 = state1;
|
||||||
|
|
||||||
if (this->pref_.save(&this->voc_baselines_storage_)) {
|
if (this->pref_.save(&this->voc_baselines_storage_)) {
|
||||||
ESP_LOGI(TAG, "Stored VOC baseline state0: 0x%04X ,state1: 0x%04X", this->voc_baselines_storage_.state0,
|
ESP_LOGI(TAG, "Stored VOC baseline state0: 0x%04" PRIX32 " ,state1: 0x%04" PRIX32,
|
||||||
voc_baselines_storage_.state1);
|
this->voc_baselines_storage_.state0, voc_baselines_storage_.state1);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(TAG, "Could not store VOC baselines");
|
ESP_LOGW(TAG, "Could not store VOC baselines");
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/core/application.h"
|
#include "esphome/core/application.h"
|
||||||
#include "esphome/core/defines.h"
|
#include "esphome/core/defines.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace uart {
|
namespace uart {
|
||||||
|
@ -12,8 +13,8 @@ static const char *const TAG = "uart";
|
||||||
void UARTDevice::check_uart_settings(uint32_t baud_rate, uint8_t stop_bits, UARTParityOptions parity,
|
void UARTDevice::check_uart_settings(uint32_t baud_rate, uint8_t stop_bits, UARTParityOptions parity,
|
||||||
uint8_t data_bits) {
|
uint8_t data_bits) {
|
||||||
if (this->parent_->get_baud_rate() != baud_rate) {
|
if (this->parent_->get_baud_rate() != baud_rate) {
|
||||||
ESP_LOGE(TAG, " Invalid baud_rate: Integration requested baud_rate %u but you have %u!", baud_rate,
|
ESP_LOGE(TAG, " Invalid baud_rate: Integration requested baud_rate %" PRIu32 " but you have %" PRIu32 "!",
|
||||||
this->parent_->get_baud_rate());
|
baud_rate, this->parent_->get_baud_rate());
|
||||||
}
|
}
|
||||||
if (this->parent_->get_stop_bits() != stop_bits) {
|
if (this->parent_->get_stop_bits() != stop_bits) {
|
||||||
ESP_LOGE(TAG, " Invalid stop bits: Integration requested stop_bits %u but you have %u!", stop_bits,
|
ESP_LOGE(TAG, " Invalid stop bits: Integration requested stop_bits %u but you have %u!", stop_bits,
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "esphome/core/defines.h"
|
#include "esphome/core/defines.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
#ifdef USE_LOGGER
|
#ifdef USE_LOGGER
|
||||||
#include "esphome/components/logger/logger.h"
|
#include "esphome/components/logger/logger.h"
|
||||||
|
@ -125,7 +126,7 @@ void IDFUARTComponent::dump_config() {
|
||||||
if (this->rx_pin_ != nullptr) {
|
if (this->rx_pin_ != nullptr) {
|
||||||
ESP_LOGCONFIG(TAG, " RX Buffer Size: %u", this->rx_buffer_size_);
|
ESP_LOGCONFIG(TAG, " RX Buffer Size: %u", this->rx_buffer_size_);
|
||||||
}
|
}
|
||||||
ESP_LOGCONFIG(TAG, " Baud Rate: %u baud", this->baud_rate_);
|
ESP_LOGCONFIG(TAG, " Baud Rate: %" PRIu32 " baud", this->baud_rate_);
|
||||||
ESP_LOGCONFIG(TAG, " Data Bits: %u", this->data_bits_);
|
ESP_LOGCONFIG(TAG, " Data Bits: %u", this->data_bits_);
|
||||||
ESP_LOGCONFIG(TAG, " Parity: %s", LOG_STR_ARG(parity_to_str(this->parity_)));
|
ESP_LOGCONFIG(TAG, " Parity: %s", LOG_STR_ARG(parity_to_str(this->parity_)));
|
||||||
ESP_LOGCONFIG(TAG, " Stop bits: %u", this->stop_bits_);
|
ESP_LOGCONFIG(TAG, " Stop bits: %u", this->stop_bits_);
|
||||||
|
@ -150,7 +151,7 @@ bool IDFUARTComponent::peek_byte(uint8_t *data) {
|
||||||
if (this->has_peek_) {
|
if (this->has_peek_) {
|
||||||
*data = this->peek_byte_;
|
*data = this->peek_byte_;
|
||||||
} else {
|
} else {
|
||||||
int len = uart_read_bytes(this->uart_num_, data, 1, 20 / portTICK_RATE_MS);
|
int len = uart_read_bytes(this->uart_num_, data, 1, 20 / portTICK_PERIOD_MS);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
*data = 0;
|
*data = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -174,7 +175,7 @@ bool IDFUARTComponent::read_array(uint8_t *data, size_t len) {
|
||||||
this->has_peek_ = false;
|
this->has_peek_ = false;
|
||||||
}
|
}
|
||||||
if (length_to_read > 0)
|
if (length_to_read > 0)
|
||||||
uart_read_bytes(this->uart_num_, data, length_to_read, 20 / portTICK_RATE_MS);
|
uart_read_bytes(this->uart_num_, data, length_to_read, 20 / portTICK_PERIOD_MS);
|
||||||
xSemaphoreGive(this->lock_);
|
xSemaphoreGive(this->lock_);
|
||||||
#ifdef USE_UART_DEBUGGER
|
#ifdef USE_UART_DEBUGGER
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "esphome/core/application.h"
|
#include "esphome/core/application.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace waveshare_epaper {
|
namespace waveshare_epaper {
|
||||||
|
@ -250,7 +251,7 @@ void WaveshareEPaperTypeA::dump_config() {
|
||||||
ESP_LOGCONFIG(TAG, " Model: 2.9inV2");
|
ESP_LOGCONFIG(TAG, " Model: 2.9inV2");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ESP_LOGCONFIG(TAG, " Full Update Every: %u", this->full_update_every_);
|
ESP_LOGCONFIG(TAG, " Full Update Every: %" PRIu32, this->full_update_every_);
|
||||||
LOG_PIN(" Reset Pin: ", this->reset_pin_);
|
LOG_PIN(" Reset Pin: ", this->reset_pin_);
|
||||||
LOG_PIN(" DC Pin: ", this->dc_pin_);
|
LOG_PIN(" DC Pin: ", this->dc_pin_);
|
||||||
LOG_PIN(" Busy Pin: ", this->busy_pin_);
|
LOG_PIN(" Busy Pin: ", this->busy_pin_);
|
||||||
|
|
Loading…
Reference in a new issue