mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 10:43:01 +08:00
FIX: detect noise signal by measuring amplitude of signal.
This commit is contained in:
parent
6f948be842
commit
db56ca11a3
4 changed files with 44 additions and 23 deletions
|
@ -85,14 +85,10 @@ extern void switch_off();
|
|||
#define FPGA_HF_ISO14443A_READER_LISTEN (3<<0)
|
||||
#define FPGA_HF_ISO14443A_READER_MOD (4<<0)
|
||||
|
||||
|
||||
//options for Felica.
|
||||
#define FPGA_MAJOR_MODE_ISO18092 (5<<5)
|
||||
#define FPGA_HF_ISO18092_FLAG_NOMOD (1<<0) //disable modulation module
|
||||
#define FPGA_HF_ISO18092_FLAG_424K (2<<0) // should enable 414k mode (untested). No autodetect
|
||||
#define FPGA_HF_ISO18092_FLAG_READER (4<<0) // enables antenna power, to act as a reader instead of tag
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -266,14 +266,27 @@ uint8_t fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, bool verbose, int *f
|
|||
}
|
||||
|
||||
//test samples are not just noise
|
||||
// By measuring mean and look at amplitude of signal from HIGH / LOW,
|
||||
// we can detect noise
|
||||
bool is_justnoise(int *bits, uint32_t size) {
|
||||
//might not be high enough for noisy environments
|
||||
#define NOICE_THRESHOLD 15;
|
||||
#define NOICE_AMPLITUDE_THRESHOLD 10;
|
||||
|
||||
// if we take the mean on the sample set and see if its
|
||||
// below the threshold, it will be a better indicator
|
||||
int32_t mean = compute_mean_int(bits, size);
|
||||
return mean < NOICE_THRESHOLD;
|
||||
uint32_t sum = 0, mean = 0, high = 0, low = 255;
|
||||
for ( size_t i = 0; i < size; i++) {
|
||||
if ( bits[i] < low ) low = bits[i];
|
||||
if ( bits[i] > high ) high = bits[i];
|
||||
sum += bits[i];
|
||||
}
|
||||
|
||||
mean = sum / size;
|
||||
// measure amplitude of signal
|
||||
bool isnoise = (high - mean) < NOICE_AMPLITUDE_THRESHOLD;
|
||||
|
||||
if (g_debugMode == 2)
|
||||
PrintAndLog("DEBUG: (is_justnoise) mean %u | hi %u | low %u | IS NOISE %c", mean, high, low, isnoise?'Y':'N');
|
||||
|
||||
return isnoise;
|
||||
|
||||
/*
|
||||
bool isNoise = true;
|
||||
|
|
|
@ -66,7 +66,8 @@ uint32_t compute_mean_uint(uint8_t *in, size_t N) {
|
|||
uint32_t mean = 0;
|
||||
for (size_t i = 0; i < N; i++)
|
||||
mean += in[i];
|
||||
return (uint32_t)mean/N;
|
||||
|
||||
return mean / N;
|
||||
}
|
||||
// Function to compute mean for a series
|
||||
// rounded to integer..
|
||||
|
@ -74,22 +75,33 @@ int32_t compute_mean_int(int *in, size_t N) {
|
|||
int32_t mean = 0;
|
||||
for (size_t i = 0; i < N; i++)
|
||||
mean += in[i];
|
||||
return (int32_t)mean/N;
|
||||
|
||||
return mean / (int)N;
|
||||
}
|
||||
|
||||
//test samples are not just noise
|
||||
// By measuring mean and look at amplitude of signal from HIGH / LOW,
|
||||
// we can detect noise
|
||||
bool justNoise(uint8_t *bits, size_t size) {
|
||||
|
||||
// if we take the mean on the sample set and see if its
|
||||
// below the threshold, it will be a better indicator
|
||||
uint32_t mean = compute_mean_uint(bits, size);
|
||||
uint8_t counter = 0;
|
||||
for ( size_t i = 0; i < size && counter < 10; i++) {
|
||||
if ( bits[i] > mean ) counter++;
|
||||
}
|
||||
if (g_debugMode == 2) prnt("DEBUG: (justNoise) mean %u | %i | counter %u", mean, FSK_PSK_THRESHOLD, counter);
|
||||
return counter < 10;
|
||||
//might not be high enough for noisy environments
|
||||
#define NOICE_AMPLITUDE_THRESHOLD 10;
|
||||
|
||||
uint32_t sum = 0, mean = 0, high = 0, low = 255;
|
||||
for ( size_t i = 0; i < size; i++) {
|
||||
if ( bits[i] < low ) low = bits[i];
|
||||
if ( bits[i] > high ) high = bits[i];
|
||||
sum += bits[i];
|
||||
}
|
||||
|
||||
mean = sum / size;
|
||||
// measure amplitude of signal
|
||||
bool isnoise = (high - mean) < NOICE_AMPLITUDE_THRESHOLD;
|
||||
|
||||
if (g_debugMode == 2)
|
||||
prnt("DEBUG: (justNoise) mean %u | hi %u | low %u | IS NOISE %c", mean, high, low, isnoise?'Y':'N');
|
||||
|
||||
return isnoise;
|
||||
/*
|
||||
// loop until a sample is larger than threshold.
|
||||
// one sample above threshold is not a good indicator.
|
||||
|
|
Loading…
Reference in a new issue