7#ifdef USE_BINARY_SENSOR
14#ifdef USE_LD2410S_VERSION
17#if defined(USE_SELECT) && defined(USE_LD2410S_PARAMETERS)
24static constexpr size_t RX_BUFFER_SIZE = 96;
25static_assert(RX_BUFFER_SIZE <= 255,
"frame lengths are kept in a byte");
39static constexpr uint8_t RESPONSE_SPEEDS[] PROGMEM = {5, 10};
40static constexpr uint8_t RESPONSE_SPEED_COUNT =
sizeof(RESPONSE_SPEEDS);
42#if defined(USE_NUMBER) && defined(USE_LD2410S_PARAMETERS)
47#ifdef USE_BINARY_SENSOR
48 SUB_BINARY_SENSOR(target)
51 SUB_SENSOR_WITH_DEDUP(distance, uint16_t)
53#ifdef USE_LD2410S_VERSION
54 SUB_TEXT_SENSOR(version)
56#if defined(USE_SELECT) && defined(USE_LD2410S_PARAMETERS)
57 SUB_SELECT(response_speed)
63 void dump_config()
override;
67#ifdef USE_LD2410S_PARAMETERS
68 bool set_parameter(
Parameter parameter, uint8_t value);
71 this->
numbers_[
static_cast<uint8_t
>(parameter)] = number;
85#ifdef USE_LD2410S_PARAMETERS
88#ifdef USE_LD2410S_VERSION
107#ifdef USE_LD2410S_PARAMETERS
111#if defined(USE_NUMBER) && defined(USE_LD2410S_PARAMETERS)
118#ifdef USE_LD2410S_PARAMETERS
132#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_
void send_command_(uint16_t command)
LD2410SNumber * numbers_[PARAMETER_COUNT]
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)
Edits one common parameter; scale converts the module's units to the number's.
Parameter
The module's common parameters, in the order the parameter read answers them.
@ PARAMETER_STATUS_FREQUENCY
@ PARAMETER_DISTANCE_FREQUENCY
@ PARAMETER_RESPONSE_SPEED