9#ifdef USE_BINARY_SENSOR
18static constexpr uint8_t MMWAVE_READ_BUFFER_LENGTH = 253;
19static constexpr uint8_t COMMAND_QUEUE_SIZE = 20;
44 SUB_SWITCH(sensor_active)
45 SUB_SWITCH(turn_on_led)
46 SUB_SWITCH(presence_via_uart)
47 SUB_SWITCH(start_after_boot)
53 void set_active(
bool active) {
56 PUBLISH_STATE(this->sensor_active_switch_, active);
61 bool is_active() {
return active_; }
63 void set_led_active(
bool active) {
66 PUBLISH_STATE(this->turn_on_led_switch_, active);
73 void set_uart_presence_active(
bool active) {
76 PUBLISH_STATE(this->presence_via_uart_switch_, active);
81 void set_start_after_boot(
bool start) {
84 PUBLISH_STATE(this->start_after_boot_switch_, start);
89#ifdef USE_BINARY_SENSOR
90 SUB_BINARY_SENSOR(detected)
96 bool has_queue_room(
size_t count)
const;
98 void enqueue_det_range_cfg(
float min1,
float max1,
float min2,
float max2,
float min3,
float max3,
float min4,
101 void enqueue_set_latency(
float delay_after_detection,
float delay_after_disappear);
107 void format_command(
const Command &cmd,
char *buf,
size_t size)
const;
virtual void dump_config()
Collects bytes into NUL terminated lines of up to N - 1 characters; IGNORE_CHAR bytes are skipped and...
Fixed-size circular buffer with FIFO semantics and iteration support.
StaticRingBuffer< Command, COMMAND_QUEUE_SIZE > cmd_queue_
LineReader< MMWAVE_READ_BUFFER_LENGTH > line_reader_
int16_t det_range_steps_[8]
uint16_t latency_steps_[2]
bool uart_presence_active_
uint32_t ts_last_cmd_sent_
const char * read_message_()
The next complete line, valid until the next call, or nullptr.
void set_detected_(bool detected)
bool handle_reply_(const Command &cmd, const char *message)
Handle a reply to a sent command; true when the command is done.
bool run_command_(const Command &cmd, uint32_t now)
Run the command at the front of the queue; true when it is done.
const LogString * message
@ COMMAND_TYPE_FACTORY_RESET
@ COMMAND_TYPE_DET_RANGE_CFG
@ COMMAND_TYPE_RESET_SYSTEM
@ COMMAND_TYPE_SENSOR_CFG_START
@ COMMAND_TYPE_SET_LATENCY
@ COMMAND_TYPE_SENSITIVITY
@ COMMAND_TYPE_UART_OUTPUT