Fix LD2410 bad reception detection

This commit is contained in:
Theo Arends 2022-12-04 12:37:50 +01:00
parent fca19401b7
commit 5f8ef0c5cb
1 changed files with 31 additions and 30 deletions

View File

@ -80,6 +80,7 @@ uint32_t ToBcd(uint32_t value) {
/********************************************************************************************/ /********************************************************************************************/
void Ld1410HandleTargetData(void) { void Ld1410HandleTargetData(void) {
if ((0x0D == LD2410.buffer[4]) && (0x55 == LD2410.buffer[17])) { // Add bad reception detection
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// F4 F3 F2 F1 0D 00 02 AA 00 00 00 00 00 00 37 00 00 55 00 F8 F7 F6 F5 - No target // F4 F3 F2 F1 0D 00 02 AA 00 00 00 00 00 00 37 00 00 55 00 F8 F7 F6 F5 - No target
// F4 F3 F2 F1 0D 00 02 AA 00 45 00 3E 00 00 3A 00 00 55 00 F8 F7 F6 F5 - No target // F4 F3 F2 F1 0D 00 02 AA 00 45 00 3E 00 00 3A 00 00 55 00 F8 F7 F6 F5 - No target
@ -113,6 +114,7 @@ void Ld1410HandleTargetData(void) {
LD2410.detect_distance = 0; LD2410.detect_distance = 0;
} }
} }
}
void Ld1410HandleConfigData(void) { void Ld1410HandleConfigData(void) {
if (LD2410_CMND_READ_PARAMETERS == LD2410.buffer[6]) { // 0x61 if (LD2410_CMND_READ_PARAMETERS == LD2410.buffer[6]) { // 0x61
@ -403,7 +405,6 @@ void Ld2410Detect(void) {
LD2410.buffer = (uint8_t*)malloc(LD2410_BUFFER_SIZE); // Default 64 LD2410.buffer = (uint8_t*)malloc(LD2410_BUFFER_SIZE); // Default 64
if (!LD2410.buffer) { return; } if (!LD2410.buffer) { return; }
LD2410Serial = new TasmotaSerial(Pin(GPIO_LD2410_RX), Pin(GPIO_LD2410_TX), 2); LD2410Serial = new TasmotaSerial(Pin(GPIO_LD2410_RX), Pin(GPIO_LD2410_TX), 2);
// LD2410Serial = new TasmotaSerial(Pin(GPIO_LD2410_RX), Pin(GPIO_LD2410_TX), 2, 1);
if (LD2410Serial->begin(256000)) { if (LD2410Serial->begin(256000)) {
if (LD2410Serial->hardwareSerial()) { ClaimSerial(); } if (LD2410Serial->hardwareSerial()) { ClaimSerial(); }