Skip to content

RF Sentinel (RFSentinel): free, open-source police detector app for Android. Spots police body cams, Flock ALPR cameras, AirTag trackers, Remote ID drones, smart glasses and fake cell towers from Bluetooth LE and WiFi. No root.

Radio sensitivity goes down to 6 dB above the noise (for testing how far a TETRA radio carries); weak TETRA bursts count at low settings

CIS-C012a021db3337
diff --git a/app/src/main/java/com/rfsentinel/app/sdr/RadioWatch.kt b/app/src/main/java/com/rfsentinel/app/sdr/RadioWatch.kt
index 178d353..588eae0 100644
--- a/app/src/main/java/com/rfsentinel/app/sdr/RadioWatch.kt
+++ b/app/src/main/java/com/rfsentinel/app/sdr/RadioWatch.kt
@@ -114,13 +114,14 @@ class RadioWatch {
q - floor
}
snr = maxOf(snr, levels.max().roundToInt())
- tdma = isTdma(levels, bursts.groupMs)
+ tdma = isTdma(levels, bursts.groupMs, activeDb(cfg.minSnrDb))
}
val ch = channels.getOrPut(f) { Channel() }
val active = snr >= ACTIVE_DB
ch.recent = (ch.recent shl 1) or (if (active) 1L else 0L)
ch.visits++
- if (active) eventFor(f, snr, band, ch, now, cfg.minSnrDb, tdma)?.let { found += it }
+ // The busy-channel learning keeps the fixed level; a low sensitivity setting only reports weaker radios.
+ if (snr >= activeDb(cfg.minSnrDb)) eventFor(f, snr, band, ch, now, cfg.minSnrDb, tdma)?.let { found += it }
}
f += STEP_HZ
}
@@ -134,7 +135,7 @@ class RadioWatch {
for (k in mid - half..mid + half) if (k in 0 until n && psdDb[k] > p) p = psdDb[k]
val snr = (p - floor).roundToInt()
val st = targetState.getOrPut(t.freqHz) { Channel() }
- if (snr < maxOf(ACTIVE_DB, cfg.minSnrDb - 10)) continue
+ if (snr < maxOf(activeDb(cfg.minSnrDb), cfg.minSnrDb - 10)) continue
found += Event(t.freqHz, snr, Band(t.label, t.freqHz, t.freqHz, Kind.TARGET), TARGET_CONFIDENCE, t,
repeat = now - st.lastEvent < REPEAT_MS)
}
@@ -225,6 +226,11 @@ class RadioWatch {
/** Around a chunk's centre the receiver's own DC spike hides everything. */
const val DC_GUARD_HZ = 15_000L
private const val ACTIVE_DB = 12
+ /** The lowest sensitivity setting: weaker than this is lost in the noise's own flicker. */
+ const val MIN_SNR_SETTING = 6
+ const val MAX_SNR_SETTING = 50
+ /** Above the noise a signal must be to count as on: lower only when the sensitivity setting is below 15 dB. */
+ fun activeDb(minSnr: Int) = minOf(ACTIVE_DB, minSnr - 3).coerceAtLeast(MIN_SNR_SETTING - 3)
private const val SPLATTER_HZ = 37_500L
private const val BUSY_RATIO = 0.4
private const val MIN_VISITS_BUSY = 6
@@ -271,12 +277,12 @@ class RadioWatch {
* [groupMs]): on for about one TETRA slot at a time, and truly off in between - not a carrier
* that stays on, and not noise. Also true for 2 slots of a frame, as a data call may use.
*/
- fun isTdma(levels: FloatArray, groupMs: Double): Boolean {
+ fun isTdma(levels: FloatArray, groupMs: Double, active: Int = ACTIVE_DB): Boolean {
if (levels.size * groupMs < FRAME_MS * 0.9) return false
val peak = levels.max()
- if (peak < ACTIVE_DB + 6) return false
- val on = BooleanArray(levels.size) { levels[it] >= peak - 10 && levels[it] >= ACTIVE_DB }
- val quiet = levels.count { it <= 6f }
+ if (peak < active + 6) return false
+ val on = BooleanArray(levels.size) { levels[it] >= peak - 10 && levels[it] >= active }
+ val quiet = levels.count { it <= minOf(6, active + 2) }
var run = 0; var longest = 0; var runs = 0
for (i in on.indices) {
if (on[i]) { run++; if (run == 1) runs++; longest = maxOf(longest, run) } else run = 0
diff --git a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt
index 4c89b66..0cf81c0 100644
--- a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt
@@ -1160,10 +1160,13 @@ class SettingsActivity : AppCompatActivity() {
switch("ADS-B aircraft receiver", Prefs.sdrAdsb(this),
"Listens on 1090 MHz for aircraft instead of sweeping the radio bands. Police aircraft are found without internet. " +
"Needs Police aircraft turned on. A 1090 MHz antenna helps; the stock one hears out to about 50 km.") { Prefs.setSdrAdsb(this, it) }
- slider(15, 50, Prefs.radioMinSnr(this), { "Sensitivity: $it dB above the noise" }) {
+ slider(com.rfsentinel.app.sdr.RadioWatch.MIN_SNR_SETTING, com.rfsentinel.app.sdr.RadioWatch.MAX_SNR_SETTING, Prefs.radioMinSnr(this),
+ { "Sensitivity: $it dB above the noise" }) {
Prefs.setRadioMinSnr(this, it)
}
- info(box.getChildAt(box.childCount - 2), "A radio is reported once its signal is this far above the noise. Lower hears farther, with more false alarms.", "Sensitivity")
+ info(box.getChildAt(box.childCount - 2), "A radio is reported once its signal is this far above the noise. Lower hears farther, with more false alarms. " +
+ "Below about 10 dB the noise's own flicker sets off some alerts: good for testing how far a known radio carries " +
+ "(a fire station's TETRA, say), noisy for everyday use.", "Sensitivity")
label("Bands to sweep")
val off = Prefs.radioBandsOff(this).toMutableSet()
for ((key, band) in com.rfsentinel.app.sdr.RadioSettings.BUILT_IN) {
diff --git a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt
index e4e9ae2..b3b0116 100644
--- a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt
+++ b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt
@@ -487,8 +487,10 @@ object Prefs {
private fun setStr(c: Context, key: String, v: String) = sp(c).edit { putString(key, v) }
/** Report a radio from this many dB above the noise (15-50; 30 = the original sensitivity). */
- fun radioMinSnr(context: Context): Int = int(context, "radio_min_snr", com.rfsentinel.app.sdr.RadioWatch.DEFAULT_MIN_SNR).coerceIn(15, 50)
- fun setRadioMinSnr(context: Context, v: Int) = setInt(context, "radio_min_snr", v.coerceIn(15, 50))
+ fun radioMinSnr(context: Context): Int = int(context, "radio_min_snr", com.rfsentinel.app.sdr.RadioWatch.DEFAULT_MIN_SNR)
+ .coerceIn(com.rfsentinel.app.sdr.RadioWatch.MIN_SNR_SETTING, com.rfsentinel.app.sdr.RadioWatch.MAX_SNR_SETTING)
+ fun setRadioMinSnr(context: Context, v: Int) = setInt(context, "radio_min_snr",
+ v.coerceIn(com.rfsentinel.app.sdr.RadioWatch.MIN_SNR_SETTING, com.rfsentinel.app.sdr.RadioWatch.MAX_SNR_SETTING))
/** Built-in bands switched off ("700", "800", "vhf", "uhf"). */
fun radioBandsOff(context: Context): Set<String> = sp(context).getStringSet("radio_bands_off", emptySet()).orEmpty()