antirez 3 лет назад
Родитель
Сommit
5174bf14df
1 измененных файлов с 7 добавлено и 7 удалено
  1. 7 7
      protocols/renault_tpms.c

+ 7 - 7
protocols/renault_tpms.c

@@ -7,10 +7,10 @@
 
 #define USE_TEST_VECTOR 0
 static const char *test_vector =
-    "10101010" "10101010" "10101010" "10101001" // Preamble + sync.
+    "...01010101010101010110" // Preamble + sync
 
-    /* The following is marshal encoded, so each two characters are
-     * actaully one bit. 01 = 1, 10 = 0. */
+    /* The following is Marshal encoded, so each two characters are
+     * actaully one bit. 01 = 0, 10 = 1. */
     "010110010110" // Flags.
     "10011001101010011001" // Pressure, multiply by 0.75 to obtain kpa.
                            // 244 kpa here.
@@ -29,19 +29,19 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
         numbits = strlen(test_vector);
     }
 
-    if (numbits < 13*8) return false;
+    if (numbits-12 < 9*8) return false;
 
-    const char *sync_pattern = "10101010" "10101010" "10101010" "10101001";
+    const char *sync_pattern = "01010101010101010110";
     uint64_t off = bitmap_seek_bits(bits,numbytes,0,numbits,sync_pattern);
     if (off == BITMAP_SEEK_NOT_FOUND) return false;
     FURI_LOG_E(TAG, "Renault TPMS preamble+sync found");
 
-    off += 32; /* Skip preamble. */
+    off += 20; /* Skip preamble. */
 
     uint8_t raw[9];
     uint32_t decoded =
         convert_from_line_code(raw,sizeof(raw),bits,numbytes,off,
-            "10","01"); /* Manchester. */
+            "01","10"); /* Manchester. */
     FURI_LOG_E(TAG, "Renault TPMS decoded bits: %lu", decoded);
 
     if (decoded < 8*9) return false; /* Require the full 9 bytes. */