فهرست منبع

Store bits in the same order they are received.

This makes everything more natural. No bit inversion usually
needed. Raw data matches what we see on the wire.
antirez 3 سال پیش
والد
کامیت
341ceda231
3فایلهای تغییر یافته به همراه11 افزوده شده و 10 حذف شده
  1. 0 1
      protocols/b4b1.c
  2. 9 7
      protocols/oregon2.c
  3. 2 2
      signal.c

+ 0 - 1
protocols/b4b1.c

@@ -31,7 +31,6 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
 
     if (DEBUG_MSG) FURI_LOG_E(TAG, "B4B1 decoded: %lu",decoded);
     if (decoded != 24) return false;
-    bitmap_invert_bytes_bits(d,sizeof(d));
     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);

+ 9 - 7
protocols/oregon2.c

@@ -9,7 +9,7 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
 
     off += 32; /* Skip preamble. */
 
-    uint8_t buffer[8];
+    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);
@@ -19,12 +19,12 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
     char temp[3] = {0}, deviceid[2] = {0}, hum[2] = {0};
     for (int j = 0; j < 64; j += 4) {
         uint8_t nib[1];
-        nib[0] = 0;
-        bitmap_set(nib,1,0,bitmap_get(buffer,8,j+0));
-        bitmap_set(nib,1,1,bitmap_get(buffer,8,j+1));
-        bitmap_set(nib,1,2,bitmap_get(buffer,8,j+2));
-        bitmap_set(nib,1,3,bitmap_get(buffer,8,j+3));
+        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);
         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;
@@ -42,7 +42,9 @@ static bool decode(uint8_t *bits, uint32_t numbytes, uint32_t numbits, ProtoView
     snprintf(info->name,sizeof(info->name),"%s","Oregon v2.1");
     /* The following line crashes the Flipper because of broken
      * snprintf() implementation. */
-    if (0) snprintf(info->raw,sizeof(info->raw),"%08llX", *((uint64_t*)buffer));
+    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",

+ 2 - 2
signal.c

@@ -188,7 +188,7 @@ void scan_for_signal(ProtoViewApp *app) {
  * Out of range bits will silently be discarded. */
 void bitmap_set(uint8_t *b, uint32_t blen, uint32_t bitpos, bool val) {
     uint32_t byte = bitpos/8;
-    uint32_t bit = bitpos&7;
+    uint32_t bit = 7-(bitpos&7);
     if (byte >= blen) return;
     if (val)
         b[byte] |= 1<<bit;
@@ -200,7 +200,7 @@ void bitmap_set(uint8_t *b, uint32_t blen, uint32_t bitpos, bool val) {
  * Out of range bits return false (not bit set). */
 bool bitmap_get(uint8_t *b, uint32_t blen, uint32_t bitpos) {
     uint32_t byte = bitpos/8;
-    uint32_t bit = bitpos&7;
+    uint32_t bit = 7-(bitpos&7);
     if (byte >= blen) return 0;
     return (b[byte] & (1<<bit)) != 0;
 }