Просмотр исходного кода

PT/SC remote protocol working.

antirez 3 лет назад
Родитель
Сommit
49a0bc46f2
2 измененных файлов с 7 добавлено и 6 удалено
  1. 4 2
      protocols/b4b1.c
  2. 3 4
      signal.c

+ 4 - 2
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]);

+ 3 - 4
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);
 }