mirror of
https://github.com/esphome/esphome.git
synced 2024-12-10 14:45:56 +01:00
commit
e6da55b925
@ -99,15 +99,17 @@ BUILD_DEPS="
|
|||||||
libfreetype-dev=2.12.1+dfsg-5+deb12u3
|
libfreetype-dev=2.12.1+dfsg-5+deb12u3
|
||||||
libssl-dev=3.0.15-1~deb12u1
|
libssl-dev=3.0.15-1~deb12u1
|
||||||
libffi-dev=3.4.4-1
|
libffi-dev=3.4.4-1
|
||||||
libopenjp2-7=2.5.0-2
|
|
||||||
libtiff6=4.5.0-6+deb12u1
|
|
||||||
cargo=0.66.0+ds1-1
|
cargo=0.66.0+ds1-1
|
||||||
pkg-config=1.8.1-1
|
pkg-config=1.8.1-1
|
||||||
"
|
"
|
||||||
|
LIB_DEPS="
|
||||||
|
libtiff6=4.5.0-6+deb12u1
|
||||||
|
libopenjp2-7=2.5.0-2
|
||||||
|
"
|
||||||
if [ "$TARGETARCH$TARGETVARIANT" = "arm64" ] || [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]
|
if [ "$TARGETARCH$TARGETVARIANT" = "arm64" ] || [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]
|
||||||
then
|
then
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y --no-install-recommends $BUILD_DEPS
|
apt-get install -y --no-install-recommends $BUILD_DEPS $LIB_DEPS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse CARGO_HOME=/root/.cargo
|
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse CARGO_HOME=/root/.cargo
|
||||||
|
@ -58,7 +58,7 @@ class BinarySensor : public EntityBase, public EntityBase_DeviceClass {
|
|||||||
void publish_initial_state(bool state);
|
void publish_initial_state(bool state);
|
||||||
|
|
||||||
/// The current reported state of the binary sensor.
|
/// The current reported state of the binary sensor.
|
||||||
bool state;
|
bool state{false};
|
||||||
|
|
||||||
void add_filter(Filter *filter);
|
void add_filter(Filter *filter);
|
||||||
void add_filters(const std::vector<Filter *> &filters);
|
void add_filters(const std::vector<Filter *> &filters);
|
||||||
|
@ -15,7 +15,7 @@ static const char *const TAG = "honeywellabp2";
|
|||||||
void HONEYWELLABP2Sensor::read_sensor_data() {
|
void HONEYWELLABP2Sensor::read_sensor_data() {
|
||||||
if (this->read(raw_data_, 7) != i2c::ERROR_OK) {
|
if (this->read(raw_data_, 7) != i2c::ERROR_OK) {
|
||||||
ESP_LOGE(TAG, "Communication with ABP2 failed!");
|
ESP_LOGE(TAG, "Communication with ABP2 failed!");
|
||||||
this->mark_failed();
|
this->status_set_warning("couldn't read sensor data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float press_counts = encode_uint24(raw_data_[1], raw_data_[2], raw_data_[3]); // calculate digital pressure counts
|
float press_counts = encode_uint24(raw_data_[1], raw_data_[2], raw_data_[3]); // calculate digital pressure counts
|
||||||
@ -25,12 +25,13 @@ void HONEYWELLABP2Sensor::read_sensor_data() {
|
|||||||
(this->max_pressure_ - this->min_pressure_)) +
|
(this->max_pressure_ - this->min_pressure_)) +
|
||||||
this->min_pressure_;
|
this->min_pressure_;
|
||||||
this->last_temperature_ = (temp_counts * 200 / 16777215) - 50;
|
this->last_temperature_ = (temp_counts * 200 / 16777215) - 50;
|
||||||
|
this->status_clear_warning();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HONEYWELLABP2Sensor::start_measurement() {
|
void HONEYWELLABP2Sensor::start_measurement() {
|
||||||
if (this->write(i2c_cmd_, 3) != i2c::ERROR_OK) {
|
if (this->write(i2c_cmd_, 3) != i2c::ERROR_OK) {
|
||||||
ESP_LOGE(TAG, "Communication with ABP2 failed!");
|
ESP_LOGE(TAG, "Communication with ABP2 failed!");
|
||||||
this->mark_failed();
|
this->status_set_warning("couldn't start measurement");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->measurement_running_ = true;
|
this->measurement_running_ = true;
|
||||||
@ -39,7 +40,7 @@ void HONEYWELLABP2Sensor::start_measurement() {
|
|||||||
bool HONEYWELLABP2Sensor::is_measurement_ready() {
|
bool HONEYWELLABP2Sensor::is_measurement_ready() {
|
||||||
if (this->read(raw_data_, 1) != i2c::ERROR_OK) {
|
if (this->read(raw_data_, 1) != i2c::ERROR_OK) {
|
||||||
ESP_LOGE(TAG, "Communication with ABP2 failed!");
|
ESP_LOGE(TAG, "Communication with ABP2 failed!");
|
||||||
this->mark_failed();
|
this->status_set_warning("couldn't check measurement");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((raw_data_[0] & (0x1 << STATUS_BIT_BUSY)) > 0) {
|
if ((raw_data_[0] & (0x1 << STATUS_BIT_BUSY)) > 0) {
|
||||||
@ -52,7 +53,7 @@ bool HONEYWELLABP2Sensor::is_measurement_ready() {
|
|||||||
void HONEYWELLABP2Sensor::measurement_timeout() {
|
void HONEYWELLABP2Sensor::measurement_timeout() {
|
||||||
ESP_LOGE(TAG, "Timeout!");
|
ESP_LOGE(TAG, "Timeout!");
|
||||||
this->measurement_running_ = false;
|
this->measurement_running_ = false;
|
||||||
this->mark_failed();
|
this->status_set_warning("measurement timed out");
|
||||||
}
|
}
|
||||||
|
|
||||||
float HONEYWELLABP2Sensor::get_pressure() { return this->last_pressure_; }
|
float HONEYWELLABP2Sensor::get_pressure() { return this->last_pressure_; }
|
||||||
@ -79,7 +80,7 @@ void HONEYWELLABP2Sensor::update() {
|
|||||||
ESP_LOGV(TAG, "Update Honeywell ABP2 Sensor");
|
ESP_LOGV(TAG, "Update Honeywell ABP2 Sensor");
|
||||||
|
|
||||||
this->start_measurement();
|
this->start_measurement();
|
||||||
this->set_timeout("meas_timeout", 50, [this] { this->measurement_timeout(); });
|
this->set_timeout("meas_timeout", 100, [this] { this->measurement_timeout(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void HONEYWELLABP2Sensor::dump_config() {
|
void HONEYWELLABP2Sensor::dump_config() {
|
||||||
|
@ -322,8 +322,8 @@ async def to_code(configs):
|
|||||||
await encoders_to_code(lv_component, config, default_group)
|
await encoders_to_code(lv_component, config, default_group)
|
||||||
await keypads_to_code(lv_component, config, default_group)
|
await keypads_to_code(lv_component, config, default_group)
|
||||||
await theme_to_code(config)
|
await theme_to_code(config)
|
||||||
await styles_to_code(config)
|
|
||||||
await gradients_to_code(config)
|
await gradients_to_code(config)
|
||||||
|
await styles_to_code(config)
|
||||||
await set_obj_properties(lv_scr_act, config)
|
await set_obj_properties(lv_scr_act, config)
|
||||||
await add_widgets(lv_scr_act, config)
|
await add_widgets(lv_scr_act, config)
|
||||||
await add_pages(lv_component, config)
|
await add_pages(lv_component, config)
|
||||||
|
@ -30,7 +30,7 @@ from .defines import (
|
|||||||
call_lambda,
|
call_lambda,
|
||||||
literal,
|
literal,
|
||||||
)
|
)
|
||||||
from .helpers import esphome_fonts_used, lv_fonts_used, requires_component
|
from .helpers import add_lv_use, esphome_fonts_used, lv_fonts_used, requires_component
|
||||||
from .types import lv_font_t, lv_gradient_t, lv_img_t
|
from .types import lv_font_t, lv_gradient_t, lv_img_t
|
||||||
|
|
||||||
opacity_consts = LvConstant("LV_OPA_", "TRANSP", "COVER")
|
opacity_consts = LvConstant("LV_OPA_", "TRANSP", "COVER")
|
||||||
@ -326,6 +326,7 @@ def image_validator(value):
|
|||||||
value = requires_component("image")(value)
|
value = requires_component("image")(value)
|
||||||
value = cv.use_id(Image_)(value)
|
value = cv.use_id(Image_)(value)
|
||||||
lv_images_used.add(value)
|
lv_images_used.add(value)
|
||||||
|
add_lv_use("img", "label")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
@ -341,6 +341,7 @@ FLEX_OBJ_SCHEMA = {
|
|||||||
cv.Optional(df.CONF_FLEX_GROW): cv.int_,
|
cv.Optional(df.CONF_FLEX_GROW): cv.int_,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DISP_BG_SCHEMA = cv.Schema(
|
DISP_BG_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(df.CONF_DISP_BG_IMAGE): lv_image,
|
cv.Optional(df.CONF_DISP_BG_IMAGE): lv_image,
|
||||||
|
@ -39,7 +39,10 @@ LINE_SCHEMA = {
|
|||||||
class LineType(WidgetType):
|
class LineType(WidgetType):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
CONF_LINE, LvType("lv_line_t"), (CONF_MAIN,), LINE_SCHEMA, modify_schema={}
|
CONF_LINE,
|
||||||
|
LvType("lv_line_t"),
|
||||||
|
(CONF_MAIN,),
|
||||||
|
LINE_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def to_code(self, w: Widget, config):
|
async def to_code(self, w: Widget, config):
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace matrix_keypad {
|
namespace matrix_keypad {
|
||||||
|
|
||||||
class MatrixKeypadBinarySensor : public MatrixKeypadListener, public binary_sensor::BinarySensor {
|
class MatrixKeypadBinarySensor : public MatrixKeypadListener, public binary_sensor::BinarySensorInitiallyOff {
|
||||||
public:
|
public:
|
||||||
MatrixKeypadBinarySensor(uint8_t key) : has_key_(true), key_(key){};
|
MatrixKeypadBinarySensor(uint8_t key) : has_key_(true), key_(key){};
|
||||||
MatrixKeypadBinarySensor(const char *key) : has_key_(true), key_((uint8_t) key[0]){};
|
MatrixKeypadBinarySensor(const char *key) : has_key_(true), key_((uint8_t) key[0]){};
|
||||||
|
@ -38,8 +38,9 @@ void Modbus::loop() {
|
|||||||
|
|
||||||
// stop blocking new send commands after sent_wait_time_ ms after response received
|
// stop blocking new send commands after sent_wait_time_ ms after response received
|
||||||
if (now - this->last_send_ > send_wait_time_) {
|
if (now - this->last_send_ > send_wait_time_) {
|
||||||
if (waiting_for_response > 0)
|
if (waiting_for_response > 0) {
|
||||||
ESP_LOGV(TAG, "Stop waiting for response from %d", waiting_for_response);
|
ESP_LOGV(TAG, "Stop waiting for response from %d", waiting_for_response);
|
||||||
|
}
|
||||||
waiting_for_response = 0;
|
waiting_for_response = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
),
|
),
|
||||||
cv.Optional(CONF_ON_OFFLINE): automation.validate_automation(
|
cv.Optional(CONF_ON_OFFLINE): automation.validate_automation(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(ModbusOnlineTrigger),
|
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(ModbusOfflineTrigger),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -622,51 +622,87 @@ int64_t payload_to_number(const std::vector<uint8_t> &data, SensorValueType sens
|
|||||||
uint32_t bitmask) {
|
uint32_t bitmask) {
|
||||||
int64_t value = 0; // int64_t because it can hold signed and unsigned 32 bits
|
int64_t value = 0; // int64_t because it can hold signed and unsigned 32 bits
|
||||||
|
|
||||||
|
size_t size = data.size() - offset;
|
||||||
|
bool error = false;
|
||||||
switch (sensor_value_type) {
|
switch (sensor_value_type) {
|
||||||
case SensorValueType::U_WORD:
|
case SensorValueType::U_WORD:
|
||||||
value = mask_and_shift_by_rightbit(get_data<uint16_t>(data, offset), bitmask); // default is 0xFFFF ;
|
if (size >= 2) {
|
||||||
|
value = mask_and_shift_by_rightbit(get_data<uint16_t>(data, offset), bitmask); // default is 0xFFFF ;
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SensorValueType::U_DWORD:
|
case SensorValueType::U_DWORD:
|
||||||
case SensorValueType::FP32:
|
case SensorValueType::FP32:
|
||||||
value = get_data<uint32_t>(data, offset);
|
if (size >= 4) {
|
||||||
value = mask_and_shift_by_rightbit((uint32_t) value, bitmask);
|
value = get_data<uint32_t>(data, offset);
|
||||||
|
value = mask_and_shift_by_rightbit((uint32_t) value, bitmask);
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SensorValueType::U_DWORD_R:
|
case SensorValueType::U_DWORD_R:
|
||||||
case SensorValueType::FP32_R:
|
case SensorValueType::FP32_R:
|
||||||
value = get_data<uint32_t>(data, offset);
|
if (size >= 4) {
|
||||||
value = static_cast<uint32_t>(value & 0xFFFF) << 16 | (value & 0xFFFF0000) >> 16;
|
value = get_data<uint32_t>(data, offset);
|
||||||
value = mask_and_shift_by_rightbit((uint32_t) value, bitmask);
|
value = static_cast<uint32_t>(value & 0xFFFF) << 16 | (value & 0xFFFF0000) >> 16;
|
||||||
|
value = mask_and_shift_by_rightbit((uint32_t) value, bitmask);
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SensorValueType::S_WORD:
|
case SensorValueType::S_WORD:
|
||||||
value = mask_and_shift_by_rightbit(get_data<int16_t>(data, offset),
|
if (size >= 2) {
|
||||||
bitmask); // default is 0xFFFF ;
|
value = mask_and_shift_by_rightbit(get_data<int16_t>(data, offset),
|
||||||
|
bitmask); // default is 0xFFFF ;
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SensorValueType::S_DWORD:
|
case SensorValueType::S_DWORD:
|
||||||
value = mask_and_shift_by_rightbit(get_data<int32_t>(data, offset), bitmask);
|
if (size >= 4) {
|
||||||
|
value = mask_and_shift_by_rightbit(get_data<int32_t>(data, offset), bitmask);
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SensorValueType::S_DWORD_R: {
|
case SensorValueType::S_DWORD_R: {
|
||||||
value = get_data<uint32_t>(data, offset);
|
if (size >= 4) {
|
||||||
// Currently the high word is at the low position
|
value = get_data<uint32_t>(data, offset);
|
||||||
// the sign bit is therefore at low before the switch
|
// Currently the high word is at the low position
|
||||||
uint32_t sign_bit = (value & 0x8000) << 16;
|
// the sign bit is therefore at low before the switch
|
||||||
value = mask_and_shift_by_rightbit(
|
uint32_t sign_bit = (value & 0x8000) << 16;
|
||||||
static_cast<int32_t>(((value & 0x7FFF) << 16 | (value & 0xFFFF0000) >> 16) | sign_bit), bitmask);
|
value = mask_and_shift_by_rightbit(
|
||||||
|
static_cast<int32_t>(((value & 0x7FFF) << 16 | (value & 0xFFFF0000) >> 16) | sign_bit), bitmask);
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case SensorValueType::U_QWORD:
|
case SensorValueType::U_QWORD:
|
||||||
case SensorValueType::S_QWORD:
|
case SensorValueType::S_QWORD:
|
||||||
// Ignore bitmask for QWORD
|
// Ignore bitmask for QWORD
|
||||||
value = get_data<uint64_t>(data, offset);
|
if (size >= 8) {
|
||||||
|
value = get_data<uint64_t>(data, offset);
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SensorValueType::U_QWORD_R:
|
case SensorValueType::U_QWORD_R:
|
||||||
case SensorValueType::S_QWORD_R: {
|
case SensorValueType::S_QWORD_R: {
|
||||||
// Ignore bitmask for QWORD
|
// Ignore bitmask for QWORD
|
||||||
uint64_t tmp = get_data<uint64_t>(data, offset);
|
if (size >= 8) {
|
||||||
value = (tmp << 48) | (tmp >> 48) | ((tmp & 0xFFFF0000) << 16) | ((tmp >> 16) & 0xFFFF0000);
|
uint64_t tmp = get_data<uint64_t>(data, offset);
|
||||||
|
value = (tmp << 48) | (tmp >> 48) | ((tmp & 0xFFFF0000) << 16) | ((tmp >> 16) & 0xFFFF0000);
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case SensorValueType::RAW:
|
case SensorValueType::RAW:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (error)
|
||||||
|
ESP_LOGE(TAG, "not enough data for value");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Commands
|
# Commands
|
||||||
SW_RESET_CMD = 0x01
|
SW_RESET_CMD = 0x01
|
||||||
SLEEP_OUT = 0x11
|
SLEEP_OUT = 0x11
|
||||||
|
NORON = 0x13
|
||||||
INVERT_OFF = 0x20
|
INVERT_OFF = 0x20
|
||||||
INVERT_ON = 0x21
|
INVERT_ON = 0x21
|
||||||
ALL_ON = 0x23
|
ALL_ON = 0x23
|
||||||
@ -56,6 +57,7 @@ chip.cmd(0xC2, 0x00)
|
|||||||
chip.delay(10)
|
chip.delay(10)
|
||||||
chip.cmd(TEON, 0x00)
|
chip.cmd(TEON, 0x00)
|
||||||
chip.cmd(PIXFMT, 0x55)
|
chip.cmd(PIXFMT, 0x55)
|
||||||
|
chip.cmd(NORON)
|
||||||
|
|
||||||
chip = DriverChip("AXS15231")
|
chip = DriverChip("AXS15231")
|
||||||
chip.cmd(0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0xA5)
|
chip.cmd(0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0xA5)
|
||||||
|
@ -111,7 +111,6 @@ void QspiDbi::reset_params_(bool ready) {
|
|||||||
mad |= MADCTL_MY;
|
mad |= MADCTL_MY;
|
||||||
this->write_command_(MADCTL_CMD, mad);
|
this->write_command_(MADCTL_CMD, mad);
|
||||||
this->write_command_(BRIGHTNESS, this->brightness_);
|
this->write_command_(BRIGHTNESS, this->brightness_);
|
||||||
this->write_command_(NORON);
|
|
||||||
this->write_command_(DISPLAY_ON);
|
this->write_command_(DISPLAY_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ from esphome.const import (
|
|||||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
DEPENDENCIES = ["network"]
|
||||||
|
|
||||||
status_ns = cg.esphome_ns.namespace("status")
|
status_ns = cg.esphome_ns.namespace("status")
|
||||||
StatusBinarySensor = status_ns.class_(
|
StatusBinarySensor = status_ns.class_(
|
||||||
"StatusBinarySensor", binary_sensor.BinarySensor, cg.Component
|
"StatusBinarySensor", binary_sensor.BinarySensor, cg.Component
|
||||||
|
@ -137,8 +137,16 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
|||||||
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv417wifi_sta_config_t
|
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv417wifi_sta_config_t
|
||||||
wifi_config_t conf;
|
wifi_config_t conf;
|
||||||
memset(&conf, 0, sizeof(conf));
|
memset(&conf, 0, sizeof(conf));
|
||||||
snprintf(reinterpret_cast<char *>(conf.sta.ssid), sizeof(conf.sta.ssid), "%s", ap.get_ssid().c_str());
|
if (ap.get_ssid().size() > sizeof(conf.sta.ssid)) {
|
||||||
snprintf(reinterpret_cast<char *>(conf.sta.password), sizeof(conf.sta.password), "%s", ap.get_password().c_str());
|
ESP_LOGE(TAG, "SSID is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ap.get_password().size() > sizeof(conf.sta.password)) {
|
||||||
|
ESP_LOGE(TAG, "password is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.sta.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.sta.password), ap.get_password().c_str(), ap.get_password().size());
|
||||||
|
|
||||||
// The weakest authmode to accept in the fast scan mode
|
// The weakest authmode to accept in the fast scan mode
|
||||||
if (ap.get_password().empty()) {
|
if (ap.get_password().empty()) {
|
||||||
@ -746,7 +754,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
|||||||
|
|
||||||
wifi_config_t conf;
|
wifi_config_t conf;
|
||||||
memset(&conf, 0, sizeof(conf));
|
memset(&conf, 0, sizeof(conf));
|
||||||
snprintf(reinterpret_cast<char *>(conf.ap.ssid), sizeof(conf.ap.ssid), "%s", ap.get_ssid().c_str());
|
if (ap.get_ssid().size() > sizeof(conf.ap.ssid)) {
|
||||||
|
ESP_LOGE(TAG, "AP SSID is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.ap.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
|
||||||
conf.ap.channel = ap.get_channel().value_or(1);
|
conf.ap.channel = ap.get_channel().value_or(1);
|
||||||
conf.ap.ssid_hidden = ap.get_ssid().size();
|
conf.ap.ssid_hidden = ap.get_ssid().size();
|
||||||
conf.ap.max_connection = 5;
|
conf.ap.max_connection = 5;
|
||||||
@ -757,7 +769,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
|||||||
*conf.ap.password = 0;
|
*conf.ap.password = 0;
|
||||||
} else {
|
} else {
|
||||||
conf.ap.authmode = WIFI_AUTH_WPA2_PSK;
|
conf.ap.authmode = WIFI_AUTH_WPA2_PSK;
|
||||||
snprintf(reinterpret_cast<char *>(conf.ap.password), sizeof(conf.ap.password), "%s", ap.get_password().c_str());
|
if (ap.get_password().size() > sizeof(conf.ap.password)) {
|
||||||
|
ESP_LOGE(TAG, "AP password is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.ap.password), ap.get_password().c_str(), ap.get_password().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// pairwise cipher of SoftAP, group cipher will be derived using this.
|
// pairwise cipher of SoftAP, group cipher will be derived using this.
|
||||||
|
@ -236,8 +236,16 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
|||||||
|
|
||||||
struct station_config conf {};
|
struct station_config conf {};
|
||||||
memset(&conf, 0, sizeof(conf));
|
memset(&conf, 0, sizeof(conf));
|
||||||
snprintf(reinterpret_cast<char *>(conf.ssid), sizeof(conf.ssid), "%s", ap.get_ssid().c_str());
|
if (ap.get_ssid().size() > sizeof(conf.ssid)) {
|
||||||
snprintf(reinterpret_cast<char *>(conf.password), sizeof(conf.password), "%s", ap.get_password().c_str());
|
ESP_LOGE(TAG, "SSID is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ap.get_password().size() > sizeof(conf.password)) {
|
||||||
|
ESP_LOGE(TAG, "password is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.password), ap.get_password().c_str(), ap.get_password().size());
|
||||||
|
|
||||||
if (ap.get_bssid().has_value()) {
|
if (ap.get_bssid().has_value()) {
|
||||||
conf.bssid_set = 1;
|
conf.bssid_set = 1;
|
||||||
@ -775,7 +783,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct softap_config conf {};
|
struct softap_config conf {};
|
||||||
snprintf(reinterpret_cast<char *>(conf.ssid), sizeof(conf.ssid), "%s", ap.get_ssid().c_str());
|
if (ap.get_ssid().size() > sizeof(conf.ssid)) {
|
||||||
|
ESP_LOGE(TAG, "AP SSID is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
|
||||||
conf.ssid_len = static_cast<uint8>(ap.get_ssid().size());
|
conf.ssid_len = static_cast<uint8>(ap.get_ssid().size());
|
||||||
conf.channel = ap.get_channel().value_or(1);
|
conf.channel = ap.get_channel().value_or(1);
|
||||||
conf.ssid_hidden = ap.get_hidden();
|
conf.ssid_hidden = ap.get_hidden();
|
||||||
@ -787,7 +799,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
|||||||
*conf.password = 0;
|
*conf.password = 0;
|
||||||
} else {
|
} else {
|
||||||
conf.authmode = AUTH_WPA2_PSK;
|
conf.authmode = AUTH_WPA2_PSK;
|
||||||
snprintf(reinterpret_cast<char *>(conf.password), sizeof(conf.password), "%s", ap.get_password().c_str());
|
if (ap.get_password().size() > sizeof(conf.password)) {
|
||||||
|
ESP_LOGE(TAG, "AP password is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.password), ap.get_password().c_str(), ap.get_password().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
ETS_UART_INTR_DISABLE();
|
ETS_UART_INTR_DISABLE();
|
||||||
|
@ -289,8 +289,16 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
|||||||
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv417wifi_sta_config_t
|
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv417wifi_sta_config_t
|
||||||
wifi_config_t conf;
|
wifi_config_t conf;
|
||||||
memset(&conf, 0, sizeof(conf));
|
memset(&conf, 0, sizeof(conf));
|
||||||
snprintf(reinterpret_cast<char *>(conf.sta.ssid), sizeof(conf.sta.ssid), "%s", ap.get_ssid().c_str());
|
if (ap.get_ssid().size() > sizeof(conf.sta.ssid)) {
|
||||||
snprintf(reinterpret_cast<char *>(conf.sta.password), sizeof(conf.sta.password), "%s", ap.get_password().c_str());
|
ESP_LOGE(TAG, "SSID is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ap.get_password().size() > sizeof(conf.sta.password)) {
|
||||||
|
ESP_LOGE(TAG, "password is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.sta.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.sta.password), ap.get_password().c_str(), ap.get_password().size());
|
||||||
|
|
||||||
// The weakest authmode to accept in the fast scan mode
|
// The weakest authmode to accept in the fast scan mode
|
||||||
if (ap.get_password().empty()) {
|
if (ap.get_password().empty()) {
|
||||||
@ -902,7 +910,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
|||||||
|
|
||||||
wifi_config_t conf;
|
wifi_config_t conf;
|
||||||
memset(&conf, 0, sizeof(conf));
|
memset(&conf, 0, sizeof(conf));
|
||||||
strncpy(reinterpret_cast<char *>(conf.ap.ssid), ap.get_ssid().c_str(), sizeof(conf.ap.ssid));
|
if (ap.get_ssid().size() > sizeof(conf.ap.ssid)) {
|
||||||
|
ESP_LOGE(TAG, "AP SSID is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.ap.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
|
||||||
conf.ap.channel = ap.get_channel().value_or(1);
|
conf.ap.channel = ap.get_channel().value_or(1);
|
||||||
conf.ap.ssid_hidden = ap.get_ssid().size();
|
conf.ap.ssid_hidden = ap.get_ssid().size();
|
||||||
conf.ap.max_connection = 5;
|
conf.ap.max_connection = 5;
|
||||||
@ -913,7 +925,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
|||||||
*conf.ap.password = 0;
|
*conf.ap.password = 0;
|
||||||
} else {
|
} else {
|
||||||
conf.ap.authmode = WIFI_AUTH_WPA2_PSK;
|
conf.ap.authmode = WIFI_AUTH_WPA2_PSK;
|
||||||
strncpy(reinterpret_cast<char *>(conf.ap.password), ap.get_password().c_str(), sizeof(conf.ap.password));
|
if (ap.get_password().size() > sizeof(conf.ap.password)) {
|
||||||
|
ESP_LOGE(TAG, "AP password is too long");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memcpy(reinterpret_cast<char *>(conf.ap.password), ap.get_password().c_str(), ap.get_password().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// pairwise cipher of SoftAP, group cipher will be derived using this.
|
// pairwise cipher of SoftAP, group cipher will be derived using this.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2024.11.1"
|
__version__ = "2024.11.2"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||||
|
Loading…
Reference in New Issue
Block a user