mirror of
https://github.com/UberGuidoZ/Flipper.git
synced 2026-09-18 18:31:29 +00:00
Added xMasterX API v11.x source
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/* PT/SC remotes. Usually 443.92 Mhz OOK.
|
||||
*
|
||||
* This line code is used in many remotes such as Princeton chips
|
||||
* named PT<number>, Silian Microelectronics SC5262 and others.
|
||||
* Basically every 4 pulsee represent a bit, where 1000 means 0, and
|
||||
* 1110 means 1. Usually we can read 24 bits of data.
|
||||
* In this specific implementation we check for a prelude that is
|
||||
* 1 bit high, 31 bits low, but the check is relaxed. */
|
||||
|
||||
#include "../app.h"
|
||||
|
||||
static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoViewMsgInfo *info) {
|
||||
if (numbits < 30) return false;
|
||||
const char *sync_patterns[3] = {
|
||||
"10000000000000000000000000000001", /* 30 zero bits. */
|
||||
"100000000000000000000000000000001", /* 31 zero bits. */
|
||||
"1000000000000000000000000000000001", /* 32 zero bits. */
|
||||
};
|
||||
|
||||
uint32_t off;
|
||||
int j;
|
||||
for (j = 0; j < 3; j++) {
|
||||
off = bitmap_seek_bits(bits,numbytes,0,numbits,sync_patterns[j]);
|
||||
if (off != BITMAP_SEEK_NOT_FOUND) break;
|
||||
}
|
||||
if (off == BITMAP_SEEK_NOT_FOUND) return false;
|
||||
if (DEBUG_MSG) FURI_LOG_E(TAG, "B4B1 preamble at: %lu",off);
|
||||
off += strlen(sync_patterns[j])-1;
|
||||
|
||||
uint8_t d[3]; /* 24 bits of data. */
|
||||
uint32_t decoded =
|
||||
convert_from_line_code(d,sizeof(d),bits,numbytes,off,"1000","1110");
|
||||
|
||||
if (DEBUG_MSG) FURI_LOG_E(TAG, "B4B1 decoded: %lu",decoded);
|
||||
if (decoded != 24) return false;
|
||||
snprintf(info->name,PROTOVIEW_MSG_STR_LEN,"PT/SC remote");
|
||||
snprintf(info->raw,PROTOVIEW_MSG_STR_LEN,"%02X%02X%02X",d[0],d[1],d[2]);
|
||||
info->len = off+(4*24);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder B4B1Decoder = {
|
||||
"B4B1", decode
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
/* Oregon remote termometers. Usually 443.92 Mhz OOK.
|
||||
*
|
||||
* The protocol is described here:
|
||||
* https://wmrx00.sourceforge.net/Arduino/OregonScientific-RF-Protocols.pdf
|
||||
* This implementation is not very complete. */
|
||||
|
||||
#include "../app.h"
|
||||
|
||||
static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoViewMsgInfo *info) {
|
||||
if (numbits < 32) return false;
|
||||
const char *sync_pattern = "01100110" "01100110" "10010110" "10010110";
|
||||
uint64_t off = bitmap_seek_bits(bits,numbytes,0,numbits,sync_pattern);
|
||||
if (off == BITMAP_SEEK_NOT_FOUND) return false;
|
||||
FURI_LOG_E(TAG, "Oregon2 preamble+sync found");
|
||||
|
||||
off += 32; /* Skip preamble. */
|
||||
|
||||
uint8_t buffer[8], raw[8] = {0};
|
||||
uint32_t decoded =
|
||||
convert_from_line_code(buffer,sizeof(buffer),bits,numbytes,off,"1001","0110");
|
||||
FURI_LOG_E(TAG, "Oregon2 decoded bits: %lu", decoded);
|
||||
|
||||
if (decoded < 11*4) return false; /* Minimum len to extract some data. */
|
||||
|
||||
char temp[3] = {0}, deviceid[2] = {0}, hum[2] = {0};
|
||||
for (int j = 0; j < 64; j += 4) {
|
||||
uint8_t nib[1];
|
||||
nib[0] = (bitmap_get(buffer,8,j+0) |
|
||||
bitmap_get(buffer,8,j+1) << 1 |
|
||||
bitmap_get(buffer,8,j+2) << 2 |
|
||||
bitmap_get(buffer,8,j+3) << 3);
|
||||
if (DEBUG_MSG) FURI_LOG_E(TAG, "Not inverted nibble[%d]: %x", j/4, (unsigned int)nib[0]);
|
||||
raw[j/8] |= nib[0] << (4-(j%4));
|
||||
switch(j/4) {
|
||||
case 1: deviceid[0] |= nib[0]; break;
|
||||
case 0: deviceid[0] |= nib[0] << 4; break;
|
||||
case 3: deviceid[1] |= nib[0]; break;
|
||||
case 2: deviceid[1] |= nib[0] << 4; break;
|
||||
case 10: temp[0] = nib[0]; break;
|
||||
/* Fixme: take the temperature sign from nibble 11. */
|
||||
case 9: temp[1] = nib[0]; break;
|
||||
case 8: temp[2] = nib[0]; break;
|
||||
case 13: hum[0] = nib[0]; break;
|
||||
case 12: hum[1] = nib[0]; break;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(info->name,sizeof(info->name),"%s","Oregon v2.1");
|
||||
/* The following line crashes the Flipper because of broken
|
||||
* snprintf() implementation. */
|
||||
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),"Sensor ID %02X%02X",
|
||||
deviceid[0], deviceid[1]);
|
||||
snprintf(info->info2,sizeof(info->info2),"Temperature %d%d.%d",
|
||||
temp[0],temp[1],temp[2]);
|
||||
snprintf(info->info3,sizeof(info->info3),"Humidity %d%d",
|
||||
hum[0],hum[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder Oregon2Decoder = {
|
||||
"Oregon2", decode
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
11001100110011001100110011001100110011001100110011001100110 (Preamble)
|
||||
10 01 01 10 10 01 01 10 (Sync)
|
||||
01 10 10 01 10 01 10 01 01 10 10 01 01 10 01 10 10 01 01 10 10 01 10 01 10 01 10 01 10 01 10 01 01 10 10 01 10 01 10 01 01 10 01 10 01 10 01 10 01 10 01 10 10 01 01 10 01 10 10 01 10 01 10 01 10 01 10 01 01 10 10 01 10 01 01 10 01 10 10 01 01 10 10 01 10 01 10 01 10 01 10 01 10 01 11 0
|
||||
|
||||
We need to seek the following bytes: 01100110 01100110 10010110 10010110
|
||||
0x66 0x66 96 96
|
||||
@@ -0,0 +1,63 @@
|
||||
/* Renault tires TPMS. Usually 443.92 Mhz FSK.
|
||||
*
|
||||
* Preamble + marshal-encoded bits. 9 Bytes in total if we don't
|
||||
* count the preamble. */
|
||||
|
||||
#include "../app.h"
|
||||
|
||||
#define USE_TEST_VECTOR 0
|
||||
static const char *test_vector =
|
||||
"10101010" "10101010" "10101010" "10101001" // Preamble + sync.
|
||||
|
||||
/* The following is marshal encoded, so each two characters are
|
||||
* actaully one bit. 01 = 1, 10 = 0. */
|
||||
"010110010110" // Flags.
|
||||
"10011001101010011001" // Pressure, multiply by 0.75 to obtain kpa.
|
||||
// 244 kpa here.
|
||||
"1010010110011010" // Temperature, subtract 30 to obtain celsius. 22C here.
|
||||
"1001010101101001"
|
||||
"0101100110010101"
|
||||
"1001010101100110" // Tire ID. 0x7AD779 here.
|
||||
"0101010101010101"
|
||||
"0101010101010101" // Two FF bytes (usually). Unknown.
|
||||
"0110010101010101"; // CRC8 with (poly 7, initialization 0).
|
||||
|
||||
static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoViewMsgInfo *info) {
|
||||
|
||||
if (USE_TEST_VECTOR) { /* Test vector to check that decoding works. */
|
||||
bitmap_set_pattern(bits,numbytes,test_vector);
|
||||
numbits = strlen(test_vector);
|
||||
}
|
||||
|
||||
if (numbits < 13*8) return false;
|
||||
|
||||
const char *sync_pattern = "10101010" "10101010" "10101010" "10101001";
|
||||
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. */
|
||||
|
||||
uint8_t raw[9];
|
||||
uint32_t decoded =
|
||||
convert_from_line_code(raw,sizeof(raw),bits,numbytes,off,
|
||||
"10","01"); /* Manchester. */
|
||||
FURI_LOG_E(TAG, "Renault TPMS decoded bits: %lu", decoded);
|
||||
|
||||
if (decoded < 8*9) return false; /* Require the full 9 bytes. */
|
||||
|
||||
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),"Pressure %.2f kpa", (double)kpa);
|
||||
snprintf(info->info2,sizeof(info->info2),"Temperature %d C", temp);
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtoViewDecoder RenaultTPMSDecoder = {
|
||||
"Renault TPMS", decode
|
||||
};
|
||||
Reference in New Issue
Block a user