forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protocol decoding, work in progress 2.
- Loading branch information
Showing
3 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* 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, uint64_t numbits, ProtoViewMsgInfo *info) { | ||
const char *sync_patterns[3] = { | ||
"10000000000000000000000000000001", /* 30 zero bits. */ | ||
"100000000000000000000000000000001", /* 31 zero bits. */ | ||
"1000000000000000000000000000000001", /* 32 zero bits. */ | ||
}; | ||
|
||
uint64_t off; | ||
int j; | ||
for (j = 0; j < 3; j++) { | ||
off = bitmap_seek_bits(bits,numbits,0,sync_patterns[j]); | ||
if (off != BITMAP_SEEK_NOT_FOUND) break; | ||
} | ||
if (off == BITMAP_SEEK_NOT_FOUND) return false; | ||
off += strlen(sync_patterns[j]); | ||
|
||
uint8_t d[3]; /* 24 bits of data. */ | ||
uint32_t decoded = | ||
convert_from_line_code(d,sizeof(d),bits,numbits,off,"1000","1110"); | ||
|
||
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters