mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
Merge branch 'wifi_api' into integration_compact_string_wifi
This commit is contained in:
@@ -5,8 +5,6 @@
|
|||||||
// Once the API is considered stable, this warning will be removed.
|
// Once the API is considered stable, this warning will be removed.
|
||||||
|
|
||||||
#include "esphome/components/infrared/infrared.h"
|
#include "esphome/components/infrared/infrared.h"
|
||||||
#include "esphome/components/remote_transmitter/remote_transmitter.h"
|
|
||||||
#include "esphome/components/remote_receiver/remote_receiver.h"
|
|
||||||
|
|
||||||
namespace esphome::ir_rf_proxy {
|
namespace esphome::ir_rf_proxy {
|
||||||
|
|
||||||
|
|||||||
@@ -823,16 +823,32 @@ void WiFiComponent::setup_ap_config_() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (this->ap_.get_ssid().empty()) {
|
if (this->ap_.get_ssid().empty()) {
|
||||||
std::string name = App.get_name();
|
// Build AP SSID from app name without heap allocation
|
||||||
if (name.length() > 32) {
|
// WiFi SSID max is 32 bytes, with MAC suffix we keep first 25 + last 7
|
||||||
|
static constexpr size_t MAX_SSID_LEN = 32;
|
||||||
|
static constexpr size_t PREFIX_LEN = 25;
|
||||||
|
static constexpr size_t SUFFIX_LEN = 7;
|
||||||
|
|
||||||
|
const std::string &app_name = App.get_name();
|
||||||
|
const char *name_ptr = app_name.c_str();
|
||||||
|
size_t name_len = app_name.length();
|
||||||
|
|
||||||
|
if (name_len <= MAX_SSID_LEN) {
|
||||||
|
// Name fits, use directly
|
||||||
|
this->ap_.set_ssid(name_ptr);
|
||||||
|
} else {
|
||||||
|
// Name too long, need to truncate into stack buffer
|
||||||
|
char ssid_buf[MAX_SSID_LEN + 1];
|
||||||
if (App.is_name_add_mac_suffix_enabled()) {
|
if (App.is_name_add_mac_suffix_enabled()) {
|
||||||
// Keep first 25 chars and last 7 chars (MAC suffix), remove middle
|
// Keep first 25 chars and last 7 chars (MAC suffix), remove middle
|
||||||
name.erase(25, name.length() - 32);
|
memcpy(ssid_buf, name_ptr, PREFIX_LEN);
|
||||||
|
memcpy(ssid_buf + PREFIX_LEN, name_ptr + name_len - SUFFIX_LEN, SUFFIX_LEN);
|
||||||
} else {
|
} else {
|
||||||
name.resize(32);
|
memcpy(ssid_buf, name_ptr, MAX_SSID_LEN);
|
||||||
}
|
}
|
||||||
|
ssid_buf[MAX_SSID_LEN] = '\0';
|
||||||
|
this->ap_.set_ssid(ssid_buf);
|
||||||
}
|
}
|
||||||
this->ap_.set_ssid(name);
|
|
||||||
}
|
}
|
||||||
this->ap_setup_ = this->wifi_start_ap_(this->ap_);
|
this->ap_setup_ = this->wifi_start_ap_(this->ap_);
|
||||||
|
|
||||||
|
|||||||
18
tests/components/ir_rf_proxy/common-rx.yaml
Normal file
18
tests/components/ir_rf_proxy/common-rx.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
remote_receiver:
|
||||||
|
id: ir_receiver
|
||||||
|
pin: ${rx_pin}
|
||||||
|
|
||||||
|
# Test various hardware types with transmitter/receiver using infrared platform
|
||||||
|
infrared:
|
||||||
|
# Infrared receiver
|
||||||
|
- platform: ir_rf_proxy
|
||||||
|
id: ir_rx
|
||||||
|
name: "IR Receiver"
|
||||||
|
remote_receiver_id: ir_receiver
|
||||||
|
|
||||||
|
# RF 900MHz receiver
|
||||||
|
- platform: ir_rf_proxy
|
||||||
|
id: rf_900_rx
|
||||||
|
name: "RF 900 Receiver"
|
||||||
|
frequency: 900 MHz
|
||||||
|
remote_receiver_id: ir_receiver
|
||||||
19
tests/components/ir_rf_proxy/common-tx.yaml
Normal file
19
tests/components/ir_rf_proxy/common-tx.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
remote_transmitter:
|
||||||
|
id: ir_transmitter
|
||||||
|
pin: ${tx_pin}
|
||||||
|
carrier_duty_percent: 50%
|
||||||
|
|
||||||
|
# Test various hardware types with transmitter/receiver using infrared platform
|
||||||
|
infrared:
|
||||||
|
# Infrared transmitter
|
||||||
|
- platform: ir_rf_proxy
|
||||||
|
id: ir_tx
|
||||||
|
name: "IR Transmitter"
|
||||||
|
remote_transmitter_id: ir_transmitter
|
||||||
|
|
||||||
|
# RF 433MHz transmitter
|
||||||
|
- platform: ir_rf_proxy
|
||||||
|
id: rf_433_tx
|
||||||
|
name: "RF 433 Transmitter"
|
||||||
|
frequency: 433 MHz
|
||||||
|
remote_transmitter_id: ir_transmitter
|
||||||
@@ -1,42 +1,7 @@
|
|||||||
|
network:
|
||||||
|
|
||||||
wifi:
|
wifi:
|
||||||
ssid: MySSID
|
ssid: MySSID
|
||||||
password: password1
|
password: password1
|
||||||
|
|
||||||
api:
|
api:
|
||||||
|
|
||||||
remote_transmitter:
|
|
||||||
id: ir_transmitter
|
|
||||||
pin: ${tx_pin}
|
|
||||||
carrier_duty_percent: 50%
|
|
||||||
|
|
||||||
remote_receiver:
|
|
||||||
id: ir_receiver
|
|
||||||
pin: ${rx_pin}
|
|
||||||
|
|
||||||
# Test various hardware types with transmitter/receiver using infrared platform
|
|
||||||
infrared:
|
|
||||||
# Infrared transmitter
|
|
||||||
- platform: ir_rf_proxy
|
|
||||||
id: ir_tx
|
|
||||||
name: "IR Transmitter"
|
|
||||||
remote_transmitter_id: ir_transmitter
|
|
||||||
|
|
||||||
# Infrared receiver
|
|
||||||
- platform: ir_rf_proxy
|
|
||||||
id: ir_rx
|
|
||||||
name: "IR Receiver"
|
|
||||||
remote_receiver_id: ir_receiver
|
|
||||||
|
|
||||||
# RF 433MHz transmitter
|
|
||||||
- platform: ir_rf_proxy
|
|
||||||
id: rf_433_tx
|
|
||||||
name: "RF 433 Transmitter"
|
|
||||||
frequency: 433 MHz
|
|
||||||
remote_transmitter_id: ir_transmitter
|
|
||||||
|
|
||||||
# RF 900MHz receiver
|
|
||||||
- platform: ir_rf_proxy
|
|
||||||
id: rf_900_rx
|
|
||||||
name: "RF 900 Receiver"
|
|
||||||
frequency: 900 MHz
|
|
||||||
remote_receiver_id: ir_receiver
|
|
||||||
|
|||||||
7
tests/components/ir_rf_proxy/test-rx.esp32-idf.yaml
Normal file
7
tests/components/ir_rf_proxy/test-rx.esp32-idf.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
substitutions:
|
||||||
|
tx_pin: GPIO4
|
||||||
|
rx_pin: GPIO5
|
||||||
|
|
||||||
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
rx: !include common-rx.yaml
|
||||||
7
tests/components/ir_rf_proxy/test-rx.esp8266-ard.yaml
Normal file
7
tests/components/ir_rf_proxy/test-rx.esp8266-ard.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
substitutions:
|
||||||
|
tx_pin: GPIO4
|
||||||
|
rx_pin: GPIO5
|
||||||
|
|
||||||
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
rx: !include common-rx.yaml
|
||||||
7
tests/components/ir_rf_proxy/test-rx.rp2040-ard.yaml
Normal file
7
tests/components/ir_rf_proxy/test-rx.rp2040-ard.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
substitutions:
|
||||||
|
tx_pin: GPIO4
|
||||||
|
rx_pin: GPIO5
|
||||||
|
|
||||||
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
rx: !include common-rx.yaml
|
||||||
7
tests/components/ir_rf_proxy/test-tx.esp32-idf.yaml
Normal file
7
tests/components/ir_rf_proxy/test-tx.esp32-idf.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
substitutions:
|
||||||
|
tx_pin: GPIO4
|
||||||
|
rx_pin: GPIO5
|
||||||
|
|
||||||
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
tx: !include common-tx.yaml
|
||||||
7
tests/components/ir_rf_proxy/test-tx.esp8266-ard.yaml
Normal file
7
tests/components/ir_rf_proxy/test-tx.esp8266-ard.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
substitutions:
|
||||||
|
tx_pin: GPIO4
|
||||||
|
rx_pin: GPIO5
|
||||||
|
|
||||||
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
tx: !include common-tx.yaml
|
||||||
7
tests/components/ir_rf_proxy/test-tx.rp2040-ard.yaml
Normal file
7
tests/components/ir_rf_proxy/test-tx.rp2040-ard.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
substitutions:
|
||||||
|
tx_pin: GPIO4
|
||||||
|
rx_pin: GPIO5
|
||||||
|
|
||||||
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
tx: !include common-tx.yaml
|
||||||
8
tests/components/ir_rf_proxy/test.bk72xx-ard.yaml
Normal file
8
tests/components/ir_rf_proxy/test.bk72xx-ard.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
substitutions:
|
||||||
|
tx_pin: GPIO4
|
||||||
|
rx_pin: GPIO5
|
||||||
|
|
||||||
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
rx: !include common-rx.yaml
|
||||||
|
tx: !include common-tx.yaml
|
||||||
@@ -2,4 +2,7 @@ substitutions:
|
|||||||
tx_pin: GPIO4
|
tx_pin: GPIO4
|
||||||
rx_pin: GPIO5
|
rx_pin: GPIO5
|
||||||
|
|
||||||
<<: !include common.yaml
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
rx: !include common-rx.yaml
|
||||||
|
tx: !include common-tx.yaml
|
||||||
|
|||||||
@@ -2,4 +2,7 @@ substitutions:
|
|||||||
tx_pin: GPIO4
|
tx_pin: GPIO4
|
||||||
rx_pin: GPIO5
|
rx_pin: GPIO5
|
||||||
|
|
||||||
<<: !include common.yaml
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
rx: !include common-rx.yaml
|
||||||
|
tx: !include common-tx.yaml
|
||||||
|
|||||||
@@ -2,4 +2,7 @@ substitutions:
|
|||||||
tx_pin: GPIO4
|
tx_pin: GPIO4
|
||||||
rx_pin: GPIO5
|
rx_pin: GPIO5
|
||||||
|
|
||||||
<<: !include common.yaml
|
packages:
|
||||||
|
common: !include common.yaml
|
||||||
|
rx: !include common-rx.yaml
|
||||||
|
tx: !include common-tx.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user