Skip to content

Commit

Permalink
Fix -inf value in noise dB calc
Browse files Browse the repository at this point in the history
  • Loading branch information
zuckschwerdt committed Jan 27, 2019
1 parent cce293c commit 6ab7b46
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rtl_433.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ static void calc_rssi_snr(r_cfg_t *cfg, pulse_data_t *pulse_data)
// NOTE: for (CU8) amplitude is 10x (because it's squares)
if (cfg->demod->sample_size == 1) { // amplitude (CU8)
pulse_data->rssi_db = 10.0f * log10f(pulse_data->ook_high_estimate) - 42.1442f; // 10*log10f(16384.0f)
pulse_data->noise_db = 10.0f * log10f(pulse_data->ook_low_estimate) - 42.1442f; // 10*log10f(16384.0f)
pulse_data->noise_db = 10.0f * log10f(pulse_data->ook_low_estimate + 1) - 42.1442f; // 10*log10f(16384.0f)
pulse_data->snr_db = 10.0f * log10f(asnr);
} else { // magnitude (CS16)
pulse_data->rssi_db = 20.0f * log10f(pulse_data->ook_high_estimate) - 84.2884f; // 20*log10f(16384.0f)
pulse_data->noise_db = 20.0f * log10f(pulse_data->ook_low_estimate) - 84.2884f; // 20*log10f(16384.0f)
pulse_data->noise_db = 20.0f * log10f(pulse_data->ook_low_estimate + 1) - 84.2884f; // 20*log10f(16384.0f)
pulse_data->snr_db = 20.0f * log10f(asnr);
}
}
Expand Down

0 comments on commit 6ab7b46

Please sign in to comment.