mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-26 03:39:58 -07:00
@@ -1,4 +1,7 @@
|
||||
/* Citroen TPMS. Usually 443.92 Mhz FSK.
|
||||
/* Copyright (C) 2022-2023 Salvatore Sanfilippo -- All Rights Reserved
|
||||
* See the LICENSE file for information about the license.
|
||||
*
|
||||
* Citroen TPMS. Usually 443.92 Mhz FSK.
|
||||
*
|
||||
* Preamble of ~14 high/low 52 us pulses
|
||||
* Sync of high 100us pulse then 50us low
|
||||
@@ -43,33 +46,13 @@ static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoView
|
||||
int temp = raw[7] - 50;
|
||||
int battery = raw[8]; /* This may be the battery. It's not clear. */
|
||||
|
||||
snprintf(info->name, sizeof(info->name), "%s", "Citroen 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%02X",
|
||||
raw[1],
|
||||
raw[2],
|
||||
raw[3],
|
||||
raw[4]);
|
||||
snprintf(info->info2, sizeof(info->info2), "Pressure %.2f kpa", (double)kpa);
|
||||
snprintf(info->info3, sizeof(info->info3), "Temperature %d C", temp);
|
||||
snprintf(info->info4, sizeof(info->info4), "Repeat %d, Bat %d", repeat, battery);
|
||||
fieldset_add_bytes(info->fieldset, "Tire ID", raw + 1, 4 * 2);
|
||||
fieldset_add_float(info->fieldset, "Pressure kpa", kpa, 2);
|
||||
fieldset_add_int(info->fieldset, "Temperature C", temp, 8);
|
||||
fieldset_add_uint(info->fieldset, "Repeat", repeat, 4);
|
||||
fieldset_add_uint(info->fieldset, "Battery", battery, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder CitroenTPMSDecoder = {"Citroen TPMS", decode};
|
||||
ProtoViewDecoder CitroenTPMSDecoder =
|
||||
{.name = "Citroen TPMS", .decode = decode, .get_fields = NULL, .build_message = NULL};
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/* Ford tires TPMS. Usually 443.92 Mhz FSK (in Europe).
|
||||
/* Copyright (C) 2022-2023 Salvatore Sanfilippo -- All Rights Reserved
|
||||
* See the LICENSE file for information about the license.
|
||||
*
|
||||
* Ford tires TPMS. Usually 443.92 Mhz FSK (in Europe).
|
||||
*
|
||||
* 52 us short pules
|
||||
* Preamble: 0101010101010101010101010101
|
||||
@@ -46,34 +49,13 @@ static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoView
|
||||
int flags = raw[5] & 0x7f;
|
||||
int car_moving = (raw[6] & 0x44) == 0x44;
|
||||
|
||||
snprintf(info->name, sizeof(info->name), "%s", "Ford TPMS");
|
||||
snprintf(
|
||||
info->raw,
|
||||
sizeof(info->raw),
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
raw[0],
|
||||
raw[1],
|
||||
raw[2],
|
||||
raw[3],
|
||||
raw[4],
|
||||
raw[5],
|
||||
raw[6],
|
||||
raw[7]);
|
||||
snprintf(
|
||||
info->info1,
|
||||
sizeof(info->info1),
|
||||
"Tire ID %02X%02X%02X%02X",
|
||||
raw[0],
|
||||
raw[1],
|
||||
raw[2],
|
||||
raw[3]);
|
||||
snprintf(info->info2, sizeof(info->info2), "Pressure %.2f psi", (double)psi);
|
||||
if(temp)
|
||||
snprintf(info->info3, sizeof(info->info3), "Temperature %d C", temp);
|
||||
else
|
||||
snprintf(info->info3, sizeof(info->info3), "Flags %d", flags);
|
||||
snprintf(info->info4, sizeof(info->info4), "Moving %s", car_moving ? "yes" : "no");
|
||||
fieldset_add_bytes(info->fieldset, "Tire ID", raw, 4 * 2);
|
||||
fieldset_add_float(info->fieldset, "Pressure psi", psi, 2);
|
||||
fieldset_add_int(info->fieldset, "Temperature C", temp, 8);
|
||||
fieldset_add_hex(info->fieldset, "Flags", flags, 7);
|
||||
fieldset_add_uint(info->fieldset, "Moving", car_moving, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder FordTPMSDecoder = {"Ford TPMS", decode};
|
||||
ProtoViewDecoder FordTPMSDecoder =
|
||||
{.name = "Ford TPMS", .decode = decode, .get_fields = NULL, .build_message = NULL};
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/* Renault tires TPMS. Usually 443.92 Mhz FSK.
|
||||
/* Copyright (C) 2022-2023 Salvatore Sanfilippo -- All Rights Reserved
|
||||
* See the LICENSE file for information about the license.
|
||||
*
|
||||
* Renault tires TPMS. Usually 443.92 Mhz FSK.
|
||||
*
|
||||
* Preamble + sync + Manchester bits. ~48us short pulse.
|
||||
* 9 Bytes in total not counting the preamble. */
|
||||
@@ -48,27 +51,69 @@ static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoView
|
||||
|
||||
info->pulses_count = (off + 8 * 9 * 2) - info->start_off;
|
||||
|
||||
uint8_t flags = raw[0] >> 2;
|
||||
float kpa = 0.75 * ((uint32_t)((raw[0] & 3) << 8) | raw[1]);
|
||||
int temp = raw[2] - 30;
|
||||
|
||||
snprintf(info->name, sizeof(info->name), "%s", "Renault TPMS");
|
||||
snprintf(
|
||||
info->raw,
|
||||
sizeof(info->raw),
|
||||
"%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]);
|
||||
snprintf(info->info1, sizeof(info->info1), "Tire ID %02X%02X%02X", raw[3], raw[4], raw[5]);
|
||||
snprintf(info->info2, sizeof(info->info2), "Pressure %.2f kpa", (double)kpa);
|
||||
snprintf(info->info3, sizeof(info->info3), "Temperature %d C", temp);
|
||||
fieldset_add_bytes(info->fieldset, "Tire ID", raw + 3, 3 * 2);
|
||||
fieldset_add_float(info->fieldset, "Pressure kpa", kpa, 2);
|
||||
fieldset_add_int(info->fieldset, "Temperature C", temp, 8);
|
||||
fieldset_add_hex(info->fieldset, "Flags", flags, 6);
|
||||
fieldset_add_bytes(info->fieldset, "Unknown1", raw + 6, 2);
|
||||
fieldset_add_bytes(info->fieldset, "Unknown2", raw + 7, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder RenaultTPMSDecoder = {"Renault TPMS", decode};
|
||||
/* Give fields and defaults for the signal creator. */
|
||||
static void get_fields(ProtoViewFieldSet* fieldset) {
|
||||
uint8_t default_id[3] = {0xAB, 0xCD, 0xEF};
|
||||
fieldset_add_bytes(fieldset, "Tire ID", default_id, 3 * 2);
|
||||
fieldset_add_float(fieldset, "Pressure kpa", 123, 2);
|
||||
fieldset_add_int(fieldset, "Temperature C", 20, 8);
|
||||
// We don't know what flags are, but 1B is a common value.
|
||||
fieldset_add_hex(fieldset, "Flags", 0x1b, 6);
|
||||
fieldset_add_bytes(fieldset, "Unknown1", (uint8_t*)"\xff", 2);
|
||||
fieldset_add_bytes(fieldset, "Unknown2", (uint8_t*)"\xff", 2);
|
||||
}
|
||||
|
||||
/* Create a Renault TPMS signal, according to the fields provided. */
|
||||
static void build_message(RawSamplesBuffer* samples, ProtoViewFieldSet* fieldset) {
|
||||
uint32_t te = 50; // Short pulse duration in microseconds.
|
||||
|
||||
// Preamble + sync
|
||||
const char* psync = "01010101010101010101010101010110";
|
||||
const char* p = psync;
|
||||
while(*p) {
|
||||
raw_samples_add_or_update(samples, *p == '1', te);
|
||||
p++;
|
||||
}
|
||||
|
||||
// Data, 9 bytes
|
||||
uint8_t data[9] = {0};
|
||||
unsigned int raw_pressure = fieldset->fields[1]->fvalue * 4 / 3;
|
||||
data[0] = fieldset->fields[3]->uvalue << 2; // Flags
|
||||
data[0] |= (raw_pressure >> 8) & 3; // Pressure kpa high 2 bits
|
||||
data[1] = raw_pressure & 0xff; // Pressure kpa low 8 bits
|
||||
data[2] = fieldset->fields[2]->value + 30; // Temperature C
|
||||
memcpy(data + 3, fieldset->fields[0]->bytes, 6); // ID, 24 bits.
|
||||
data[6] = fieldset->fields[4]->bytes[0]; // Unknown 1
|
||||
data[7] = fieldset->fields[5]->bytes[0]; // Unknown 2
|
||||
data[8] = crc8(data, 8, 0, 7);
|
||||
|
||||
// Generate Manchester code for each bit
|
||||
for(uint32_t j = 0; j < 9 * 8; j++) {
|
||||
if(bitmap_get(data, sizeof(data), j)) {
|
||||
raw_samples_add_or_update(samples, true, te);
|
||||
raw_samples_add_or_update(samples, false, te);
|
||||
} else {
|
||||
raw_samples_add_or_update(samples, false, te);
|
||||
raw_samples_add_or_update(samples, true, te);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ProtoViewDecoder RenaultTPMSDecoder = {
|
||||
.name = "Renault TPMS",
|
||||
.decode = decode,
|
||||
.get_fields = get_fields,
|
||||
.build_message = build_message};
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/* Schrader TPMS. Usually 443.92 Mhz OOK, 120us pulse len.
|
||||
/* Copyright (C) 2022-2023 Salvatore Sanfilippo -- All Rights Reserved
|
||||
* See the LICENSE file for information about the license.
|
||||
*
|
||||
* Schrader TPMS. Usually 443.92 Mhz OOK, 120us pulse len.
|
||||
*
|
||||
* 500us high pulse + Preamble + Manchester coded bits where:
|
||||
* 1 = 10
|
||||
@@ -34,6 +37,7 @@ static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoView
|
||||
0011 = 0x3. */
|
||||
|
||||
uint8_t raw[8];
|
||||
uint8_t id[4];
|
||||
uint32_t decoded = convert_from_line_code(
|
||||
raw, sizeof(raw), bits, numbytes, off, "01", "10"); /* Manchester code. */
|
||||
FURI_LOG_E(TAG, "Schrader TPMS decoded bits: %lu", decoded);
|
||||
@@ -51,31 +55,16 @@ static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoView
|
||||
|
||||
float kpa = (float)raw[5] * 2.5;
|
||||
int temp = raw[6] - 50;
|
||||
id[0] = raw[1] & 7;
|
||||
id[1] = raw[2];
|
||||
id[2] = raw[3];
|
||||
id[3] = raw[4];
|
||||
|
||||
snprintf(info->name, sizeof(info->name), "%s", "Schrader TPMS");
|
||||
snprintf(
|
||||
info->raw,
|
||||
sizeof(info->raw),
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
raw[0],
|
||||
raw[1],
|
||||
raw[2],
|
||||
raw[3],
|
||||
raw[4],
|
||||
raw[5],
|
||||
raw[6],
|
||||
raw[7]);
|
||||
snprintf(
|
||||
info->info1,
|
||||
sizeof(info->info1),
|
||||
"Tire ID %01X%02X%02X%02X",
|
||||
raw[1] & 7,
|
||||
raw[2],
|
||||
raw[3],
|
||||
raw[4]); /* 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);
|
||||
fieldset_add_bytes(info->fieldset, "Tire ID", id, 4 * 2);
|
||||
fieldset_add_float(info->fieldset, "Pressure kpa", kpa, 2);
|
||||
fieldset_add_int(info->fieldset, "Temperature C", temp, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder SchraderTPMSDecoder = {"Schrader TPMS", decode};
|
||||
ProtoViewDecoder SchraderTPMSDecoder =
|
||||
{.name = "Schrader TPMS", .decode = decode, .get_fields = NULL, .build_message = NULL};
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/* Schrader variant EG53MA4 TPMS.
|
||||
/* Copyright (C) 2022-2023 Salvatore Sanfilippo -- All Rights Reserved
|
||||
* See the LICENSE file for information about the license.
|
||||
*
|
||||
* Schrader variant EG53MA4 TPMS.
|
||||
* Usually 443.92 Mhz OOK, 100us pulse len.
|
||||
*
|
||||
* Preamble: alternating pulse/gap, 100us.
|
||||
@@ -49,31 +52,11 @@ static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoView
|
||||
int temp_f = raw[8];
|
||||
int temp_c = (temp_f - 32) * 5 / 9; /* Convert Fahrenheit to Celsius. */
|
||||
|
||||
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);
|
||||
fieldset_add_bytes(info->fieldset, "Tire ID", raw + 4, 3 * 2);
|
||||
fieldset_add_float(info->fieldset, "Pressure kpa", kpa, 2);
|
||||
fieldset_add_int(info->fieldset, "Temperature C", temp_c, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder SchraderEG53MA4TPMSDecoder = {"Schrader EG53MA4 TPMS", decode};
|
||||
ProtoViewDecoder SchraderEG53MA4TPMSDecoder =
|
||||
{.name = "Schrader EG53MA4 TPMS", .decode = decode, .get_fields = NULL, .build_message = NULL};
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/* Toyota tires TPMS. Usually 443.92 Mhz FSK (In Europe).
|
||||
/* Copyright (C) 2022-2023 Salvatore Sanfilippo -- All Rights Reserved
|
||||
* See the LICENSE file for information about the license.
|
||||
*
|
||||
* Toyota tires TPMS. Usually 443.92 Mhz FSK (In Europe).
|
||||
*
|
||||
* Preamble + sync + 64 bits of data. ~48us short pulse length.
|
||||
*
|
||||
@@ -65,34 +68,14 @@ static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoView
|
||||
|
||||
info->pulses_count = (off + 8 * 9 * 2) - info->start_off;
|
||||
|
||||
float kpa = (float)((raw[4] & 0x7f) << 1 | raw[5] >> 7) * 0.25 - 7;
|
||||
float psi = (float)((raw[4] & 0x7f) << 1 | raw[5] >> 7) * 0.25 - 7;
|
||||
int temp = ((raw[5] & 0x7f) << 1 | raw[6] >> 7) - 40;
|
||||
|
||||
snprintf(info->name, sizeof(info->name), "%s", "Toyota TPMS");
|
||||
snprintf(
|
||||
info->raw,
|
||||
sizeof(info->raw),
|
||||
"%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]);
|
||||
snprintf(
|
||||
info->info1,
|
||||
sizeof(info->info1),
|
||||
"Tire ID %02X%02X%02X%02X",
|
||||
raw[0],
|
||||
raw[1],
|
||||
raw[2],
|
||||
raw[3]);
|
||||
snprintf(info->info2, sizeof(info->info2), "Pressure %.2f psi", (double)kpa);
|
||||
snprintf(info->info3, sizeof(info->info3), "Temperature %d C", temp);
|
||||
fieldset_add_bytes(info->fieldset, "Tire ID", raw, 4 * 2);
|
||||
fieldset_add_float(info->fieldset, "Pressure psi", psi, 2);
|
||||
fieldset_add_int(info->fieldset, "Temperature C", temp, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder ToyotaTPMSDecoder = {"Toyota TPMS", decode};
|
||||
ProtoViewDecoder ToyotaTPMSDecoder =
|
||||
{.name = "Toyota TPMS", .decode = decode, .get_fields = NULL, .build_message = NULL};
|
||||
|
||||
Reference in New Issue
Block a user