Skip to content

Commit

Permalink
Reanult TPMS fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jan 11, 2023
1 parent 0d62d89 commit 5174bf1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions protocols/renault_tpms.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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. */
Expand Down

0 comments on commit 5174bf1

Please sign in to comment.