From 49a0bc46f2b0568ab6b92228960babec2bc3e11e Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 2 Jan 2023 18:27:59 +0100 Subject: [PATCH] PT/SC remote protocol working. --- protocols/b4b1.c | 6 ++++-- signal.c | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/protocols/b4b1.c b/protocols/b4b1.c index c5f9e8eaf24..cbc648fa354 100644 --- a/protocols/b4b1.c +++ b/protocols/b4b1.c @@ -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]); diff --git a/signal.c b/signal.c index e6ff5c6b5df..16ff7c03657 100644 --- a/signal.c +++ b/signal.c @@ -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); }