ld2420: Firmware v1.5.4+ bug workaround (#6168)

This commit is contained in:
Mike La Spina 2024-03-18 13:26:39 -05:00 committed by GitHub
parent e7fe2a2816
commit d692b5404c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -211,10 +211,11 @@ void LD2420Component::factory_reset_action() {
void LD2420Component::restart_module_action() { void LD2420Component::restart_module_action() {
ESP_LOGCONFIG(TAG, "Restarting LD2420 module..."); ESP_LOGCONFIG(TAG, "Restarting LD2420 module...");
this->send_module_restart(); this->send_module_restart();
delay_microseconds_safe(45000); this->set_timeout(250, [this]() {
this->set_config_mode(true); this->set_config_mode(true);
this->set_system_mode(system_mode_); this->set_system_mode(system_mode_);
this->set_config_mode(false); this->set_config_mode(false);
});
ESP_LOGCONFIG(TAG, "LD2420 Restarted."); ESP_LOGCONFIG(TAG, "LD2420 Restarted.");
} }
@ -527,18 +528,16 @@ int LD2420Component::send_cmd_from_array(CmdFrameT frame) {
this->write_byte(cmd_buffer[index]); this->write_byte(cmd_buffer[index]);
} }
delay_microseconds_safe(500); // give the module a moment to process it
error = 0; error = 0;
if (frame.command == CMD_RESTART) { if (frame.command == CMD_RESTART) {
delay_microseconds_safe(25000); // Wait for the restart return 0; // restart does not reply exit now
return 0; // restart does not reply exit now
} }
while (!this->cmd_reply_.ack) { while (!this->cmd_reply_.ack) {
while (available()) { while (available()) {
this->readline_(read(), ack_buffer, sizeof(ack_buffer)); this->readline_(read(), ack_buffer, sizeof(ack_buffer));
} }
delay_microseconds_safe(250); delay_microseconds_safe(1450);
if (loop_count <= 0) { if (loop_count <= 0) {
error = LD2420_ERROR_TIMEOUT; error = LD2420_ERROR_TIMEOUT;
retry--; retry--;