Skip to content

Commit

Permalink
PT/SC remote protocol working.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jan 2, 2023
1 parent 10227a4 commit 49a0bc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 4 additions & 2 deletions protocols/b4b1.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ static bool decode(uint8_t *bits, uint64_t numbits, ProtoViewMsgInfo *info) {
"1000000000000000000000000000000001", /* 32 zero bits. */
};

uint64_t off;
uint32_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]);
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,numbits,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]);
Expand Down
7 changes: 3 additions & 4 deletions signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,23 +328,22 @@ void decode_signal(RawSamplesBuffer *s, uint64_t len) {

/* Try all the decoders available. */
int j = 0;

ProtoViewMsgInfo info;
initialize_msg_info(&info);

while(Decoders[j]) {
FURI_LOG_E(TAG, "Calling decoder %s", Decoders[j]->name);
ProtoViewMsgInfo info;
if (Decoders[j]->decode(bitmap,bits,&info)) {
FURI_LOG_E(TAG, "Message detected by %s", Decoders[j]->name);
break;
}
j++;
}

if (Decoders[j] == NULL) {
FURI_LOG_E(TAG, "No decoding possible");
} else {
FURI_LOG_E(TAG, "Decoded %s, raw=%s",
info.name, info.raw);
FURI_LOG_E(TAG, "Decoded %s, raw=%s", info.name, info.raw);
}
free(bitmap);
}

0 comments on commit 49a0bc4

Please sign in to comment.