67static constexpr uint16_t REFRESH_RATE_MS = 1000;
70static constexpr uint16_t CMD_DISABLE_CONF = 0x00FE;
71static constexpr uint16_t CMD_ENABLE_CONF = 0x00FF;
72static constexpr uint16_t CMD_PARM_HIGH_TRESH = 0x0012;
73static constexpr uint16_t CMD_PARM_LOW_TRESH = 0x0021;
74static constexpr uint16_t CMD_PROTOCOL_VER = 0x0002;
75static constexpr uint16_t CMD_READ_ABD_PARAM = 0x0008;
76static constexpr uint16_t CMD_READ_REG_ADDR = 0x0020;
77static constexpr uint16_t CMD_READ_REGISTER = 0x0002;
78static constexpr uint16_t CMD_READ_SERIAL_NUM = 0x0011;
79static constexpr uint16_t CMD_READ_SYS_PARAM = 0x0013;
80static constexpr uint16_t CMD_READ_VERSION = 0x0000;
81static constexpr uint16_t CMD_RESTART = 0x0068;
82static constexpr uint16_t CMD_SYSTEM_MODE = 0x0000;
83static constexpr uint16_t CMD_SYSTEM_MODE_GR = 0x0003;
84static constexpr uint16_t CMD_SYSTEM_MODE_MTT = 0x0001;
85static constexpr uint16_t CMD_SYSTEM_MODE_SIMPLE = 0x0064;
86static constexpr uint16_t CMD_SYSTEM_MODE_DEBUG = 0x0000;
87static constexpr uint16_t CMD_SYSTEM_MODE_ENERGY = 0x0004;
88static constexpr uint16_t CMD_SYSTEM_MODE_VS = 0x0002;
89static constexpr uint16_t CMD_WRITE_ABD_PARAM = 0x0007;
90static constexpr uint16_t CMD_WRITE_REGISTER = 0x0001;
91static constexpr uint16_t CMD_WRITE_SYS_PARAM = 0x0012;
93static constexpr uint8_t CMD_ABD_DATA_REPLY_SIZE = 0x04;
94static constexpr uint8_t CMD_ABD_DATA_REPLY_START = 0x0A;
95static constexpr uint8_t CMD_MAX_BYTES = 0x64;
96static constexpr uint8_t CMD_REG_DATA_REPLY_SIZE = 0x02;
98static constexpr uint8_t LD2420_ERROR_NONE = 0x00;
99static constexpr uint8_t LD2420_ERROR_TIMEOUT = 0x02;
100static constexpr uint8_t LD2420_ERROR_UNKNOWN = 0x01;
103static constexpr uint16_t CMD_MIN_GATE_REG = 0x0000;
104static constexpr uint16_t CMD_MAX_GATE_REG = 0x0001;
105static constexpr uint16_t CMD_TIMEOUT_REG = 0x0004;
107static constexpr uint16_t CMD_GATE_MOVE_THRESH_REG = 0x0010;
108static constexpr uint16_t CMD_GATE_STILL_THRESH_REG = 0x0020;
110static constexpr uint32_t FACTORY_MOVE_THRESH[TOTAL_GATES] PROGMEM = {60000, 30000, 400, 250, 250, 250, 250, 250,
111 250, 250, 250, 250, 250, 250, 250, 250};
112static constexpr uint32_t FACTORY_STILL_THRESH[TOTAL_GATES] PROGMEM = {40000, 20000, 200, 200, 200, 200, 200, 150,
113 150, 100, 100, 100, 100, 100, 100, 100};
114static constexpr uint16_t FACTORY_TIMEOUT = 120;
115static constexpr uint16_t FACTORY_MIN_GATE = 1;
116static constexpr uint16_t FACTORY_MAX_GATE = 12;
119static constexpr uint32_t CMD_FRAME_FOOTER = 0x01020304;
120static constexpr uint32_t CMD_FRAME_HEADER = 0xFAFBFCFD;
121static constexpr uint32_t DEBUG_FRAME_FOOTER = 0xFAFBFCFD;
122static constexpr uint32_t DEBUG_FRAME_HEADER = 0x1410BFAA;
123static constexpr uint32_t ENERGY_FRAME_FOOTER = 0xF5F6F7F8;
124static constexpr uint32_t ENERGY_FRAME_HEADER = 0xF1F2F3F4;
125static constexpr int CALIBRATE_VERSION_MIN = 154;
126static constexpr uint8_t CMD_FRAME_COMMAND = 6;
127static constexpr uint8_t CMD_FRAME_DATA_LENGTH = 4;
128static constexpr uint8_t CMD_FRAME_STATUS = 7;
129static constexpr uint8_t CMD_ERROR_WORD = 8;
130static constexpr uint8_t ENERGY_SENSOR_START = 9;
131static constexpr uint8_t CALIBRATE_REPORT_INTERVAL = 4;
137static uint8_t calc_checksum(
const void *data,
size_t size) {
142static uint16_t system_mode_for(uint8_t
mode) {
146static int32_t get_firmware_int(
const char *version_string) {
148 const char *p = (*version_string ==
'v') ? version_string + 1 : version_string;
150 for (; *p !=
'\0'; p++) {
153 if (*p <
'0' || *p >
'9')
155 result = result * 10 + (*p -
'0');
163 " Firmware version: %7s",
166 ESP_LOGCONFIG(TAG,
"Number:");
167 LOG_NUMBER(
" ",
"Gate Timeout:", this->gate_timeout_number_);
168 LOG_NUMBER(
" ",
"Gate Max Distance:", this->max_gate_distance_number_);
169 LOG_NUMBER(
" ",
"Gate Min Distance:", this->min_gate_distance_number_);
170 LOG_NUMBER(
" ",
"Gate Select:", this->gate_select_number_);
171 for (uint8_t gate = 0; gate < TOTAL_GATES; gate++) {
177 LOG_BUTTON(
" ",
"Apply Config:", this->apply_config_button_);
178 LOG_BUTTON(
" ",
"Revert Edits:", this->revert_config_button_);
179 LOG_BUTTON(
" ",
"Factory Reset:", this->factory_reset_button_);
180 LOG_BUTTON(
" ",
"Restart Module:", this->restart_module_button_);
183 ESP_LOGCONFIG(TAG,
"Select:");
184 LOG_SELECT(
" ",
"Operating Mode", this->operating_mode_select_);
186 if (ld2420::get_firmware_int(this->
firmware_ver_) < CALIBRATE_VERSION_MIN) {
187 ESP_LOGW(TAG,
"Firmware version %s and older supports Simple Mode only", this->
firmware_ver_);
193 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
202#ifdef LD2420_LISTENER_COUNT
208 for (uint8_t gate = 0; gate < TOTAL_GATES; gate++) {
214 if (ld2420::get_firmware_int(this->
firmware_ver_) < CALIBRATE_VERSION_MIN) {
215 ESP_LOGW(TAG,
"Firmware version %s and older supports Simple Mode only", this->
firmware_ver_);
229 ESP_LOGD(TAG,
"No configuration change detected");
232 ESP_LOGD(TAG,
"Reconfiguring");
234 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
239 for (uint8_t gate = 0; gate < TOTAL_GATES; gate++) {
255 ESP_LOGD(TAG,
"Setting factory defaults");
257 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
263 this->gate_timeout_number_->state = FACTORY_TIMEOUT;
264 this->min_gate_distance_number_->state = FACTORY_MIN_GATE;
265 this->max_gate_distance_number_->state = FACTORY_MAX_GATE;
267 for (uint8_t gate = 0; gate < TOTAL_GATES; gate++) {
283 ESP_LOGD(TAG,
"Restarting");
297 ESP_LOGD(TAG,
"Reverted config number edits");
309 for (uint8_t gate = 0; gate < TOTAL_GATES; ++gate) {
310 this->
radar_data[gate][sample_number] = gate_energy[gate];
319 for (uint8_t gate = 0; gate < TOTAL_GATES; ++gate) {
323 for (uint8_t sample_number = 0; sample_number < CALIBRATE_SAMPLES; ++sample_number) {
328 if (this->
radar_data[gate][sample_number] > peak) {
334 this->
gate_avg[gate] = sum / CALIBRATE_SAMPLES;
341 this->
new_config.
move_thresh[gate] =
static_cast<uint16_t
>(calculated_value <= 65535 ? calculated_value : 65535);
344 this->
new_config.
still_thresh[gate] =
static_cast<uint16_t
>(calculated_value <= 65535 ? calculated_value : 65535);
349 for (uint8_t gate = 0; gate < TOTAL_GATES; ++gate) {
351 ESP_LOGI(TAG,
"Gate: %2d Avg: %5d Peak: %5d", gate, this->
gate_avg[gate], this->
gate_peak[gate]);
374 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
381 if (ld2420::get_firmware_int(this->
firmware_ver_) < CALIBRATE_VERSION_MIN) {
386 PUBLISH_STATE(this->operating_mode_select_,
static_cast<size_t>(
mode - 1));
391 for (uint8_t gate = 0; gate < TOTAL_GATES; gate++) {
394 for (uint8_t i = 0; i < CALIBRATE_SAMPLES; i++) {
417 ESP_LOGW(TAG,
"Max command length exceeded; ignoring");
423 if (memcmp(&
buffer[this->
buffer_pos_ - 4], &CMD_FRAME_FOOTER,
sizeof(CMD_FRAME_FOOTER)) == 0) {
428 (this->
get_mode_() == CMD_SYSTEM_MODE_SIMPLE)) {
431 }
else if ((memcmp(&
buffer[this->
buffer_pos_ - 4], &ENERGY_FRAME_FOOTER,
sizeof(ENERGY_FRAME_FOOTER)) == 0) &&
432 (this->
get_mode_() == CMD_SYSTEM_MODE_ENERGY)) {
442 if (len <
static_cast<int>(index + 1 +
sizeof(
range) + elements *
sizeof(this->
gate_energy_[0]))) {
443 ESP_LOGW(TAG,
"Energy frame too short: %d bytes",
len);
449 index +=
sizeof(
range);
451 for (uint8_t i = 0; i < elements; i++) {
470#ifdef LD2420_LISTENER_COUNT
487 const uint8_t bufsize = 16;
490 char *endptr{
nullptr};
491 char outbuf[bufsize]{0};
493 if (
pos >= 2 && inbuf[
pos - 2] ==
'O' && inbuf[
pos - 1] ==
'F' && inbuf[
pos] ==
'F') {
495 }
else if (
pos >= 1 && inbuf[
pos - 1] ==
'O' && inbuf[
pos] ==
'N') {
498 if (inbuf[
pos] >=
'0' && inbuf[
pos] <=
'9') {
499 if (index < bufsize - 1) {
500 outbuf[index++] = inbuf[
pos];
509 outbuf[index] =
'\0';
514 if (this->
get_mode_() == CMD_SYSTEM_MODE_SIMPLE) {
521#ifdef LD2420_LISTENER_COUNT
526 for (
auto *listener : this->listeners_) {
541 uint16_t data_pos = 0;
543 ESP_LOGW(TAG,
"Reply frame too long");
546 ESP_LOGW(TAG,
"Command frame too short");
549 memcpy(&this->
cmd_reply_.
error, &buffer[CMD_ERROR_WORD],
sizeof(this->cmd_reply_.error));
556 case (CMD_ENABLE_CONF):
557 ESP_LOGV(TAG,
"Set config enable: CMD = %2X %s", CMD_ENABLE_CONF, result);
559 case (CMD_DISABLE_CONF):
560 ESP_LOGV(TAG,
"Set config disable: CMD = %2X %s", CMD_DISABLE_CONF, result);
562 case (CMD_READ_REGISTER): {
563 ESP_LOGV(TAG,
"Read register: CMD = %2X %s", CMD_READ_REGISTER, result);
566 uint16_t reg_count = std::min<uint16_t>((
buffer[CMD_FRAME_DATA_LENGTH] - 4) / CMD_REG_DATA_REPLY_SIZE,
567 sizeof(this->
cmd_reply_.
data) /
sizeof(this->cmd_reply_.data[0]));
568 for (uint16_t i = 0; i < reg_count; i++) {
569 memcpy(&this->
cmd_reply_.
data[i], &
buffer[data_pos + i * CMD_REG_DATA_REPLY_SIZE], CMD_REG_DATA_REPLY_SIZE);
573 case (CMD_WRITE_REGISTER):
574 ESP_LOGV(TAG,
"Write register: CMD = %2X %s", CMD_WRITE_REGISTER, result);
576 case (CMD_WRITE_ABD_PARAM):
577 ESP_LOGV(TAG,
"Write gate parameter(s): %2X %s", CMD_WRITE_ABD_PARAM, result);
579 case (CMD_READ_ABD_PARAM): {
580 ESP_LOGV(TAG,
"Read gate parameter(s): %2X %s", CMD_READ_ABD_PARAM, result);
581 data_pos = CMD_ABD_DATA_REPLY_START;
582 uint16_t abd_count = std::min<uint16_t>((
buffer[CMD_FRAME_DATA_LENGTH] - 4) / CMD_ABD_DATA_REPLY_SIZE,
583 sizeof(this->
cmd_reply_.
data) /
sizeof(this->cmd_reply_.data[0]));
584 for (uint16_t i = 0; i < abd_count; i++) {
586 sizeof(this->cmd_reply_.data[i]));
590 case (CMD_WRITE_SYS_PARAM):
591 ESP_LOGV(TAG,
"Set system parameter(s): %2X %s", CMD_WRITE_SYS_PARAM, result);
593 case (CMD_READ_VERSION): {
597 ESP_LOGV(TAG,
"Firmware version: %s %s", this->
firmware_ver_, result);
608 uint8_t ack_buffer[MAX_LINE_LENGTH];
609 uint8_t cmd_buffer[MAX_LINE_LENGTH];
611 if (frame.
command != CMD_RESTART) {
628 for (uint16_t index = 0; index < frame.
data_length; index++) {
629 memcpy(&cmd_buffer[frame.
length], &frame.
data[index],
sizeof(frame.
data[index]));
638 if (frame.
command == CMD_RESTART) {
644 this->
readline_(this->
read(), ack_buffer,
sizeof(ack_buffer));
648 if ((
millis() - start_millis) > 1000) {
650 error = LD2420_ERROR_TIMEOUT;
669 cmd_frame.
header = CMD_FRAME_HEADER;
670 cmd_frame.
command = enable ? CMD_ENABLE_CONF : CMD_DISABLE_CONF;
672 memcpy(&cmd_frame.
data[0], &CMD_PROTOCOL_VER,
sizeof(CMD_PROTOCOL_VER));
675 cmd_frame.
footer = CMD_FRAME_FOOTER;
676 ESP_LOGV(TAG,
"Sending set config %s command: %2X", enable ? LOG_STR_LITERAL(
"enable") : LOG_STR_LITERAL(
"disable"),
687 cmd_frame.
header = CMD_FRAME_HEADER;
688 cmd_frame.
command = CMD_RESTART;
689 cmd_frame.
footer = CMD_FRAME_FOOTER;
690 ESP_LOGV(TAG,
"Sending restart command: %2X", cmd_frame.
command);
697 cmd_frame.
header = CMD_FRAME_HEADER;
698 cmd_frame.
command = CMD_READ_REGISTER;
699 cmd_frame.
data[1] = reg;
701 cmd_frame.
footer = CMD_FRAME_FOOTER;
702 ESP_LOGV(TAG,
"Sending read register %4X command: %2X", reg, cmd_frame.
command);
709 cmd_frame.
header = CMD_FRAME_HEADER;
710 cmd_frame.
command = CMD_WRITE_REGISTER;
711 memcpy(&cmd_frame.
data[cmd_frame.
data_length], ®, CMD_REG_DATA_REPLY_SIZE);
715 cmd_frame.
footer = CMD_FRAME_FOOTER;
716 ESP_LOGV(TAG,
"Sending write register %4X command: %2X data = %4X", reg, cmd_frame.
command,
value);
721 if (error < ErrMessages::COUNT) {
722 ESP_LOGE(TAG,
"Command failed: %s", LOG_STR_ARG(ErrMessages::get_log_str(error, ErrMessages::LAST_INDEX)));
725 ESP_LOGE(TAG,
"Command failed: error 0x%04X", error);
733 cmd_frame.
header = CMD_FRAME_HEADER;
734 cmd_frame.
command = CMD_READ_ABD_PARAM;
735 const uint16_t move_reg = CMD_GATE_MOVE_THRESH_REG + gate;
736 const uint16_t still_reg = CMD_GATE_STILL_THRESH_REG + gate;
737 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &move_reg,
sizeof(move_reg));
739 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &still_reg,
sizeof(still_reg));
741 cmd_frame.
footer = CMD_FRAME_FOOTER;
742 ESP_LOGV(TAG,
"Sending read gate %d high/low threshold command: %2X", gate, cmd_frame.
command);
755 cmd_frame.
header = CMD_FRAME_HEADER;
756 cmd_frame.
command = CMD_READ_ABD_PARAM;
758 sizeof(CMD_MIN_GATE_REG));
761 sizeof(CMD_MAX_GATE_REG));
764 sizeof(CMD_TIMEOUT_REG));
766 cmd_frame.
footer = CMD_FRAME_FOOTER;
767 ESP_LOGV(TAG,
"Sending read gate min max and timeout command: %2X", cmd_frame.
command);
779 uint16_t unknown_parm = 0x0000;
781 cmd_frame.
header = CMD_FRAME_HEADER;
782 cmd_frame.
command = CMD_WRITE_SYS_PARAM;
783 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &CMD_SYSTEM_MODE,
sizeof(CMD_SYSTEM_MODE));
787 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &unknown_parm,
sizeof(unknown_parm));
789 cmd_frame.
footer = CMD_FRAME_FOOTER;
790 ESP_LOGV(TAG,
"Sending write system mode command: %2X", cmd_frame.
command);
799 cmd_frame.
header = CMD_FRAME_HEADER;
800 cmd_frame.
command = CMD_READ_VERSION;
801 cmd_frame.
footer = CMD_FRAME_FOOTER;
803 ESP_LOGV(TAG,
"Sending read firmware version command: %2X", cmd_frame.
command);
816 cmd_frame.
header = CMD_FRAME_HEADER;
817 cmd_frame.
command = CMD_WRITE_ABD_PARAM;
819 sizeof(CMD_MIN_GATE_REG));
821 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &min_gate_distance,
sizeof(min_gate_distance));
822 cmd_frame.
data_length +=
sizeof(min_gate_distance);
824 sizeof(CMD_MAX_GATE_REG));
826 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &max_gate_distance,
sizeof(max_gate_distance));
827 cmd_frame.
data_length +=
sizeof(max_gate_distance);
829 sizeof(CMD_TIMEOUT_REG));
831 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &timeout,
sizeof(timeout));
834 cmd_frame.
footer = CMD_FRAME_FOOTER;
836 ESP_LOGV(TAG,
"Sending write gate min max and timeout command: %2X", cmd_frame.
command);
845 const uint16_t move_threshold_gate = CMD_GATE_MOVE_THRESH_REG + gate;
846 const uint16_t still_threshold_gate = CMD_GATE_STILL_THRESH_REG + gate;
849 cmd_frame.
header = CMD_FRAME_HEADER;
850 cmd_frame.
command = CMD_WRITE_ABD_PARAM;
851 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &move_threshold_gate,
sizeof(move_threshold_gate));
852 cmd_frame.
data_length +=
sizeof(move_threshold_gate);
853 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &this->new_config.move_thresh[gate],
854 sizeof(this->new_config.move_thresh[gate]));
856 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &still_threshold_gate,
sizeof(still_threshold_gate));
857 cmd_frame.
data_length +=
sizeof(still_threshold_gate);
858 memcpy(&cmd_frame.
data[cmd_frame.
data_length], &this->new_config.still_thresh[gate],
859 sizeof(this->new_config.still_thresh[gate]));
861 cmd_frame.
footer = CMD_FRAME_FOOTER;
862 ESP_LOGV(TAG,
"Sending set gate %4X sensitivity command: %2X", gate, cmd_frame.
command);
869 PUBLISH_STATE(this->gate_select_number_, 0);
874 for (uint8_t gate = 0; gate < TOTAL_GATES; gate++) {
883 for (uint8_t gate = 0; gate < TOTAL_GATES; gate++) {
BedjetMode mode
BedJet operating mode.
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
void mark_failed()
Mark this component as failed.
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
void dump_config() override
void init_gate_config_numbers()
void readline_(int rx_data, uint8_t *buffer, int len)
void set_system_mode(uint16_t mode)
void handle_ack_data_(uint8_t *buffer, int len)
void revert_config_action()
float gate_still_sensitivity_factor
int32_t last_periodic_millis
void restart_module_action()
uint8_t set_config_mode(bool enable)
void update_radar_data(uint16_t const *gate_energy, uint8_t sample_number)
void send_module_restart()
void set_distance_(uint16_t distance)
void set_min_max_distances_timeout(uint32_t max_gate_distance, uint32_t min_gate_distance, uint32_t timeout)
void set_gate_threshold(uint8_t gate)
void change_operating_mode(OpMode mode)
void handle_energy_mode_(uint8_t *buffer, int len)
void auto_calibrate_sensitivity()
void set_calibration_(bool state)
void set_gate_threshold_value(number::Number *n, float value)
int32_t report_periodic_millis
uint16_t gate_peak[TOTAL_GATES]
void get_firmware_version_()
float gate_move_sensitivity_factor
std::array< number::Number *, TOTAL_GATES > gate_move_threshold_numbers_
void set_mode_(uint16_t mode)
void apply_config_action()
uint8_t get_gate_select_value()
uint16_t gate_avg[TOTAL_GATES]
void read_batch_(std::span< uint8_t, MAX_LINE_LENGTH > buffer)
RegConfigT current_config
uint8_t buffer_data_[MAX_LINE_LENGTH]
int get_gate_threshold_(uint8_t gate)
void factory_reset_action()
int send_cmd_from_array(CmdFrameT cmd_frame)
void get_reg_value_(uint16_t reg)
void refresh_gate_config_numbers()
uint16_t gate_energy_[TOTAL_GATES]
int32_t last_normal_periodic_millis
void handle_simple_mode_(const uint8_t *inbuf, int len)
int get_min_max_distances_timeout_()
StaticVector< LD2420Listener *, LD2420_LISTENER_COUNT > listeners_
uint16_t total_sample_number_counter
void set_operating_mode(const char *state)
uint8_t current_operating_mode
uint16_t radar_data[TOTAL_GATES][CALIBRATE_SAMPLES]
uint8_t sample_number_counter
void handle_cmd_error(uint16_t error)
void set_presence_(bool presence)
void set_reg_value(uint16_t reg, uint16_t value)
std::array< number::Number *, TOTAL_GATES > gate_still_threshold_numbers_
Base-class for all numbers.
bool read_available(F &&on_byte)
Same as read_available_chunks(), calling on_byte(uint8_t) once per byte.
void write_array(const uint8_t *data, size_t len)
ESPHOME_LOG_TAG(TAG, "ld2420.binary_sensor")
PROGMEM_STRING_TABLE(OpModeStrings, "Normal", "Calibrate", "Simple")
constexpr uint8_t xor_bytes(const uint8_t *data, size_t len, uint8_t init=0)
XOR the bytes of data with size len, starting from init.
int16_t progmem_string_table_find(const char *value, size_t len)
The index of the string value (len bytes, in RAM) in a PROGMEM_STRING_TABLE, or -1 when it is not one...
void delay_microseconds_safe(uint32_t us)
Delay for the given amount of microseconds, possibly yielding to other processes during the wait.
uint32_t IRAM_ATTR HOT millis()
Application App
Global storage of Application pointer - only one Application can exist.
uint32_t move_thresh[TOTAL_GATES]
uint32_t still_thresh[TOTAL_GATES]