mirror of
https://github.com/esphome/esphome.git
synced 2025-04-08 03:40:28 +01:00
Merge remote-tracking branch 'origin/dev' into nrf52
This commit is contained in:
commit
c128822381
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@ -132,10 +132,16 @@ jobs:
|
||||
suffix: lint
|
||||
version: ${{ needs.init.outputs.tag }}
|
||||
|
||||
- name: Sanitize platform name
|
||||
id: sanitize
|
||||
run: |
|
||||
echo "${{ matrix.platform }}" | sed 's|/|-|g' > /tmp/platform
|
||||
echo name=$(cat /tmp/platform) >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Upload digests
|
||||
uses: actions/upload-artifact@v4.3.3
|
||||
with:
|
||||
name: digests-${{ matrix.platform }}
|
||||
name: digests-${{ steps.sanitize.outputs.name }}
|
||||
path: /tmp/digests
|
||||
retention-days: 1
|
||||
|
||||
|
@ -6,16 +6,6 @@
|
||||
|
||||
#ifdef USE_ESP32
|
||||
|
||||
#ifdef USE_ARDUINO
|
||||
#include "mbedtls/aes.h"
|
||||
#include "mbedtls/base64.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_ESP_IDF
|
||||
#define MBEDTLS_AES_ALT
|
||||
#include <aes_alt.h>
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
namespace ble_presence {
|
||||
|
||||
@ -72,7 +62,7 @@ class BLEPresenceDevice : public binary_sensor::BinarySensorInitiallyOff,
|
||||
}
|
||||
break;
|
||||
case MATCH_BY_IRK:
|
||||
if (resolve_irk_(device.address_uint64(), this->irk_)) {
|
||||
if (device.resolve_irk(this->irk_)) {
|
||||
this->set_found_(true);
|
||||
return true;
|
||||
}
|
||||
@ -142,43 +132,6 @@ class BLEPresenceDevice : public binary_sensor::BinarySensorInitiallyOff,
|
||||
bool check_ibeacon_minor_{false};
|
||||
bool check_minimum_rssi_{false};
|
||||
|
||||
bool resolve_irk_(uint64_t addr64, const uint8_t *irk) {
|
||||
uint8_t ecb_key[16];
|
||||
uint8_t ecb_plaintext[16];
|
||||
uint8_t ecb_ciphertext[16];
|
||||
|
||||
memcpy(&ecb_key, irk, 16);
|
||||
memset(&ecb_plaintext, 0, 16);
|
||||
|
||||
ecb_plaintext[13] = (addr64 >> 40) & 0xff;
|
||||
ecb_plaintext[14] = (addr64 >> 32) & 0xff;
|
||||
ecb_plaintext[15] = (addr64 >> 24) & 0xff;
|
||||
|
||||
mbedtls_aes_context ctx = {0, 0, {0}};
|
||||
mbedtls_aes_init(&ctx);
|
||||
|
||||
if (mbedtls_aes_setkey_enc(&ctx, ecb_key, 128) != 0) {
|
||||
mbedtls_aes_free(&ctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mbedtls_aes_crypt_ecb(&ctx,
|
||||
#ifdef USE_ARDUINO
|
||||
MBEDTLS_AES_ENCRYPT,
|
||||
#elif defined(USE_ESP_IDF)
|
||||
ESP_AES_ENCRYPT,
|
||||
#endif
|
||||
ecb_plaintext, ecb_ciphertext) != 0) {
|
||||
mbedtls_aes_free(&ctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
mbedtls_aes_free(&ctx);
|
||||
|
||||
return ecb_ciphertext[15] == (addr64 & 0xff) && ecb_ciphertext[14] == ((addr64 >> 8) & 0xff) &&
|
||||
ecb_ciphertext[13] == ((addr64 >> 16) & 0xff);
|
||||
}
|
||||
|
||||
bool found_{false};
|
||||
uint32_t last_seen_{};
|
||||
uint32_t timeout_{};
|
||||
|
@ -15,6 +15,10 @@ class BLERSSISensor : public sensor::Sensor, public esp32_ble_tracker::ESPBTDevi
|
||||
this->match_by_ = MATCH_BY_MAC_ADDRESS;
|
||||
this->address_ = address;
|
||||
}
|
||||
void set_irk(uint8_t *irk) {
|
||||
this->match_by_ = MATCH_BY_IRK;
|
||||
this->irk_ = irk;
|
||||
}
|
||||
void set_service_uuid16(uint16_t uuid) {
|
||||
this->match_by_ = MATCH_BY_SERVICE_UUID;
|
||||
this->uuid_ = esp32_ble_tracker::ESPBTUUID::from_uint16(uuid);
|
||||
@ -53,6 +57,13 @@ class BLERSSISensor : public sensor::Sensor, public esp32_ble_tracker::ESPBTDevi
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case MATCH_BY_IRK:
|
||||
if (device.resolve_irk(this->irk_)) {
|
||||
this->publish_state(device.get_rssi());
|
||||
this->found_ = true;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case MATCH_BY_SERVICE_UUID:
|
||||
for (auto uuid : device.get_service_uuids()) {
|
||||
if (this->uuid_ == uuid) {
|
||||
@ -91,12 +102,13 @@ class BLERSSISensor : public sensor::Sensor, public esp32_ble_tracker::ESPBTDevi
|
||||
float get_setup_priority() const override { return setup_priority::DATA; }
|
||||
|
||||
protected:
|
||||
enum MatchType { MATCH_BY_MAC_ADDRESS, MATCH_BY_SERVICE_UUID, MATCH_BY_IBEACON_UUID };
|
||||
enum MatchType { MATCH_BY_MAC_ADDRESS, MATCH_BY_IRK, MATCH_BY_SERVICE_UUID, MATCH_BY_IBEACON_UUID };
|
||||
MatchType match_by_;
|
||||
|
||||
bool found_{false};
|
||||
|
||||
uint64_t address_;
|
||||
uint8_t *irk_;
|
||||
|
||||
esp32_ble_tracker::ESPBTUUID uuid_;
|
||||
|
||||
|
@ -12,6 +12,8 @@ from esphome.const import (
|
||||
UNIT_DECIBEL_MILLIWATT,
|
||||
)
|
||||
|
||||
CONF_IRK = "irk"
|
||||
|
||||
DEPENDENCIES = ["esp32_ble_tracker"]
|
||||
|
||||
ble_rssi_ns = cg.esphome_ns.namespace("ble_rssi")
|
||||
@ -39,6 +41,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
.extend(
|
||||
{
|
||||
cv.Optional(CONF_MAC_ADDRESS): cv.mac_address,
|
||||
cv.Optional(CONF_IRK): cv.uuid,
|
||||
cv.Optional(CONF_SERVICE_UUID): esp32_ble_tracker.bt_uuid,
|
||||
cv.Optional(CONF_IBEACON_MAJOR): cv.uint16_t,
|
||||
cv.Optional(CONF_IBEACON_MINOR): cv.uint16_t,
|
||||
@ -47,7 +50,9 @@ CONFIG_SCHEMA = cv.All(
|
||||
)
|
||||
.extend(esp32_ble_tracker.ESP_BLE_DEVICE_SCHEMA)
|
||||
.extend(cv.COMPONENT_SCHEMA),
|
||||
cv.has_exactly_one_key(CONF_MAC_ADDRESS, CONF_SERVICE_UUID, CONF_IBEACON_UUID),
|
||||
cv.has_exactly_one_key(
|
||||
CONF_MAC_ADDRESS, CONF_IRK, CONF_SERVICE_UUID, CONF_IBEACON_UUID
|
||||
),
|
||||
_validate,
|
||||
)
|
||||
|
||||
@ -60,6 +65,10 @@ async def to_code(config):
|
||||
if mac_address := config.get(CONF_MAC_ADDRESS):
|
||||
cg.add(var.set_address(mac_address.as_hex))
|
||||
|
||||
if irk := config.get(CONF_IRK):
|
||||
irk = esp32_ble_tracker.as_hex_array(str(irk))
|
||||
cg.add(var.set_irk(irk))
|
||||
|
||||
if service_uuid := config.get(CONF_SERVICE_UUID):
|
||||
if len(service_uuid) == len(esp32_ble_tracker.bt_uuid16_format):
|
||||
cg.add(var.set_service_uuid16(esp32_ble_tracker.as_hex(service_uuid)))
|
||||
|
@ -14,15 +14,41 @@ CONF_HEX = "hex"
|
||||
|
||||
|
||||
def hex_color(value):
|
||||
if isinstance(value, int):
|
||||
value = str(value)
|
||||
if not isinstance(value, str):
|
||||
raise cv.Invalid("Invalid value for hex color")
|
||||
if len(value) != 6:
|
||||
raise cv.Invalid("Color must have six digits")
|
||||
raise cv.Invalid("Hex color must have six digits")
|
||||
try:
|
||||
return (int(value[0:2], 16), int(value[2:4], 16), int(value[4:6], 16))
|
||||
return int(value[0:2], 16), int(value[2:4], 16), int(value[4:6], 16)
|
||||
except ValueError as exc:
|
||||
raise cv.Invalid("Color must be hexadecimal") from exc
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.Any(
|
||||
components = {
|
||||
CONF_RED,
|
||||
CONF_RED_INT,
|
||||
CONF_GREEN,
|
||||
CONF_GREEN_INT,
|
||||
CONF_BLUE,
|
||||
CONF_BLUE_INT,
|
||||
CONF_WHITE,
|
||||
CONF_WHITE_INT,
|
||||
}
|
||||
|
||||
|
||||
def validate_color(config):
|
||||
has_components = set(config) & components
|
||||
has_hex = CONF_HEX in config
|
||||
if has_hex and has_components:
|
||||
raise cv.Invalid("Hex color value may not be combined with component values")
|
||||
if not has_hex and not has_components:
|
||||
raise cv.Invalid("Must provide at least one color option")
|
||||
return config
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.declare_id(ColorStruct),
|
||||
@ -34,14 +60,10 @@ CONFIG_SCHEMA = cv.Any(
|
||||
cv.Exclusive(CONF_BLUE_INT, "blue"): cv.uint8_t,
|
||||
cv.Exclusive(CONF_WHITE, "white"): cv.percentage,
|
||||
cv.Exclusive(CONF_WHITE_INT, "white"): cv.uint8_t,
|
||||
cv.Optional(CONF_HEX): hex_color,
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA),
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.declare_id(ColorStruct),
|
||||
cv.Required(CONF_HEX): hex_color,
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA),
|
||||
validate_color,
|
||||
)
|
||||
|
||||
|
||||
|
@ -227,7 +227,7 @@ ARDUINO_PLATFORM_VERSION = cv.Version(5, 4, 0)
|
||||
# The default/recommended esp-idf framework version
|
||||
# - https://github.com/espressif/esp-idf/releases
|
||||
# - https://api.registry.platformio.org/v3/packages/platformio/tool/framework-espidf
|
||||
RECOMMENDED_ESP_IDF_FRAMEWORK_VERSION = cv.Version(4, 4, 6)
|
||||
RECOMMENDED_ESP_IDF_FRAMEWORK_VERSION = cv.Version(4, 4, 7)
|
||||
# The platformio/espressif32 version to use for esp-idf frameworks
|
||||
# - https://github.com/platformio/platform-espressif32/releases
|
||||
# - https://api.registry.platformio.org/v3/packages/platformio/platform/espressif32
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include <esp32-hal-bt.h>
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_AES_ALT
|
||||
#include <aes_alt.h>
|
||||
|
||||
// bt_trace.h
|
||||
#undef TAG
|
||||
|
||||
@ -693,6 +696,39 @@ void ESP32BLETracker::print_bt_device_info(const ESPBTDevice &device) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ESPBTDevice::resolve_irk(const uint8_t *irk) const {
|
||||
uint8_t ecb_key[16];
|
||||
uint8_t ecb_plaintext[16];
|
||||
uint8_t ecb_ciphertext[16];
|
||||
|
||||
uint64_t addr64 = esp32_ble::ble_addr_to_uint64(this->address_);
|
||||
|
||||
memcpy(&ecb_key, irk, 16);
|
||||
memset(&ecb_plaintext, 0, 16);
|
||||
|
||||
ecb_plaintext[13] = (addr64 >> 40) & 0xff;
|
||||
ecb_plaintext[14] = (addr64 >> 32) & 0xff;
|
||||
ecb_plaintext[15] = (addr64 >> 24) & 0xff;
|
||||
|
||||
mbedtls_aes_context ctx = {0, 0, {0}};
|
||||
mbedtls_aes_init(&ctx);
|
||||
|
||||
if (mbedtls_aes_setkey_enc(&ctx, ecb_key, 128) != 0) {
|
||||
mbedtls_aes_free(&ctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mbedtls_aes_crypt_ecb(&ctx, ESP_AES_ENCRYPT, ecb_plaintext, ecb_ciphertext) != 0) {
|
||||
mbedtls_aes_free(&ctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
mbedtls_aes_free(&ctx);
|
||||
|
||||
return ecb_ciphertext[15] == (addr64 & 0xff) && ecb_ciphertext[14] == ((addr64 >> 8) & 0xff) &&
|
||||
ecb_ciphertext[13] == ((addr64 >> 16) & 0xff);
|
||||
}
|
||||
|
||||
} // namespace esp32_ble_tracker
|
||||
} // namespace esphome
|
||||
|
||||
|
@ -86,6 +86,8 @@ class ESPBTDevice {
|
||||
|
||||
const esp_ble_gap_cb_param_t::ble_scan_result_evt_param &get_scan_result() const { return scan_result_; }
|
||||
|
||||
bool resolve_irk(const uint8_t *irk) const;
|
||||
|
||||
optional<ESPBLEiBeacon> get_ibeacon() const {
|
||||
for (auto &it : this->manufacturer_datas_) {
|
||||
auto res = ESPBLEiBeacon::from_manufacturer_data(it);
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "ethernet_component.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/util.h"
|
||||
#include "esphome/core/application.h"
|
||||
|
||||
#ifdef USE_ESP32
|
||||
|
||||
#include <cinttypes>
|
||||
#include <lwip/dns.h>
|
||||
#include <cinttypes>
|
||||
#include "esp_event.h"
|
||||
|
||||
#ifdef USE_ETHERNET_SPI
|
||||
@ -184,6 +184,10 @@ void EthernetComponent::setup() {
|
||||
// KSZ8081RNA default is incorrect. It expects a 25MHz clock instead of the 50MHz we provide.
|
||||
this->ksz8081_set_clock_reference_(mac);
|
||||
}
|
||||
if (this->type_ == ETHERNET_TYPE_RTL8201 && this->clk_mode_ == EMAC_CLK_EXT_IN) {
|
||||
// Change in default behavior of RTL8201FI may require register setting to enable external clock
|
||||
this->rtl8201_set_rmii_mode_(mac);
|
||||
}
|
||||
#endif
|
||||
|
||||
// use ESP internal eth mac
|
||||
@ -554,9 +558,10 @@ bool EthernetComponent::powerdown() {
|
||||
}
|
||||
|
||||
#ifndef USE_ETHERNET_SPI
|
||||
void EthernetComponent::ksz8081_set_clock_reference_(esp_eth_mac_t *mac) {
|
||||
#define KSZ80XX_PC2R_REG_ADDR (0x1F)
|
||||
|
||||
constexpr uint8_t KSZ80XX_PC2R_REG_ADDR = 0x1F;
|
||||
|
||||
void EthernetComponent::ksz8081_set_clock_reference_(esp_eth_mac_t *mac) {
|
||||
esp_err_t err;
|
||||
|
||||
uint32_t phy_control_2;
|
||||
@ -581,9 +586,47 @@ void EthernetComponent::ksz8081_set_clock_reference_(esp_eth_mac_t *mac) {
|
||||
ESPHL_ERROR_CHECK(err, "Read PHY Control 2 failed");
|
||||
ESP_LOGVV(TAG, "KSZ8081 PHY Control 2: %s", format_hex_pretty((u_int8_t *) &phy_control_2, 2).c_str());
|
||||
}
|
||||
|
||||
#undef KSZ80XX_PC2R_REG_ADDR
|
||||
}
|
||||
constexpr uint8_t RTL8201_RMSR_REG_ADDR = 0x10;
|
||||
void EthernetComponent::rtl8201_set_rmii_mode_(esp_eth_mac_t *mac) {
|
||||
esp_err_t err;
|
||||
uint32_t phy_rmii_mode;
|
||||
err = mac->write_phy_reg(mac, this->phy_addr_, 0x1f, 0x07);
|
||||
ESPHL_ERROR_CHECK(err, "Setting Page 7 failed");
|
||||
|
||||
/*
|
||||
* RTL8201 RMII Mode Setting Register (RMSR)
|
||||
* Page 7 Register 16
|
||||
*
|
||||
* bit 0 Reserved 0
|
||||
* bit 1 Rg_rmii_rxdsel 1 (default)
|
||||
* bit 2 Rg_rmii_rxdv_sel: 0 (default)
|
||||
* bit 3 RMII Mode: 1 (RMII Mode)
|
||||
* bit 4~7 Rg_rmii_rx_offset: 1111 (default)
|
||||
* bit 8~11 Rg_rmii_tx_offset: 1111 (default)
|
||||
* bit 12 Rg_rmii_clkdir: 1 (Input)
|
||||
* bit 13~15 Reserved 000
|
||||
*
|
||||
* Binary: 0001 1111 1111 1010
|
||||
* Hex: 0x1FFA
|
||||
*
|
||||
*/
|
||||
|
||||
err = mac->read_phy_reg(mac, this->phy_addr_, RTL8201_RMSR_REG_ADDR, &(phy_rmii_mode));
|
||||
ESPHL_ERROR_CHECK(err, "Read PHY RMSR Register failed");
|
||||
ESP_LOGV(TAG, "Hardware default RTL8201 RMII Mode Register is: 0x%04X", phy_rmii_mode);
|
||||
|
||||
err = mac->write_phy_reg(mac, this->phy_addr_, RTL8201_RMSR_REG_ADDR, 0x1FFA);
|
||||
ESPHL_ERROR_CHECK(err, "Setting Register 16 RMII Mode Setting failed");
|
||||
|
||||
err = mac->read_phy_reg(mac, this->phy_addr_, RTL8201_RMSR_REG_ADDR, &(phy_rmii_mode));
|
||||
ESPHL_ERROR_CHECK(err, "Read PHY RMSR Register failed");
|
||||
ESP_LOGV(TAG, "Setting RTL8201 RMII Mode Register to: 0x%04X", phy_rmii_mode);
|
||||
|
||||
err = mac->write_phy_reg(mac, this->phy_addr_, 0x1f, 0x0);
|
||||
ESPHL_ERROR_CHECK(err, "Setting Page 0 failed");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace ethernet
|
||||
|
@ -86,6 +86,8 @@ class EthernetComponent : public Component {
|
||||
void dump_connect_params_();
|
||||
/// @brief Set `RMII Reference Clock Select` bit for KSZ8081.
|
||||
void ksz8081_set_clock_reference_(esp_eth_mac_t *mac);
|
||||
/// @brief Set `RMII Mode Setting Register` for RTL8201.
|
||||
void rtl8201_set_rmii_mode_(esp_eth_mac_t *mac);
|
||||
|
||||
std::string use_address_;
|
||||
#ifdef USE_ETHERNET_SPI
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "esphome/components/display/display_color_utils.h"
|
||||
|
||||
#ifdef USE_NEXTION_TFT_UPLOAD
|
||||
#ifdef ARDUINO
|
||||
#ifdef USE_ARDUINO
|
||||
#ifdef USE_ESP32
|
||||
#include <HTTPClient.h>
|
||||
#endif // USE_ESP32
|
||||
@ -22,7 +22,7 @@
|
||||
#endif // USE_ESP8266
|
||||
#elif defined(USE_ESP_IDF)
|
||||
#include <esp_http_client.h>
|
||||
#endif // ARDUINO vs ESP-IDF
|
||||
#endif // ARDUINO vs USE_ESP_IDF
|
||||
#endif // USE_NEXTION_TFT_UPLOAD
|
||||
|
||||
namespace esphome {
|
||||
@ -987,7 +987,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
|
||||
#ifdef USE_NEXTION_TFT_UPLOAD
|
||||
/**
|
||||
* Set the tft file URL. https seems problematic with arduino..
|
||||
* Set the tft file URL. https seems problematic with Arduino..
|
||||
*/
|
||||
void set_tft_url(const std::string &tft_url) { this->tft_url_ = tft_url; }
|
||||
|
||||
@ -1190,7 +1190,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
uint32_t original_baud_rate_ = 0;
|
||||
bool upload_first_chunk_sent_ = false;
|
||||
|
||||
#ifdef ARDUINO
|
||||
#ifdef USE_ARDUINO
|
||||
/**
|
||||
* will request chunk_size chunks from the web server
|
||||
* and send each to the nextion
|
||||
@ -1208,7 +1208,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
* @return position of last byte transferred, -1 for failure.
|
||||
*/
|
||||
int upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &range_start);
|
||||
#endif // ARDUINO vs USE_ESP_IDF
|
||||
#endif // USE_ARDUINO vs USE_ESP_IDF
|
||||
|
||||
/**
|
||||
* Ends the upload process, restart Nextion and, if successful,
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "nextion.h"
|
||||
|
||||
#ifdef USE_NEXTION_TFT_UPLOAD
|
||||
#ifdef ARDUINO
|
||||
#ifdef USE_ARDUINO
|
||||
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/defines.h"
|
||||
@ -383,5 +383,5 @@ WiFiClient *Nextion::get_wifi_client_() {
|
||||
} // namespace nextion
|
||||
} // namespace esphome
|
||||
|
||||
#endif // ARDUINO
|
||||
#endif // USE_ARDUINO
|
||||
#endif // USE_NEXTION_TFT_UPLOAD
|
||||
|
@ -58,6 +58,7 @@ class RemoteReceiverComponent : public remote_base::RemoteReceiverBase,
|
||||
void decode_rmt_(rmt_item32_t *item, size_t len);
|
||||
RingbufHandle_t ringbuf_;
|
||||
esp_err_t error_code_{ESP_OK};
|
||||
std::string error_string_{""};
|
||||
#endif
|
||||
|
||||
#if defined(USE_ESP8266) || defined(USE_LIBRETINY)
|
||||
|
@ -29,6 +29,7 @@ void RemoteReceiverComponent::setup() {
|
||||
esp_err_t error = rmt_config(&rmt);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
this->error_string_ = "in rmt_config";
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
@ -36,18 +37,25 @@ void RemoteReceiverComponent::setup() {
|
||||
error = rmt_driver_install(this->channel_, this->buffer_size_, 0);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
if (error == ESP_ERR_INVALID_STATE) {
|
||||
this->error_string_ = str_sprintf("RMT channel %i is already in use by another component", this->channel_);
|
||||
} else {
|
||||
this->error_string_ = "in rmt_driver_install";
|
||||
}
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
error = rmt_get_ringbuf_handle(this->channel_, &this->ringbuf_);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
this->error_string_ = "in rmt_get_ringbuf_handle";
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
error = rmt_rx_start(this->channel_, true);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
this->error_string_ = "in rmt_rx_start";
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
@ -67,7 +75,8 @@ void RemoteReceiverComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, " Filter out pulses shorter than: %" PRIu32 " us", this->filter_us_);
|
||||
ESP_LOGCONFIG(TAG, " Signal is done after %" PRIu32 " us of no changes", this->idle_us_);
|
||||
if (this->is_failed()) {
|
||||
ESP_LOGE(TAG, "Configuring RMT driver failed: %s", esp_err_to_name(this->error_code_));
|
||||
ESP_LOGE(TAG, "Configuring RMT driver failed: %s (%s)", esp_err_to_name(this->error_code_),
|
||||
this->error_string_.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase,
|
||||
bool initialized_{false};
|
||||
std::vector<rmt_item32_t> rmt_temp_;
|
||||
esp_err_t error_code_{ESP_OK};
|
||||
std::string error_string_{""};
|
||||
bool inverted_{false};
|
||||
#endif
|
||||
uint8_t carrier_duty_percent_;
|
||||
|
@ -23,7 +23,8 @@ void RemoteTransmitterComponent::dump_config() {
|
||||
}
|
||||
|
||||
if (this->is_failed()) {
|
||||
ESP_LOGE(TAG, "Configuring RMT driver failed: %s", esp_err_to_name(this->error_code_));
|
||||
ESP_LOGE(TAG, "Configuring RMT driver failed: %s (%s)", esp_err_to_name(this->error_code_),
|
||||
this->error_string_.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,6 +57,7 @@ void RemoteTransmitterComponent::configure_rmt_() {
|
||||
esp_err_t error = rmt_config(&c);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
this->error_string_ = "in rmt_config";
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
@ -64,6 +66,11 @@ void RemoteTransmitterComponent::configure_rmt_() {
|
||||
error = rmt_driver_install(this->channel_, 0, 0);
|
||||
if (error != ESP_OK) {
|
||||
this->error_code_ = error;
|
||||
if (error == ESP_ERR_INVALID_STATE) {
|
||||
this->error_string_ = str_sprintf("RMT channel %i is already in use by another component", this->channel_);
|
||||
} else {
|
||||
this->error_string_ = "in rmt_driver_install";
|
||||
}
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
@ -341,6 +341,8 @@ class ID:
|
||||
|
||||
if self.id is None:
|
||||
base = str(self.type).replace("::", "_").lower()
|
||||
if base == self.type:
|
||||
base = base + "_id"
|
||||
name = "".join(c for c in base if c.isalnum() or c == "_")
|
||||
used = set(registered_ids) | set(RESERVED_IDS) | CORE.loaded_integrations
|
||||
self.id = ensure_unique_string(name, used)
|
||||
|
@ -137,7 +137,7 @@ extra_scripts = post:esphome/components/esp32/post_build.py.script
|
||||
extends = common:idf
|
||||
platform = platformio/espressif32@5.4.0
|
||||
platform_packages =
|
||||
platformio/framework-espidf@~3.40406.0
|
||||
platformio/framework-espidf@~3.40407.0
|
||||
|
||||
framework = espidf
|
||||
lib_deps =
|
||||
|
@ -16,3 +16,6 @@ sensor:
|
||||
- platform: ble_rssi
|
||||
service_uuid: 11223344-5566-7788-99aa-bbccddeeff00
|
||||
name: BLE Test iBeacon UUID
|
||||
- platform: ble_rssi
|
||||
irk: 1234567890abcdef1234567890abcdef
|
||||
name: "BLE Tracker with Identity Resolving Key"
|
||||
|
@ -9,3 +9,12 @@ color:
|
||||
blue: 100%
|
||||
- id: kbx_green
|
||||
hex: "3DEC55"
|
||||
- id: kbx_green_1
|
||||
hex: 3DEC55
|
||||
- id: cps_red
|
||||
hex: 800000
|
||||
- id: cps_green
|
||||
hex: 008000
|
||||
- id: cps_blue
|
||||
hex: 000080
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user