mirror of
https://github.com/esphome/esphome.git
synced 2026-09-22 20:48:43 +00:00
Merge remote-tracking branch 'origin/dev' into web-server-offline-hint
# Conflicts: # esphome/components/wifi/wifi_component.cpp # esphome/components/wifi/wifi_component.h
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# A wifi power_save_mode other than NONE is forced off with a warning while
|
||||
# bk72xx_ble is configured (esphome#18592); this config must still validate.
|
||||
packages:
|
||||
bk72xx_ble: !include common.yaml
|
||||
|
||||
wifi:
|
||||
ssid: MySSID
|
||||
password: password1
|
||||
power_save_mode: high
|
||||
@@ -52,7 +52,7 @@ TEST(RpcResponseBuilder, GoldenBytes) {
|
||||
(std::vector<uint8_t>{0x04, 0x03, 0x02, 'a', 'b', 0xCC}));
|
||||
}
|
||||
|
||||
// esp32_improv calls finish() and build_rpc_response() with no checksum flag,
|
||||
// improv_ble calls finish() and build_rpc_response() with no checksum flag,
|
||||
// so the two defaults must agree
|
||||
TEST(RpcResponseBuilder, DefaultChecksumFlagMatches) {
|
||||
const std::vector<std::string> urls = {"https://example.com"};
|
||||
|
||||
@@ -12,7 +12,7 @@ output:
|
||||
pin: 2
|
||||
id: built_in_led
|
||||
|
||||
esp32_improv:
|
||||
improv_ble:
|
||||
authorizer: io0_button
|
||||
authorized_duration: 1min
|
||||
status_indicator: built_in_led
|
||||
@@ -5,6 +5,6 @@ wifi:
|
||||
logger:
|
||||
hardware_uart: UART0
|
||||
|
||||
# next_url compiles the USE_IMPROV_SERIAL_NEXT_URL branch and add_next_url_
|
||||
# next_url compiles the USE_IMPROV_NEXT_URL branch and add_next_url_
|
||||
improv_serial:
|
||||
next_url: https://example.com/?device_name={{device_name}}&ip_address={{ip_address}}
|
||||
|
||||
@@ -792,6 +792,261 @@ TEST(ModbusClientHubBroadcast, RefusesReadBroadcast) {
|
||||
EXPECT_EQ(device.sent_count_, 0); // never transmitted
|
||||
}
|
||||
|
||||
// allow_broadcast_read lifts the refusal for a device that answers address 0: the read is queued, sent,
|
||||
// and waits for a reply like a unicast read, so a reply from address 0 completes it with on_response.
|
||||
TEST(ModbusClientHubBroadcast, AllowBroadcastReadWaitsAndAcceptsReplyFromZero) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice device(&hub, BROADCAST_ADDRESS);
|
||||
|
||||
const uint8_t read[] = {0x03, 0x00, 0x10, 0x00, 0x02}; // read holding registers 0x0010, count 2
|
||||
ASSERT_TRUE(device.queue_pdu(read, {.allow_broadcast_read = true}));
|
||||
EXPECT_TRUE(hub.queued(0).options.allow_broadcast_read);
|
||||
EXPECT_FALSE(hub.queued(0).fire_and_forget());
|
||||
|
||||
hub.send_next_for_test();
|
||||
EXPECT_EQ(device.sent_count_, 1);
|
||||
EXPECT_TRUE(hub.waiting()); // not fire-and-forget: the reply is expected
|
||||
EXPECT_EQ(hub.entries(), 1u);
|
||||
|
||||
const uint8_t reply[] = {0x03, 0x04, 0x00, 0x01, 0x00, 0x02};
|
||||
hub.receive_frame_for_test(BROADCAST_ADDRESS, reply);
|
||||
EXPECT_EQ(device.response_count_, 1);
|
||||
EXPECT_EQ(device.last_response_size_, sizeof(reply));
|
||||
EXPECT_FALSE(hub.waiting());
|
||||
EXPECT_EQ(hub.entries(), 0u);
|
||||
}
|
||||
|
||||
// The address-0 read waits like a unicast one, so the reply must come from address 0 too: a reply from
|
||||
// another unit id is an unexpected frame and interrupts the transaction as it would for any address.
|
||||
TEST(ModbusClientHubBroadcast, AllowBroadcastReadRejectsReplyFromOtherAddress) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice device(&hub, BROADCAST_ADDRESS);
|
||||
|
||||
const uint8_t read[] = {0x03, 0x00, 0x10, 0x00, 0x02};
|
||||
ASSERT_TRUE(device.queue_pdu(read, {.allow_broadcast_read = true}));
|
||||
hub.send_next_for_test();
|
||||
ASSERT_TRUE(hub.waiting());
|
||||
|
||||
const uint8_t reply[] = {0x03, 0x04, 0x00, 0x01, 0x00, 0x02};
|
||||
hub.receive_frame_for_test(0x07, reply);
|
||||
EXPECT_EQ(device.response_count_, 0);
|
||||
EXPECT_EQ(hub.waiting_command().state, FrameState::INTERRUPTED);
|
||||
}
|
||||
|
||||
// An address-scoped clear must not turn a live address-0 entry back into a fire-and-forget broadcast: a
|
||||
// retry granted after the clear is re-sent with the flag intact, so it still waits and gets its terminal.
|
||||
TEST(ModbusClientHubBroadcast, AllowBroadcastReadSurvivesClearBeforeRetry) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
RetryingDevice device(&hub, BROADCAST_ADDRESS, true);
|
||||
|
||||
const uint8_t read[] = {0x03, 0x00, 0x10, 0x00, 0x02};
|
||||
ASSERT_TRUE(device.queue_pdu(read, {.allow_broadcast_read = true}));
|
||||
hub.send_next_for_test();
|
||||
ASSERT_TRUE(hub.waiting());
|
||||
|
||||
hub.clear_tx_queue_for_address(BROADCAST_ADDRESS);
|
||||
EXPECT_EQ(hub.waiting_command().state, FrameState::WAITING_RETIRED);
|
||||
EXPECT_TRUE(hub.waiting_command().options.allow_broadcast_read);
|
||||
|
||||
hub.timeout_waiting(); // retry granted: the entry is READY again
|
||||
ASSERT_EQ(hub.queued_frames(), 1u);
|
||||
EXPECT_FALSE(hub.queued(0).fire_and_forget());
|
||||
|
||||
hub.send_next_for_test();
|
||||
EXPECT_TRUE(hub.waiting()); // the retry still waits for its reply
|
||||
EXPECT_EQ(hub.entries(), 1u);
|
||||
}
|
||||
|
||||
// The function code check is unchanged by the relaxed address match: a mismatched reply still interrupts.
|
||||
TEST(ModbusClientHubBroadcast, AllowBroadcastReadStillRejectsWrongFunctionCode) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice device(&hub, BROADCAST_ADDRESS);
|
||||
|
||||
const uint8_t read[] = {0x03, 0x00, 0x10, 0x00, 0x02};
|
||||
ASSERT_TRUE(device.queue_pdu(read, {.allow_broadcast_read = true}));
|
||||
hub.send_next_for_test();
|
||||
ASSERT_TRUE(hub.waiting());
|
||||
|
||||
const uint8_t wrong_reply[] = {0x04, 0x04, 0x00, 0x01, 0x00, 0x02};
|
||||
hub.receive_frame_for_test(BROADCAST_ADDRESS, wrong_reply); // right address, wrong function code
|
||||
EXPECT_EQ(device.response_count_, 0);
|
||||
EXPECT_EQ(hub.waiting_command().state, FrameState::INTERRUPTED);
|
||||
}
|
||||
|
||||
// A silent device leaves the read to the normal send-wait timeout, so on_no_response is delivered.
|
||||
TEST(ModbusClientHubBroadcast, AllowBroadcastReadTimesOutLikeUnicast) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice device(&hub, BROADCAST_ADDRESS);
|
||||
|
||||
const uint8_t read[] = {0x03, 0x00, 0x10, 0x00, 0x02};
|
||||
ASSERT_TRUE(device.queue_pdu(read, {.allow_broadcast_read = true}));
|
||||
hub.send_next_for_test();
|
||||
ASSERT_TRUE(hub.waiting());
|
||||
|
||||
hub.timeout_waiting();
|
||||
EXPECT_EQ(device.no_response_count_, 1);
|
||||
EXPECT_EQ(device.response_count_, 0);
|
||||
EXPECT_FALSE(hub.waiting());
|
||||
EXPECT_EQ(hub.entries(), 0u);
|
||||
}
|
||||
|
||||
// allow_broadcast_read is stripped from a broadcastable code (a write or custom code to address 0 is a real broadcast,
|
||||
// still fire-and-forget) and from a unicast frame (nothing to allow).
|
||||
TEST(ModbusClientHubBroadcast, AllowBroadcastReadIgnoredForWritesAndUnicast) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice broadcast_device(&hub, BROADCAST_ADDRESS);
|
||||
BroadcastProbeDevice unicast_device(&hub, 0x01);
|
||||
|
||||
const uint8_t write[] = {0x06, 0x00, 0x10, 0x00, 0x01};
|
||||
ASSERT_TRUE(broadcast_device.queue_pdu(write, {.allow_broadcast_read = true}));
|
||||
EXPECT_FALSE(hub.queued(0).options.allow_broadcast_read);
|
||||
EXPECT_TRUE(hub.queued(0).fire_and_forget());
|
||||
hub.send_next_for_test();
|
||||
EXPECT_EQ(broadcast_device.sent_count_, 1);
|
||||
EXPECT_FALSE(hub.waiting());
|
||||
EXPECT_EQ(hub.entries(), 0u);
|
||||
|
||||
const uint8_t custom[] = {0x41, 0x01, 0x02};
|
||||
ASSERT_TRUE(broadcast_device.queue_pdu(custom, {.allow_broadcast_read = true}));
|
||||
EXPECT_FALSE(hub.queued(0).options.allow_broadcast_read);
|
||||
EXPECT_TRUE(hub.queued(0).fire_and_forget());
|
||||
hub.send_next_for_test();
|
||||
EXPECT_FALSE(hub.waiting());
|
||||
EXPECT_EQ(hub.entries(), 0u);
|
||||
|
||||
const uint8_t read[] = {0x03, 0x00, 0x10, 0x00, 0x02};
|
||||
ASSERT_TRUE(unicast_device.queue_pdu(read, {.allow_broadcast_read = true}));
|
||||
EXPECT_FALSE(hub.queued(0).options.allow_broadcast_read);
|
||||
EXPECT_FALSE(hub.queued(0).fire_and_forget());
|
||||
}
|
||||
|
||||
// expect_broadcast_write_response is the write-side twin: a write to address 0 waits for its reply instead
|
||||
// of retiring at transmission, and the reply (from address 0) completes it.
|
||||
TEST(ModbusClientHubBroadcast, ExpectBroadcastWriteResponseWaitsAndAcceptsReply) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice device(&hub, BROADCAST_ADDRESS);
|
||||
|
||||
const uint8_t write[] = {0x06, 0x00, 0x10, 0x00, 0x01};
|
||||
ASSERT_TRUE(device.write_single_register(0x0010, 0x0001, {.expect_broadcast_write_response = true}));
|
||||
EXPECT_TRUE(hub.queued(0).options.expect_broadcast_write_response);
|
||||
EXPECT_FALSE(hub.queued(0).fire_and_forget());
|
||||
|
||||
hub.send_next_for_test();
|
||||
EXPECT_EQ(device.sent_count_, 1);
|
||||
EXPECT_TRUE(hub.waiting());
|
||||
EXPECT_EQ(hub.entries(), 1u);
|
||||
|
||||
hub.receive_frame_for_test(BROADCAST_ADDRESS, write); // the echo, as address 0
|
||||
EXPECT_EQ(device.response_count_, 1);
|
||||
EXPECT_EQ(device.last_response_size_, sizeof(write));
|
||||
EXPECT_FALSE(hub.waiting());
|
||||
EXPECT_EQ(hub.entries(), 0u);
|
||||
}
|
||||
|
||||
// Two requests for the same address-0 write may disagree on expect_broadcast_write_response (a
|
||||
// broadcastable frame is accepted either way), but a write duplicate is refused at its cap of one in
|
||||
// flight rather than absorbed, so the queued entry's delivery mode is never changed under it.
|
||||
TEST(ModbusClientHubBroadcast, ExpectBroadcastWriteResponseDuplicateRefusedNotMerged) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice device(&hub, BROADCAST_ADDRESS);
|
||||
|
||||
ASSERT_TRUE(device.write_single_register(0x0010, 0x0001)); // fire-and-forget as queued
|
||||
EXPECT_TRUE(hub.queued(0).fire_and_forget());
|
||||
EXPECT_FALSE(device.write_single_register(0x0010, 0x0001, {.expect_broadcast_write_response = true}));
|
||||
EXPECT_EQ(hub.entries(), 1u);
|
||||
EXPECT_TRUE(hub.queued(0).fire_and_forget()); // the refused request left the entry untouched
|
||||
|
||||
hub.send_next_for_test();
|
||||
EXPECT_FALSE(hub.waiting());
|
||||
EXPECT_EQ(hub.entries(), 0u);
|
||||
}
|
||||
|
||||
// A custom-code poll at address 0 is a fire-and-forget broadcast that a one-shot duplicate downgrades and
|
||||
// is absorbed into; if that duplicate wants the reply, the entry waits for it instead of retiring at the
|
||||
// send, so the absorbed request still gets its terminal callback.
|
||||
TEST(ModbusClientHubBroadcast, ExpectBroadcastWriteResponseMergesIntoDowngradedPoll) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice device(&hub, BROADCAST_ADDRESS);
|
||||
|
||||
const uint8_t custom[] = {0x41, 0x01, 0x02};
|
||||
ASSERT_TRUE(device.queue_pdu(custom, {.continuous = true}));
|
||||
EXPECT_TRUE(hub.queued(0).fire_and_forget());
|
||||
ASSERT_TRUE(device.queue_pdu(custom, {.expect_broadcast_write_response = true})); // downgrades, absorbed
|
||||
EXPECT_EQ(hub.entries(), 1u);
|
||||
EXPECT_FALSE(hub.queued(0).options.continuous);
|
||||
EXPECT_FALSE(hub.queued(0).fire_and_forget());
|
||||
|
||||
hub.send_next_for_test();
|
||||
EXPECT_TRUE(hub.waiting());
|
||||
hub.receive_frame_for_test(BROADCAST_ADDRESS, custom);
|
||||
EXPECT_EQ(device.response_count_, 1);
|
||||
}
|
||||
|
||||
// A silent device leaves an expected write response to the normal send-wait timeout.
|
||||
TEST(ModbusClientHubBroadcast, ExpectBroadcastWriteResponseTimesOutLikeUnicast) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice device(&hub, BROADCAST_ADDRESS);
|
||||
|
||||
ASSERT_TRUE(device.write_single_coil(0x0010, true, {.expect_broadcast_write_response = true}));
|
||||
hub.send_next_for_test();
|
||||
ASSERT_TRUE(hub.waiting());
|
||||
|
||||
hub.timeout_waiting();
|
||||
EXPECT_EQ(device.no_response_count_, 1);
|
||||
EXPECT_EQ(device.response_count_, 0);
|
||||
EXPECT_FALSE(hub.waiting());
|
||||
EXPECT_EQ(hub.entries(), 0u);
|
||||
}
|
||||
|
||||
// expect_broadcast_write_response is stripped from a read (allow_broadcast_read is the read-side flag, so
|
||||
// the broadcast guard still refuses it) and from a unicast frame (nothing to expect).
|
||||
TEST(ModbusClientHubBroadcast, ExpectBroadcastWriteResponseIgnoredForReadsAndUnicast) {
|
||||
NullUART uart;
|
||||
NoResponseProbeHub hub;
|
||||
hub.set_uart_parent(&uart);
|
||||
hub.setup();
|
||||
BroadcastProbeDevice broadcast_device(&hub, BROADCAST_ADDRESS);
|
||||
BroadcastProbeDevice unicast_device(&hub, 0x01);
|
||||
|
||||
const uint8_t read[] = {0x03, 0x00, 0x10, 0x00, 0x02};
|
||||
EXPECT_FALSE(broadcast_device.queue_pdu(read, {.expect_broadcast_write_response = true}));
|
||||
EXPECT_EQ(hub.entries(), 0u);
|
||||
|
||||
ASSERT_TRUE(unicast_device.write_single_register(0x0010, 0x0001, {.expect_broadcast_write_response = true}));
|
||||
EXPECT_FALSE(hub.queued(0).options.expect_broadcast_write_response);
|
||||
EXPECT_FALSE(hub.queued(0).fire_and_forget());
|
||||
}
|
||||
|
||||
// The counterpart to RefusesReadBroadcast: a custom (user-defined) function code carries no reply the
|
||||
// hub knows how to expect, so a broadcast of one is accepted and completes fire-and-forget like a write.
|
||||
TEST(ModbusClientHubBroadcast, AcceptsCustomBroadcast) {
|
||||
|
||||
@@ -79,7 +79,8 @@ button:
|
||||
name: "Typed Actions"
|
||||
on_press:
|
||||
- modbus_client.write_single_register:
|
||||
address: 0x01
|
||||
address: !lambda "return 1;"
|
||||
expect_broadcast_write_response: true
|
||||
start_address: 0x0102
|
||||
value: !lambda "return 42;"
|
||||
on_response:
|
||||
@@ -93,6 +94,7 @@ button:
|
||||
start_address: 0x10
|
||||
count: 2
|
||||
continuous: true
|
||||
allow_broadcast_read: !lambda "return false;"
|
||||
on_response:
|
||||
then:
|
||||
- lambda: 'ESP_LOGI("modbus_client.test", "first=%u n=%u", values[0], (unsigned) values.size());'
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Config-only: actions that address the broadcast address (0) and wait for a reply, for a device that
|
||||
# answers it. Never compiled, so the extra action objects do not inflate the memory-impact baseline.
|
||||
packages:
|
||||
modbus: !include ../../test_build_components/common/modbus/esp32-idf.yaml
|
||||
|
||||
button:
|
||||
- platform: template
|
||||
name: Broadcast probe
|
||||
on_press:
|
||||
- modbus_client.read_holding_registers:
|
||||
address: 0
|
||||
allow_broadcast_read: true
|
||||
start_address: 0x10
|
||||
count: 1
|
||||
on_response:
|
||||
then:
|
||||
- lambda: 'ESP_LOGI("modbus_client.test", "broadcast read first=%u", values[0]);'
|
||||
- modbus_client.write_single_register:
|
||||
address: 0
|
||||
expect_broadcast_write_response: true
|
||||
start_address: 0x0102
|
||||
value: 42
|
||||
on_response:
|
||||
then:
|
||||
- logger.log: "broadcast write acked"
|
||||
- modbus_client.read_write_multiple_registers:
|
||||
address: 0
|
||||
allow_broadcast_read: true
|
||||
read_address: 0x10
|
||||
read_count: 1
|
||||
write_address: 0x20
|
||||
values: [1]
|
||||
- modbus_client.send:
|
||||
address: 0
|
||||
expect_broadcast_write_response: true
|
||||
pdu: [0x41, 0x01]
|
||||
@@ -6,7 +6,6 @@ modbus_controller:
|
||||
on_online:
|
||||
then:
|
||||
logger.log: "Module Online"
|
||||
|
||||
binary_sensor:
|
||||
- platform: modbus_controller
|
||||
modbus_controller_id: modbus_controller1
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# Config-only: a controller polling the broadcast address (0), for a device that answers it, with a
|
||||
# writer entity expecting the reply to its broadcast writes. Never compiled, so the extra entities do
|
||||
# not inflate the memory-impact baseline.
|
||||
packages:
|
||||
modbus: !include ../../test_build_components/common/modbus/esp32-idf.yaml
|
||||
|
||||
modbus_controller:
|
||||
- id: modbus_controller_broadcast
|
||||
address: 0
|
||||
allow_broadcast_read: true
|
||||
modbus_id: modbus_bus
|
||||
|
||||
sensor:
|
||||
- platform: modbus_controller
|
||||
modbus_controller_id: modbus_controller_broadcast
|
||||
id: modbus_broadcast_sensor
|
||||
name: Broadcast Read Sensor
|
||||
register_type: holding
|
||||
address: 0x0010
|
||||
value_type: U_WORD
|
||||
|
||||
switch:
|
||||
- platform: modbus_controller
|
||||
modbus_controller_id: modbus_controller_broadcast
|
||||
id: modbus_broadcast_switch
|
||||
name: Broadcast Write Switch
|
||||
register_type: coil
|
||||
address: 0x20
|
||||
expect_broadcast_write_response: true
|
||||
@@ -1,6 +1,6 @@
|
||||
# Exercises the provisioning window: api registers as a provisioning source
|
||||
# (encryption enabled, no key), the on_timeout automation, and the wifi (AP +
|
||||
# captive portal) and esp32_improv cross-component guards. improv_serial is
|
||||
# captive portal) and improv_ble cross-component guards. improv_serial is
|
||||
# intentionally NOT gated.
|
||||
provisioning:
|
||||
timeout: 1min
|
||||
@@ -26,5 +26,5 @@ binary_sensor:
|
||||
pin: 0
|
||||
id: io0_button
|
||||
|
||||
esp32_improv:
|
||||
improv_ble:
|
||||
authorizer: io0_button
|
||||
|
||||
@@ -6,6 +6,15 @@ tinyusb:
|
||||
usb_product_str: ESPHomeTestProduct
|
||||
usb_serial_str: ESPHomeTestSerialNumber
|
||||
usb_vendor_id: 0x2345
|
||||
on_mount:
|
||||
- logger.log: USB host mounted
|
||||
- if:
|
||||
condition:
|
||||
tinyusb.is_mounted:
|
||||
then:
|
||||
- logger.log: USB host is mounted
|
||||
on_unmount:
|
||||
- logger.log: USB host unmounted
|
||||
|
||||
# tinyusb requires at least one USB class companion; usb_cdc_acm satisfies that.
|
||||
usb_cdc_acm:
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
<<: !include common.yaml
|
||||
packages:
|
||||
tinyusb: !include common.yaml
|
||||
|
||||
# VBUS monitoring is per variant: the OTG hardware watches the pin here, while the
|
||||
# S31 would need the GPIO ISR path and rejects the key.
|
||||
tinyusb:
|
||||
vbus_monitor_pin: 4
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<<: !include common.yaml
|
||||
packages:
|
||||
tinyusb: !include common.yaml
|
||||
|
||||
# VBUS monitoring is per variant: the OTG hardware watches the pin here, while the
|
||||
# S31 would need the GPIO ISR path and rejects the key.
|
||||
tinyusb:
|
||||
vbus_monitor_pin: 4
|
||||
|
||||
# S2 defaults logger to USB_CDC, which conflicts with tinyusb on the shared
|
||||
# USB OTG peripheral; route the logger to UART0 so the fixture builds.
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
<<: !include common.yaml
|
||||
packages:
|
||||
tinyusb: !include common.yaml
|
||||
|
||||
# VBUS monitoring is per variant: the OTG hardware watches the pin here, while the
|
||||
# S31 would need the GPIO ISR path and rejects the key.
|
||||
tinyusb:
|
||||
vbus_monitor_pin: 4
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
tinyusb:
|
||||
id: tinyusb_test
|
||||
on_mount:
|
||||
- uart_mux.select_bridge: mux_0
|
||||
on_unmount:
|
||||
- uart_mux.select_local: mux_0
|
||||
usb_manufacturer_str: ESPHomeTestManufacturer
|
||||
usb_product_id: 0x1234
|
||||
usb_product_str: ESPHomeTestProduct
|
||||
usb_vendor_id: 0x2345
|
||||
|
||||
uart:
|
||||
- id: uart_0
|
||||
tx_pin: 14
|
||||
rx_pin: 13
|
||||
baud_rate: 115200
|
||||
|
||||
usb_cdc_acm:
|
||||
interfaces:
|
||||
- id: cdc_acm_1
|
||||
|
||||
bridge:
|
||||
- platform: cdc_acm_uart
|
||||
id: bridge_0
|
||||
uart_id: uart_0
|
||||
usb_cdc_acm_id: cdc_acm_1
|
||||
|
||||
uart_mux:
|
||||
- id: mux_0
|
||||
bridge_id: bridge_0
|
||||
initial_route: local
|
||||
|
||||
interval:
|
||||
- interval: 60s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
uart_mux.is_local: mux_0
|
||||
then:
|
||||
- lambda: |-
|
||||
uint8_t byte;
|
||||
if (id(mux_0).available() && id(mux_0).read_byte(&byte)) {
|
||||
id(mux_0).write_byte(byte);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
uart_mux: !include common.yaml
|
||||
@@ -0,0 +1,7 @@
|
||||
# ESP32-S2 has no USB_SERIAL_JTAG, so the logger defaults to USB_CDC, which shares
|
||||
# the USB OTG peripheral with tinyusb. Use a hardware UART for logging instead.
|
||||
logger:
|
||||
hardware_uart: UART0
|
||||
|
||||
packages:
|
||||
uart_mux: !include common.yaml
|
||||
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
uart_mux: !include common.yaml
|
||||
@@ -6,6 +6,7 @@ usb_uart:
|
||||
type: cdc_acm
|
||||
vid: 0x1234
|
||||
pid: 0x5678
|
||||
claim_comm_interface: false
|
||||
channels:
|
||||
- id: channel_0_1
|
||||
- id: uart_1
|
||||
|
||||
Reference in New Issue
Block a user