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

1.1.1 - Improve calibration cycle (hope nothing breaks)

AloneLiberty 2 лет назад
Родитель
Сommit
c9654abd57
3 измененных файлов с 22 добавлено и 6 удалено
  1. 1 1
      FAQ.md
  2. 20 4
      lib/nested/nested.c
  3. 1 1
      mifare_nested_i.h

+ 1 - 1
FAQ.md

@@ -46,7 +46,7 @@ A: By nonces I mean authorization attempts on the tag. Because we can predict PR
 
 Q: How I can ask for help?
 
-A: Create issue **with label "Question"** or use [discussions](https://github.com/AloneLiberty/FlipperNested/discussions). If you can't share private info in issue you can contact me in [Telegram](https://t.me/liberydev). 
+A: Create issue **with label "Question"** or use [discussions](https://github.com/AloneLiberty/FlipperNested/discussions). If you can't share private info in issue you can contact me in [Telegram](https://t.me/libertydev). 
 
 Q: What is being done at the moment and what are the plans?
 

+ 20 - 4
lib/nested/nested.c

@@ -297,16 +297,21 @@ uint32_t nested_calibrate_distance(
     uint32_t nt1, nt2, i = 0, davg = 0, dmin = 0, dmax = 0, rtr = 0, unsuccessful_tries = 0;
     uint32_t max_prng_value = full ? 65565 : 1200;
     uint32_t rounds = full ? 5 : 17; // full does not require precision
+    uint32_t collected = 0;
 
     for(rtr = 0; rtr < rounds; rtr++) {
         nfc_activate();
         if(!furi_hal_nfc_activate_nfca(200, &cuid)) break;
 
-        mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt1);
+        if(!mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, false, &nt1)) {
+            continue;
+        }
 
         furi_delay_us(delay);
 
-        mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, true, &nt2);
+        if(!mifare_classic_authex(crypto, tx_rx, cuid, blockNo, keyType, ui64Key, true, &nt2)) {
+            continue;
+        }
 
         // NXP Mifare is typical around 840, but for some unlicensed/compatible mifare tag this can be 160
         uint32_t nttmp = prng_successor(nt1, 100);
@@ -321,9 +326,12 @@ uint32_t nested_calibrate_distance(
                 davg += i;
                 dmin = MIN(dmin, i);
                 dmax = MAX(dmax, i);
+            } else {
+                dmin = dmax = i;
             }
 
             FURI_LOG_D(TAG, "Calibrating: ntdist=%lu", i);
+            collected++;
         } else {
             unsuccessful_tries++;
             if(unsuccessful_tries > 12) {
@@ -335,10 +343,18 @@ uint32_t nested_calibrate_distance(
         }
     }
 
-    if(rtr > 1) davg = (davg + (rtr - 1) / 2) / (rtr - 1);
+    if(collected > 1) davg = (davg + (collected - 1) / 2) / (collected - 1);
+
+    davg = MIN(MAX(dmin, davg), dmax);
 
     FURI_LOG_I(
-        TAG, "Calibration completed: rtr=%lu min=%lu max=%lu avg=%lu", rtr, dmin, dmax, davg);
+        TAG,
+        "Calibration completed: rtr=%lu min=%lu max=%lu avg=%lu collected=%lu",
+        rtr,
+        dmin,
+        dmax,
+        davg,
+        collected);
 
     nfc_deactivate();
 

+ 1 - 1
mifare_nested_i.h

@@ -19,7 +19,7 @@
 #include <lib/nfc/nfc_device.h>
 #include "mifare_nested_icons.h"
 
-#define NESTED_VERSION_APP "1.1.0"
+#define NESTED_VERSION_APP "1.1.1"
 #define NESTED_GITHUB_LINK "https://github.com/AloneLiberty/FlipperNested"
 #define NESTED_RECOVER_KEYS_GITHUB_LINK "https://github.com/AloneLiberty/FlipperNestedRecovery"
 #define NESTED_NONCE_FORMAT_VERSION "2"