1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-13 14:20:29 +01:00

Merge branch 'dev' into bh1745

This commit is contained in:
Anton Viktorov 2024-06-19 10:01:12 +02:00 committed by GitHub
commit e4e0ba75a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1755 changed files with 421 additions and 495 deletions

View File

@ -46,7 +46,7 @@ runs:
- name: Build and push to ghcr by digest
id: build-ghcr
uses: docker/build-push-action@v5.4.0
uses: docker/build-push-action@v6.0.1
with:
context: .
file: ./docker/Dockerfile
@ -69,7 +69,7 @@ runs:
- name: Build and push to dockerhub by digest
id: build-dockerhub
uses: docker/build-push-action@v5.4.0
uses: docker/build-push-action@v6.0.1
with:
context: .
file: ./docker/Dockerfile

View File

@ -65,7 +65,7 @@ jobs:
pip3 install build
python3 -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.8.14
uses: pypa/gh-action-pypi-publish@v1.9.0
deploy-docker:
name: Build ESPHome ${{ matrix.platform }}

View File

@ -36,7 +36,7 @@ jobs:
python ./script/sync-device_class.py
- name: Commit changes
uses: peter-evans/create-pull-request@v6.0.5
uses: peter-evans/create-pull-request@v6.1.0
with:
commit-message: "Synchronise Device Classes from Home Assistant"
committer: esphomebot <esphome@nabucasa.com>

View File

@ -129,13 +129,13 @@ class Cover : public EntityBase, public EntityBase_DeviceClass {
*
* This is a legacy method and may be removed later, please use `.make_call()` instead.
*/
ESPDEPRECATED("open() is deprecated, use make_call().set_command_open() instead.", "2021.9")
ESPDEPRECATED("open() is deprecated, use make_call().set_command_open().perform() instead.", "2021.9")
void open();
/** Close the cover.
*
* This is a legacy method and may be removed later, please use `.make_call()` instead.
*/
ESPDEPRECATED("close() is deprecated, use make_call().set_command_close() instead.", "2021.9")
ESPDEPRECATED("close() is deprecated, use make_call().set_command_close().perform() instead.", "2021.9")
void close();
/** Stop the cover.
*

View File

@ -96,16 +96,16 @@ def get_board(core_obj=None):
def get_download_types(storage_json):
return [
{
"title": "Modern format",
"title": "Factory format (Previously Modern)",
"description": "For use with ESPHome Web and other tools.",
"file": "firmware-factory.bin",
"download": f"{storage_json.name}-factory.bin",
"file": "firmware.factory.bin",
"download": f"{storage_json.name}.factory.bin",
},
{
"title": "Legacy format",
"description": "For use with ESPHome Flasher.",
"file": "firmware.bin",
"download": f"{storage_json.name}.bin",
"title": "OTA format (Previously Legacy)",
"description": "For OTA updating a device.",
"file": "firmware.ota.bin",
"download": f"{storage_json.name}.ota.bin",
},
]

View File

@ -17,17 +17,19 @@ from SCons.Script import ARGUMENTS
# Copy over the default sdkconfig.
from os import path
if path.exists("./sdkconfig.defaults"):
os.makedirs(".temp", exist_ok=True)
shutil.copy("./sdkconfig.defaults", "./.temp/sdkconfig-esp32-idf")
def esp32_create_combined_bin(source, target, env):
verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0")))
if verbose:
print("Generating combined binary for serial flashing")
app_offset = 0x10000
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
sections = env.subst(env.get("FLASH_EXTRA_IMAGES"))
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
chip = env.get("BOARD_MCU")
@ -62,5 +64,14 @@ def esp32_create_combined_bin(source, target, env):
else:
subprocess.run(["esptool.py", *cmd])
def esp32_copy_ota_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
shutil.copyfile(firmware_name, new_file_name)
# pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_copy_ota_bin) # noqa

View File

@ -6,10 +6,18 @@ Import("env") # noqa
def esp8266_copy_factory_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
shutil.copyfile(firmware_name, new_file_name)
def esp8266_copy_ota_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
shutil.copyfile(firmware_name, new_file_name)
# pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_factory_bin) # noqa
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_ota_bin) # noqa

View File

@ -631,7 +631,7 @@ void EthernetComponent::write_phy_register_(esp_eth_mac_t *mac, PHYRegister regi
ESPHL_ERROR_CHECK(err, "Writing PHY Register failed");
if (this->type_ == ETHERNET_TYPE_RTL8201 && register_data.page) {
ESP_LOGD(TAG, "Select PHY Register Page 0x%02" PRIX32, 0x0);
ESP_LOGD(TAG, "Select PHY Register Page 0x00");
err = mac->write_phy_reg(mac, this->phy_addr_, eth_phy_psr_reg_addr, 0x0);
ESPHL_ERROR_CHECK(err, "Select PHY Register Page 0 failed");
}

View File

@ -60,7 +60,7 @@ void HOT IRAM_ATTR GPIOOneWireBus::write_bit_(bool bit) {
// recovery time: t_rec: min=1µs
// ds18b20 appears to read the bus after roughly 14µs
uint32_t delay0 = bit ? 6 : 60;
uint32_t delay1 = bit ? 54 : 5;
uint32_t delay1 = bit ? 59 : 5;
// delay A/C
delayMicroseconds(delay0);

View File

@ -34,8 +34,8 @@ void ILI9XXXDisplay::setup() {
ESP_LOGD(TAG, "Setting up ILI9xxx");
this->setup_pins_();
this->init_lcd_(this->init_sequence_);
this->init_lcd_(this->extra_init_sequence_.data());
this->init_lcd(this->init_sequence_);
this->init_lcd(this->extra_init_sequence_.data());
switch (this->pixel_mode_) {
case PIXEL_MODE_16:
if (this->is_18bitdisplay_) {
@ -405,7 +405,7 @@ void ILI9XXXDisplay::reset_() {
}
}
void ILI9XXXDisplay::init_lcd_(const uint8_t *addr) {
void ILI9XXXDisplay::init_lcd(const uint8_t *addr) {
if (addr == nullptr)
return;
uint8_t cmd, x, num_args;
@ -427,6 +427,20 @@ void ILI9XXXDisplay::init_lcd_(const uint8_t *addr) {
}
}
void ILI9XXXGC9A01A::init_lcd(const uint8_t *addr) {
if (addr == nullptr)
return;
uint8_t cmd, x, num_args;
while ((cmd = *addr++) != 0) {
x = *addr++;
num_args = x & 0x7F;
this->send_command(cmd, addr, num_args);
addr += num_args;
if (x & 0x80)
delay(150); // NOLINT
}
}
// Tell the display controller where we want to draw pixels.
void ILI9XXXDisplay::set_addr_window_(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
x1 += this->offset_x_;

View File

@ -109,7 +109,7 @@ class ILI9XXXDisplay : public display::DisplayBuffer,
virtual void set_madctl();
void display_();
void init_lcd_(const uint8_t *addr);
virtual void init_lcd(const uint8_t *addr);
void set_addr_window_(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2);
void reset_();
@ -269,6 +269,7 @@ class ILI9XXXS3BoxLite : public ILI9XXXDisplay {
class ILI9XXXGC9A01A : public ILI9XXXDisplay {
public:
ILI9XXXGC9A01A() : ILI9XXXDisplay(INITCMD_GC9A01A, 240, 240, true) {}
void init_lcd(const uint8_t *addr) override;
};
//----------- ILI9XXX_24_TFT display --------------

View File

@ -6,12 +6,12 @@
#include "mqtt_const.h"
#ifdef USE_MQTT
#ifdef USE_DATETIME_TIME
#ifdef USE_DATETIME_DATETIME
namespace esphome {
namespace mqtt {
static const char *const TAG = "mqtt.datetime.time";
static const char *const TAG = "mqtt.datetime.datetime";
using namespace esphome::datetime;
@ -80,5 +80,5 @@ bool MQTTDateTimeComponent::publish_state(uint16_t year, uint8_t month, uint8_t
} // namespace mqtt
} // namespace esphome
#endif // USE_DATETIME_TIME
#endif // USE_DATETIME_DATETIME
#endif // USE_MQTT

View File

@ -3,7 +3,7 @@
#include "esphome/core/defines.h"
#ifdef USE_MQTT
#ifdef USE_DATETIME_TIME
#ifdef USE_DATETIME_DATETIME
#include "esphome/components/datetime/datetime_entity.h"
#include "mqtt_component.h"
@ -17,7 +17,7 @@ class MQTTDateTimeComponent : public mqtt::MQTTComponent {
*
* @param time The time entity.
*/
explicit MQTTDateTimeComponent(datetime::DateTimeEntity *time);
explicit MQTTDateTimeComponent(datetime::DateTimeEntity *datetime);
// ========== INTERNAL METHODS ==========
// (In most use cases you won't need these)
@ -41,5 +41,5 @@ class MQTTDateTimeComponent : public mqtt::MQTTComponent {
} // namespace mqtt
} // namespace esphome
#endif // USE_DATETIME_DATE
#endif // USE_DATETIME_DATETIME
#endif // USE_MQTT

View File

@ -19,7 +19,12 @@ IPAddress = network_ns.class_("IPAddress")
CONFIG_SCHEMA = cv.Schema(
{
cv.SplitDefault(CONF_ENABLE_IPV6): cv.All(
cv.SplitDefault(
CONF_ENABLE_IPV6,
esp8266=False,
esp32=False,
rp2040=False,
): cv.All(
cv.boolean, cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040])
),
cv.Optional(CONF_MIN_IPV6_ADDR_COUNT, default=0): cv.positive_int,
@ -28,18 +33,17 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config):
if CONF_ENABLE_IPV6 in config:
cg.add_define("USE_NETWORK_IPV6", config[CONF_ENABLE_IPV6])
cg.add_define(
"USE_NETWORK_MIN_IPV6_ADDR_COUNT", config[CONF_MIN_IPV6_ADDR_COUNT]
)
if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", config[CONF_ENABLE_IPV6])
add_idf_sdkconfig_option(
"CONFIG_LWIP_IPV6_AUTOCONFIG", config[CONF_ENABLE_IPV6]
if (enable_ipv6 := config.get(CONF_ENABLE_IPV6, None)) is not None:
cg.add_define("USE_NETWORK_IPV6", enable_ipv6)
if enable_ipv6:
cg.add_define(
"USE_NETWORK_MIN_IPV6_ADDR_COUNT", config[CONF_MIN_IPV6_ADDR_COUNT]
)
if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6)
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6)
else:
if config[CONF_ENABLE_IPV6]:
if enable_ipv6:
cg.add_build_flag("-DCONFIG_LWIP_IPV6")
cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG")
if CORE.is_rp2040:

View File

@ -42,6 +42,14 @@ COLOR_ORDERS = {
}
DATA_PIN_SCHEMA = pins.internal_gpio_output_pin_schema
def validate_dimension(value):
value = cv.positive_int(value)
if value % 2 != 0:
raise cv.Invalid("Width/height/offset must be divisible by 2")
return value
CONFIG_SCHEMA = cv.All(
display.FULL_DISPLAY_SCHEMA.extend(
cv.Schema(
@ -52,10 +60,14 @@ CONFIG_SCHEMA = cv.All(
cv.dimensions,
cv.Schema(
{
cv.Required(CONF_WIDTH): cv.int_,
cv.Required(CONF_HEIGHT): cv.int_,
cv.Optional(CONF_OFFSET_HEIGHT, default=0): cv.int_,
cv.Optional(CONF_OFFSET_WIDTH, default=0): cv.int_,
cv.Required(CONF_WIDTH): validate_dimension,
cv.Required(CONF_HEIGHT): validate_dimension,
cv.Optional(
CONF_OFFSET_HEIGHT, default=0
): validate_dimension,
cv.Optional(
CONF_OFFSET_WIDTH, default=0
): validate_dimension,
}
),
),

View File

@ -26,6 +26,19 @@ void QspiAmoLed::setup() {
void QspiAmoLed::update() {
this->do_update_();
// Start addresses and widths/heights must be divisible by 2 (CASET/RASET restriction in datasheet)
if (this->x_low_ % 2 == 1) {
this->x_low_--;
}
if (this->x_high_ % 2 == 0) {
this->x_high_++;
}
if (this->y_low_ % 2 == 1) {
this->y_low_--;
}
if (this->y_high_ % 2 == 0) {
this->y_high_++;
}
int w = this->x_high_ - this->x_low_ + 1;
int h = this->y_high_ - this->y_low_ + 1;
this->draw_pixels_at(this->x_low_, this->y_low_, w, h, this->buffer_, this->color_mode_, display::COLOR_BITNESS_565,

View File

@ -47,10 +47,16 @@ def set_core_data(config):
def get_download_types(storage_json):
return [
{
"title": "UF2 format",
"title": "UF2 factory format",
"description": "For copying to RP2040 over USB.",
"file": "firmware.uf2",
"download": f"{storage_json.name}.uf2",
"download": f"{storage_json.name}.factory.uf2",
},
{
"title": "OTA format",
"description": "For OTA updating a device.",
"file": "firmware.ota.bin",
"download": f"{storage_json.name}.ota.bin",
},
]
@ -160,6 +166,8 @@ async def to_code(config):
cg.add_define("ESPHOME_BOARD", config[CONF_BOARD])
cg.add_define("ESPHOME_VARIANT", "RP2040")
cg.add_platformio_option("extra_scripts", ["post:post_build.py"])
conf = config[CONF_FRAMEWORK]
cg.add_platformio_option("framework", "arduino")
cg.add_build_flag("-DUSE_ARDUINO")
@ -225,4 +233,10 @@ def generate_pio_files() -> bool:
# Called by writer.py
def copy_files() -> bool:
dir = os.path.dirname(__file__)
post_build_file = os.path.join(dir, "post_build.py.script")
copy_file_if_changed(
post_build_file,
CORE.relative_build_path("post_build.py"),
)
return generate_pio_files()

View File

@ -0,0 +1,23 @@
import shutil
# pylint: disable=E0602
Import("env") # noqa
def rp2040_copy_factory_uf2(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.uf2")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.uf2")
shutil.copyfile(firmware_name, new_file_name)
def rp2040_copy_ota_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
shutil.copyfile(firmware_name, new_file_name)
# pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_factory_uf2) # noqa
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_ota_bin) # noqa

View File

@ -258,6 +258,7 @@ KEY_UART_DEVICES = "uart_devices"
def final_validate_device_schema(
name: str,
*,
uart_bus: str = CONF_UART_ID,
baud_rate: Optional[int] = None,
require_tx: bool = False,
require_rx: bool = False,
@ -268,7 +269,7 @@ def final_validate_device_schema(
def validate_baud_rate(value):
if value != baud_rate:
raise cv.Invalid(
f"Component {name} requires baud rate {baud_rate} for the uart bus"
f"Component {name} requires baud rate {baud_rate} for the uart referenced by {uart_bus}"
)
return value
@ -287,21 +288,21 @@ def final_validate_device_schema(
def validate_data_bits(value):
if value != data_bits:
raise cv.Invalid(
f"Component {name} requires {data_bits} data bits for the uart bus"
f"Component {name} requires {data_bits} data bits for the uart referenced by {uart_bus}"
)
return value
def validate_parity(value):
if value != parity:
raise cv.Invalid(
f"Component {name} requires parity {parity} for the uart bus"
f"Component {name} requires parity {parity} for the uart referenced by {uart_bus}"
)
return value
def validate_stop_bits(value):
if value != stop_bits:
raise cv.Invalid(
f"Component {name} requires {stop_bits} stop bits for the uart bus"
f"Component {name} requires {stop_bits} stop bits for the uart referenced by {uart_bus}"
)
return value
@ -316,14 +317,14 @@ def final_validate_device_schema(
hub_schema[
cv.Required(
CONF_TX_PIN,
msg=f"Component {name} requires this uart bus to declare a tx_pin",
msg=f"Component {name} requires uart referenced by {uart_bus} to declare a tx_pin",
)
] = validate_pin(CONF_TX_PIN, device)
if require_rx and uart_id_type_str in NATIVE_UART_CLASSES:
hub_schema[
cv.Required(
CONF_RX_PIN,
msg=f"Component {name} requires this uart bus to declare a rx_pin",
msg=f"Component {name} requires uart referenced by {uart_bus} to declare a rx_pin",
)
] = validate_pin(CONF_RX_PIN, device)
if baud_rate is not None:
@ -337,7 +338,7 @@ def final_validate_device_schema(
return cv.Schema(hub_schema, extra=cv.ALLOW_EXTRA)(hub_config)
return cv.Schema(
{cv.Required(CONF_UART_ID): fv.id_declaration_match_schema(validate_hub)},
{cv.Required(uart_bus): fv.id_declaration_match_schema(validate_hub)},
extra=cv.ALLOW_EXTRA,
)

View File

@ -243,7 +243,7 @@ ErrorCode VEML7700Component::configure_() {
}
PSMRegister psm{0};
psm.PSM = PSM::PSM_MODE_1;
psm.PSM = PSMMode::PSM_MODE_1;
psm.PSM_EN = false;
ESP_LOGV(TAG, "Setting PSM to 0x%04X", psm.raw);
err = this->write_register((uint8_t) CommandRegisters::PWR_SAVING, psm.raw_bytes, VEML_REG_SIZE);

View File

@ -24,7 +24,7 @@ enum class CommandRegisters : uint8_t {
ALS_INT = 0x06 // R: ALS INT trigger event
};
enum Gain : uint8_t {
enum Gain : uint16_t {
X_1 = 0,
X_2 = 1,
X_1_8 = 2,
@ -32,7 +32,7 @@ enum Gain : uint8_t {
};
const uint8_t GAINS_COUNT = 4;
enum IntegrationTime : uint8_t {
enum IntegrationTime : uint16_t {
INTEGRATION_TIME_25MS = 0b1100,
INTEGRATION_TIME_50MS = 0b1000,
INTEGRATION_TIME_100MS = 0b0000,
@ -42,14 +42,14 @@ enum IntegrationTime : uint8_t {
};
const uint8_t INTEGRATION_TIMES_COUNT = 6;
enum Persistence : uint8_t {
enum Persistence : uint16_t {
PERSISTENCE_1 = 0,
PERSISTENCE_2 = 1,
PERSISTENCE_4 = 2,
PERSISTENCE_8 = 3,
};
enum PSM : uint8_t {
enum PSMMode : uint16_t {
PSM_MODE_1 = 0,
PSM_MODE_2 = 1,
PSM_MODE_3 = 2,
@ -92,7 +92,7 @@ union PSMRegister {
uint8_t raw_bytes[2];
struct {
bool PSM_EN : 1;
uint8_t PSM : 2;
PSMMode PSM : 2;
uint16_t reserved : 13;
} __attribute__((packed));
};

View File

@ -799,7 +799,7 @@ void VoiceAssistant::on_audio(const api::VoiceAssistantAudio &msg) {
this->speaker_buffer_index_ += msg.data.length();
this->speaker_buffer_size_ += msg.data.length();
this->speaker_bytes_received_ += msg.data.length();
ESP_LOGV(TAG, "Received audio: %" PRId32 " bytes from API", msg.data.length());
ESP_LOGV(TAG, "Received audio: %u bytes from API", msg.data.length());
} else {
ESP_LOGE(TAG, "Cannot receive audio, buffer is full");
}

View File

@ -694,15 +694,15 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
info.netmask = network::IPAddress(255, 255, 255, 0);
}
err = esp_netif_dhcpc_stop(s_ap_netif);
err = esp_netif_dhcps_stop(s_ap_netif);
if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
ESP_LOGV(TAG, "esp_netif_dhcpc_stop failed: %s", esp_err_to_name(err));
ESP_LOGE(TAG, "esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
return false;
}
err = esp_netif_set_ip_info(s_ap_netif, &info);
if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_set_ip_info failed! %d", err);
ESP_LOGE(TAG, "esp_netif_set_ip_info failed! %d", err);
return false;
}
@ -712,20 +712,20 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
start_address += 99;
lease.start_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
start_address += 100;
start_address += 10;
lease.end_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_dhcps_option failed! %d", err);
ESP_LOGE(TAG, "esp_netif_dhcps_option failed! %d", err);
return false;
}
err = esp_netif_dhcps_start(s_ap_netif);
if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_dhcps_start failed! %d", err);
ESP_LOGE(TAG, "esp_netif_dhcps_start failed! %d", err);
return false;
}

View File

@ -716,12 +716,12 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
if (wifi_softap_dhcps_status() == DHCP_STARTED) {
if (!wifi_softap_dhcps_stop()) {
ESP_LOGV(TAG, "Stopping DHCP server failed!");
ESP_LOGW(TAG, "Stopping DHCP server failed!");
}
}
if (!wifi_set_ip_info(SOFTAP_IF, &info)) {
ESP_LOGV(TAG, "Setting SoftAP info failed!");
ESP_LOGE(TAG, "Setting SoftAP info failed!");
return false;
}
@ -735,17 +735,17 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
start_address += 99;
lease.start_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
start_address += 100;
start_address += 10;
lease.end_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
if (!wifi_softap_set_dhcps_lease(&lease)) {
ESP_LOGV(TAG, "Setting SoftAP DHCP lease failed!");
ESP_LOGE(TAG, "Setting SoftAP DHCP lease failed!");
return false;
}
// lease time 1440 minutes (=24 hours)
if (!wifi_softap_set_dhcps_lease_time(1440)) {
ESP_LOGV(TAG, "Setting SoftAP DHCP lease time failed!");
ESP_LOGE(TAG, "Setting SoftAP DHCP lease time failed!");
return false;
}
@ -755,13 +755,13 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
uint8_t mode = 1;
// bit0, 1 enables router information from ESP8266 SoftAP DHCP server.
if (!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode)) {
ESP_LOGV(TAG, "wifi_softap_set_dhcps_offer_option failed!");
ESP_LOGE(TAG, "wifi_softap_set_dhcps_offer_option failed!");
return false;
}
#endif
if (!wifi_softap_dhcps_start()) {
ESP_LOGV(TAG, "Starting SoftAP DHCPS failed!");
ESP_LOGE(TAG, "Starting SoftAP DHCPS failed!");
return false;
}

View File

@ -823,15 +823,15 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
info.netmask = network::IPAddress(255, 255, 255, 0);
}
err = esp_netif_dhcpc_stop(s_ap_netif);
err = esp_netif_dhcps_stop(s_ap_netif);
if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
ESP_LOGV(TAG, "esp_netif_dhcpc_stop failed: %s", esp_err_to_name(err));
ESP_LOGE(TAG, "esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
return false;
}
err = esp_netif_set_ip_info(s_ap_netif, &info);
if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_set_ip_info failed! %d", err);
ESP_LOGE(TAG, "esp_netif_set_ip_info failed! %d", err);
return false;
}
@ -841,20 +841,20 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
start_address += 99;
lease.start_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
start_address += 100;
start_address += 10;
lease.end_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_dhcps_option failed! %d", err);
ESP_LOGE(TAG, "esp_netif_dhcps_option failed! %d", err);
return false;
}
err = esp_netif_dhcps_start(s_ap_netif);
if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_dhcps_start failed! %d", err);
ESP_LOGE(TAG, "esp_netif_dhcps_start failed! %d", err);
return false;
}
@ -887,12 +887,12 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf);
if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_wifi_set_config failed! %d", err);
ESP_LOGE(TAG, "esp_wifi_set_config failed! %d", err);
return false;
}
if (!this->wifi_ap_ip_config_(ap.get_manual_ip())) {
ESP_LOGV(TAG, "wifi_ap_ip_config_ failed!");
ESP_LOGE(TAG, "wifi_ap_ip_config_ failed!");
return false;
}

View File

@ -24,8 +24,8 @@ fi
start_esphome() {
# create dynamic yaml file in `build` folder.
# `./tests/test_build_components/build/[target_component].[test_name].[target_platform].yaml`
component_test_file="./tests/test_build_components/build/$target_component.$test_name.$target_platform.yaml"
# `./tests/test_build_components/build/[target_component].[test_name].[target_platform_with_version].yaml`
component_test_file="./tests/test_build_components/build/$target_component.$test_name.$target_platform_with_version.yaml"
cp $target_platform_file $component_test_file
if [[ "$OSTYPE" == "darwin"* ]]; then
@ -36,7 +36,7 @@ start_esphome() {
fi
# Start esphome process
echo "> [$target_component] [$test_name] [$target_platform]"
echo "> [$target_component] [$test_name] [$target_platform_with_version]"
set -x
# TODO: Validate escape of Command line substitution value
python -m esphome -s component_name $target_component -s component_dir ../../components/$target_component -s test_name $test_name -s target_platform $target_platform $esphome_command $component_test_file
@ -76,16 +76,17 @@ for f in ./tests/components/$target_component/*.*.yaml; do
# 2. `./tests/test_build_components/build_components_base.[target_platform]-ard.yaml`
target_platform_file="./tests/test_build_components/build_components_base.$target_platform.yaml"
if ! [ -f "$target_platform_file" ]; then
# Try find arduino test framework as platform.
target_platform_ard="$target_platform-ard"
target_platform_file="./tests/test_build_components/build_components_base.$target_platform_ard.yaml"
if ! [ -f "$target_platform_file" ]; then
echo "No base test file [./tests/test_build_components/build_components_base.$target_platform.yaml, ./tests/build_components_base.$target_platform_ard.yaml] for component test [$f] found."
exit 1
fi
target_platform=$target_platform_ard
echo "No base test file [./tests/test_build_components/build_components_base.$target_platform.yaml] for component test [$f] found."
exit 1
fi
start_esphome
for target_platform_file in ./tests/test_build_components/build_components_base.$target_platform*.yaml; do
# trim off "./tests/test_build_components/build_components_base." prefix
target_platform_with_version=${target_platform_file:52}
# ...now remove suffix starting with "." leaving just the test target hardware and software platform (possibly with version)
# For example: "esp32-s3-idf-50"
target_platform_with_version=${target_platform_with_version%.*}
start_esphome
done
fi
done

View File

@ -1,9 +1,7 @@
uart:
- id: uart_a01nyub
tx_pin:
number: 4
rx_pin:
number: 5
tx_pin: ${tx_pin}
rx_pin: ${rx_pin}
baud_rate: 9600
sensor:

View File

@ -1,13 +1,5 @@
uart:
- id: uart_a01nyub
tx_pin:
number: 4
rx_pin:
number: 5
baud_rate: 9600
substitutions:
tx_pin: GPIO4
rx_pin: GPIO5
sensor:
- platform: a01nyub
id: a01nyub_sensor
name: a01nyub Distance
uart_id: uart_a01nyub
<<: !include common.yaml

View File

@ -1,13 +1,5 @@
uart:
- id: uart_a01nyub
tx_pin:
number: 17
rx_pin:
number: 16
baud_rate: 9600
substitutions:
tx_pin: GPIO17
rx_pin: GPIO16
sensor:
- platform: a01nyub
id: a01nyub_sensor
name: a01nyub Distance
uart_id: uart_a01nyub
<<: !include common.yaml

View File

@ -1,13 +0,0 @@
uart:
- id: uart_a01nyub
tx_pin:
number: 17
rx_pin:
number: 16
baud_rate: 9600
sensor:
- platform: a01nyub
id: a01nyub_sensor
name: a01nyub Distance
uart_id: uart_a01nyub

View File

@ -1,13 +0,0 @@
uart:
- id: uart_a01nyub
tx_pin:
number: 4
rx_pin:
number: 5
baud_rate: 9600
sensor:
- platform: a01nyub
id: a01nyub_sensor
name: a01nyub Distance
uart_id: uart_a01nyub

View File

@ -1,13 +0,0 @@
uart:
- id: uart_a01nyub
tx_pin:
number: 4
rx_pin:
number: 5
baud_rate: 9600
sensor:
- platform: a01nyub
id: a01nyub_sensor
name: a01nyub Distance
uart_id: uart_a01nyub

Some files were not shown because too many files have changed in this diff Show More