7#ifdef USE_BINARY_SENSOR
14#ifdef USE_LD2410S_VERSION
17#if defined(USE_NUMBER) && defined(USE_LD2410S_PARAMETERS)
20#if defined(USE_SELECT) && defined(USE_LD2410S_PARAMETERS)
27static constexpr size_t RX_BUFFER_SIZE = 96;
28static_assert(RX_BUFFER_SIZE <= 255,
"frame lengths are kept in a byte");
42static constexpr uint8_t RESPONSE_SPEEDS[] PROGMEM = {5, 10};
43static constexpr uint8_t RESPONSE_SPEED_COUNT =
sizeof(RESPONSE_SPEEDS);
46#ifdef USE_BINARY_SENSOR
47 SUB_BINARY_SENSOR(target)
50 SUB_SENSOR_WITH_DEDUP(distance, uint16_t)
52#ifdef USE_LD2410S_VERSION
53 SUB_TEXT_SENSOR(version)
55#if defined(USE_SELECT) && defined(USE_LD2410S_PARAMETERS)
56 SUB_SELECT(response_speed)
62 void dump_config()
override;
66#ifdef USE_LD2410S_PARAMETERS
70 this->
numbers_[
static_cast<uint8_t
>(parameter)] = number;
89#ifdef USE_LD2410S_PARAMETERS
92#ifdef USE_LD2410S_VERSION
111#ifdef USE_LD2410S_PARAMETERS
115#if defined(USE_NUMBER) && defined(USE_LD2410S_PARAMETERS)
122#ifdef USE_LD2410S_PARAMETERS
136#ifdef USE_LD2410S_PARAMETERS
virtual void setup()
Where the component's initialization should happen.
void status_set_warning()
virtual void loop()
This method will be called repeatedly.
void handle_command_ack_(const uint8_t *payload, uint16_t len)
bool handle_version_(const uint8_t *values, uint16_t len)
void publish_parameters_()
bool handle_frame_()
Returns false when the footer does not match, so the bytes can be scanned again.
void start_sequence_(const uint16_t *sequence, uint8_t length, uint32_t now)
uint8_t parameters_[PARAMETER_COUNT]
void restart_init_(uint32_t at)
uint16_t current_command_() const
void publish_target_(bool target, uint16_t distance)
const uint16_t * sequence_
number::Number * numbers_[PARAMETER_COUNT]
void send_command_(uint16_t command)
uint8_t rx_buffer_[RX_BUFFER_SIZE]
void count_dropped_frame_()
bool handle_parameters_(const uint8_t *values, uint16_t len)
bool handle_data_frame_(const uint8_t *payload, uint16_t len)
Returns false for a data frame whose state byte is impossible, so it counts as dropped.
void receive_byte_(uint8_t byte)
void run_sequence_(uint32_t now)
Base-class for all numbers.
Base-class for all selects.
Parameter
The module's common parameters, in the order the parameter read answers them.
@ PARAMETER_STATUS_FREQUENCY
@ PARAMETER_DISTANCE_FREQUENCY
@ PARAMETER_RESPONSE_SPEED