2023-01-18 17:18:19 +00:00
|
|
|
/* Schrader variant EG53MA4 TPMS.
|
|
|
|
* Usually 443.92 Mhz OOK, 100us pulse len.
|
|
|
|
*
|
|
|
|
* Preamble: alternating pulse/gap, 100us.
|
|
|
|
* Sync (as pulses and gaps): "01100101", already part of the data stream
|
|
|
|
* (first nibble) corresponding to 0x4
|
|
|
|
*
|
|
|
|
* A total of 10 bytes payload, Manchester encoded.
|
|
|
|
*
|
|
|
|
* 0 = 01
|
|
|
|
* 1 = 10
|
|
|
|
*
|
|
|
|
* Used in certain Open cars and others.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../../app.h"
|
|
|
|
|
2023-01-18 19:25:39 +00:00
|
|
|
static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoViewMsgInfo* info) {
|
|
|
|
const char* sync_pattern = "010101010101"
|
|
|
|
"01100101";
|
|
|
|
uint8_t sync_len = 12 + 8; /* We just use 12 preamble symbols + sync. */
|
|
|
|
if(numbits - sync_len + 8 < 8 * 10) return false;
|
2023-01-18 17:18:19 +00:00
|
|
|
|
2023-01-18 19:25:39 +00:00
|
|
|
uint64_t off = bitmap_seek_bits(bits, numbytes, 0, numbits, sync_pattern);
|
|
|
|
if(off == BITMAP_SEEK_NOT_FOUND) return false;
|
2023-01-18 17:18:19 +00:00
|
|
|
FURI_LOG_E(TAG, "Schrader EG53MA4 TPMS preamble+sync found");
|
|
|
|
|
|
|
|
info->start_off = off;
|
2023-01-18 19:25:39 +00:00
|
|
|
off += sync_len - 8; /* Skip preamble, not sync that is part of the data. */
|
2023-01-18 17:18:19 +00:00
|
|
|
|
|
|
|
uint8_t raw[10];
|
2023-01-18 19:25:39 +00:00
|
|
|
uint32_t decoded = convert_from_line_code(
|
|
|
|
raw, sizeof(raw), bits, numbytes, off, "01", "10"); /* Manchester code. */
|
2023-01-18 17:18:19 +00:00
|
|
|
FURI_LOG_E(TAG, "Schrader EG53MA4 TPMS decoded bits: %lu", decoded);
|
|
|
|
|
2023-01-18 19:25:39 +00:00
|
|
|
if(decoded < 10 * 8) return false; /* Require the full 10 bytes. */
|
2023-01-18 17:18:19 +00:00
|
|
|
|
|
|
|
/* CRC is just all bytes added mod 256. */
|
|
|
|
uint8_t crc = 0;
|
2023-01-18 19:25:39 +00:00
|
|
|
for(int j = 0; j < 9; j++) crc += raw[j];
|
|
|
|
if(crc != raw[9]) return false; /* Require sane CRC. */
|
2023-01-18 17:18:19 +00:00
|
|
|
|
2023-01-18 19:25:39 +00:00
|
|
|
info->pulses_count = (off + 10 * 8 * 2) - info->start_off;
|
2023-01-18 17:18:19 +00:00
|
|
|
|
|
|
|
/* To convert the raw pressure to kPa, RTL433 uses 2.5, but is likely
|
|
|
|
* wrong. Searching on Google for users experimenting with the value
|
|
|
|
* reported, the value appears to be 2.75. */
|
2023-01-18 19:25:39 +00:00
|
|
|
float kpa = (float)raw[7] * 2.75;
|
2023-01-18 17:18:19 +00:00
|
|
|
int temp_f = raw[8];
|
2023-01-18 19:25:39 +00:00
|
|
|
int temp_c = (temp_f - 32) * 5 / 9; /* Convert Fahrenheit to Celsius. */
|
2023-01-18 17:18:19 +00:00
|
|
|
|
2023-01-18 19:25:39 +00:00
|
|
|
snprintf(info->name, sizeof(info->name), "%s", "Schrader EG53MA4 TPMS");
|
|
|
|
snprintf(
|
|
|
|
info->raw,
|
|
|
|
sizeof(info->raw),
|
|
|
|
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
|
|
|
raw[0],
|
|
|
|
raw[1],
|
|
|
|
raw[2],
|
|
|
|
raw[3],
|
|
|
|
raw[4],
|
|
|
|
raw[5],
|
|
|
|
raw[6],
|
|
|
|
raw[7],
|
|
|
|
raw[8],
|
|
|
|
raw[9]);
|
|
|
|
snprintf(
|
|
|
|
info->info1,
|
|
|
|
sizeof(info->info1),
|
|
|
|
"Tire ID %02X%02X%02X",
|
|
|
|
raw[4],
|
|
|
|
raw[5],
|
|
|
|
raw[6]); /* Only 28 bits of ID, not 32. */
|
|
|
|
snprintf(info->info2, sizeof(info->info2), "Pressure %.2f kpa", (double)kpa);
|
|
|
|
snprintf(info->info3, sizeof(info->info3), "Temperature %d C", temp_c);
|
2023-01-18 17:18:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-01-18 19:25:39 +00:00
|
|
|
ProtoViewDecoder SchraderEG53MA4TPMSDecoder = {"Schrader EG53MA4 TPMS", decode};
|