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.

Easier device identification

CIS-C07afdbf295ce7
diff --git a/app/src/main/assets/vendors/fast_pair.tsv b/app/src/main/assets/vendors/fast_pair.tsv
new file mode 100644
index 0000000..3e53564
--- /dev/null
+++ b/app/src/main/assets/vendors/fast_pair.tsv
@@ -0,0 +1,459 @@
+# Google Fast Pair model IDs of shipping products (hex, name). Source: the genuine-device list in Momentum-Apps ble_spam/protocols/fastpair.c (GPL-3.0, @Willy-JL, @Spooks4576)
+CD8256 Bose NC 700
+0000F0 Bose QuietComfort 35 II
+821F66 JBL Flip 6
+F52494 JBL Buds Pro
+718FA4 JBL Live 300TWS
+0002F0 JBL Everest 110GA
+92BBBD Pixel Buds
+000006 Google Pixel buds
+D446A7 Sony XM5
+2D7A23 Sony WF-1000XM4
+0E30C3 Razer Hammerhead TWS
+72EF8D Razer Hammerhead TWS X
+72FB00 Soundcore Spirit Pro GVA
+0003F0 LG HBS-835S
+002000 AIAIAI TMA-2 (H60)
+003000 Libratone Q Adapt On-Ear
+003001 Libratone Q Adapt On-Ear 2
+00A168 boAt Airdopes 621
+00AA48 Jabra Elite 2
+00AA91 Beoplay E8 2.0
+00C95C Sony WF-1000X
+01EEB4 WH-1000XM4
+02AA91 B&O Earset
+01C95C Sony WF-1000X
+02D815 ATH-CK1TW
+035764 PLT V8200 Series
+038CC7 JBL TUNE760NC
+02DD4F JBL TUNE770NC
+02E2A9 TCL MOVEAUDIO S200
+035754 Plantronics PLT_K2
+02C95C Sony WH-1000XM2
+038B91 DENON AH-C830NCW
+02F637 JBL LIVE FLEX
+02D886 JBL REFLECT MINI NC
+F00001 Bose QuietComfort 35 II
+F00201 JBL Everest 110GA
+F00204 JBL Everest 310GA
+F00209 JBL LIVE400BT
+F00205 JBL Everest 310GA
+F00200 JBL Everest 110GA
+F00208 JBL Everest 710GA
+F00207 JBL Everest 710GA
+F00206 JBL Everest 310GA
+F0020A JBL LIVE400BT
+F0020B JBL LIVE400BT
+F0020C JBL LIVE400BT
+F00203 JBL Everest 310GA
+F00202 JBL Everest 110GA
+F00213 JBL LIVE650BTNC
+F0020F JBL LIVE500BT
+F0020E JBL LIVE500BT
+F00214 JBL LIVE650BTNC
+F00212 JBL LIVE500BT
+F0020D JBL LIVE400BT
+F00211 JBL LIVE500BT
+F00215 JBL LIVE650BTNC
+F00210 JBL LIVE500BT
+F00305 LG HBS-1500
+F00304 LG HBS-1010
+F00308 LG HBS-1125
+F00303 LG HBS-930
+F00306 LG HBS-1700
+F00300 LG HBS-835S
+F00309 LG HBS-2000
+F00302 LG HBS-830
+F00307 LG HBS-1120
+F00301 LG HBS-835
+F00E97 JBL VIBE BEAM
+04ACFC JBL WAVE BEAM
+04AA91 Beoplay H4
+04AFB8 JBL TUNE 720BT
+05A963 WONDERBOOM 3
+05AA91 B&O Beoplay E6
+05C452 JBL LIVE220BT
+05C95C Sony WI-1000X
+0602F0 JBL Everest 310GA
+0603F0 LG HBS-1700
+1E8B18 SRS-XB43
+1E955B WI-1000XM2
+1EC95C Sony WF-SP700N
+1ED9F9 JBL WAVE FLEX
+1EE890 ATH-CKS30TW WH
+1EEDF5 Teufel REAL BLUE TWS 3
+1F1101 TAG Heuer Calibre E4 45mm
+1F181A LinkBuds S
+1F2E13 Jabra Elite 2
+1F4589 Jabra Elite 2
+1F4627 SRS-XG300
+1F5865 boAt Airdopes 441
+1FBB50 WF-C700N
+1FC95C Sony WF-SP700N
+1FE765 TONE-TF7Q
+1FF8FA JBL REFLECT MINI NC
+201C7C SUMMIT
+202B3D Amazfit PowerBuds
+20330C SRS-XB33
+003B41 M&D MW65
+003D8A Cleer FLOW II
+005BC3 Panasonic RP-HD610N
+008F7D soundcore Glow Mini
+00FA72 Pioneer SE-MS9BN
+0100F0 Bose QuietComfort 35 II
+011242 Nirvana Ion
+013D8A Cleer EDGE Voice
+01AA91 Beoplay H9 3rd Generation
+038F16 Beats Studio Buds
+039F8F Michael Kors Darci 5e
+03AA91 B&O Beoplay H8i
+03B716 YY2963
+03C95C Sony WH-1000XM2
+03C99C MOTO BUDS 135
+03F5D4 Writing Account Key
+045754 Plantronics PLT_K2
+045764 PLT V8200 Series
+04C95C Sony WI-1000X
+050F0C Major III Voice
+052CC7 MINOR III
+057802 TicWatch Pro 5
+0582FD Pixel Buds
+058D08 WH-1000XM4
+06AE20 Galaxy S21 5G
+06C197 OPPO Enco Air3 Pro
+06C95C Sony WH-1000XM2
+06D8FC soundcore Liberty 4 NC
+0744B6 Technics EAH-AZ60M2
+07A41C WF-C700N
+07C95C Sony WH-1000XM2
+07F426 Nest Hub Max
+0102F0 JBL Everest 110GA - Gun Metal
+0202F0 JBL Everest 110GA - Silver
+0302F0 JBL Everest 310GA - Brown
+0402F0 JBL Everest 310GA - Gun Metal
+0502F0 JBL Everest 310GA - Silver
+0702F0 JBL Everest 710GA - Gun Metal
+0802F0 JBL Everest 710GA - Silver
+054B2D JBL TUNE125TWS
+0660D7 JBL LIVE770NC
+0103F0 LG HBS-835
+0203F0 LG HBS-830
+0303F0 LG HBS-930
+0403F0 LG HBS-1010
+0503F0 LG HBS-1500
+0703F0 LG HBS-1120
+0803F0 LG HBS-1125
+0903F0 LG HBS-2000
+070000 Android Auto
+071C74 JBL Flip 6
+080000 Foocorp Foophones
+0B0000 Google Gphones
+0C0000 Google Gphones
+0DC95C Sony WH-1000XM3
+0DEC2B Emporio Armani EA Connected
+0E138D WF-SP800N
+0EC95C Sony WI-C600N
+0ECE95 Philips TAT3508
+0F0993 COUMI TWS-834A
+0F1B8D JBL VIBE BEAM
+0F232A JBL TUNE BUDS
+0F2D16 WH-CH520
+20A19B WF-SP800N
+20C95C Sony WF-SP700N
+20CC2C SRS-XB43
+213C8C DIZO Wireless Power
+21521D boAt Rockerz 355 (Green)
+21A04E oraimo FreePods Pro
+470000 Arduino 101
+480000 Fast Pair Headphones
+490000 Fast Pair Headphones
+5BA9B5 WF-SP800N
+5BACD6 Bose QC Ultra Earbuds
+5BD6C9 JBL TUNE225TWS
+5BE3D4 JBL Flip 6
+5C0206 UA | JBL TWS STREAK
+5C0C84 JBL TUNE225TWS
+5C4833 WH-CH720N
+5C4A7E LG HBS-XL7
+5C55E7 TCL MOVEAUDIO S200
+5C7CDC WH-1000XM5
+5C8AA5 JBL LIVE220BT
+5CC900 Sony WF-1000X
+5CC901 Sony WF-1000X
+5CC902 Sony WH-1000XM2
+5CC903 Sony WH-1000XM2
+5CC904 Sony WI-1000X
+5CC905 Sony WI-1000X
+5CC906 Sony WH-1000XM2
+5CC907 Sony WH-1000XM2
+5CC908 Sony WI-1000X
+5CC909 Sony WI-1000X
+5CC90A Sony WH-1000XM3
+5CC90B Sony WH-1000XM3
+5CC90C Sony WH-1000XM3
+5CC90D Sony WH-1000XM3
+5CC90E Sony WI-C600N
+5CC90F Sony WI-C600N
+5CC910 Sony WI-C600N
+5CC911 Sony WI-C600N
+5CC912 Sony WI-C600N
+5CC913 Sony WI-C600N
+5CC914 Sony WI-SP600N
+5CC915 Sony WI-SP600N
+5CC916 Sony WI-SP600N
+5CC917 Sony WI-SP600N
+5CC918 Sony WI-SP600N
+5CC919 Sony WI-SP600N
+5CC91A Sony WI-SP600N
+5CC91B Sony WI-SP600N
+5CC91C Sony WI-SP600N
+5CC91D Sony WI-SP600N
+5CC91E Sony WF-SP700N
+5CC91F Sony WF-SP700N
+5CC920 Sony WF-SP700N
+5CC921 Sony WF-SP700N
+5CC922 Sony WF-SP700N
+5CC923 Sony WF-SP700N
+5CC924 Sony WF-SP700N
+5CC925 Sony WF-SP700N
+5CC926 Sony WF-SP700N
+5CC927 Sony WF-SP700N
+5CC928 Sony WH-H900N
+5CC929 Sony WH-H900N
+5CC92A Sony WH-H900N
+5CC92B Sony WH-H900N
+5CC92C Sony WH-H900N
+5CC92D Sony WH-H900N
+5CC92E Sony WH-H900N
+5CC92F Sony WH-H900N
+5CC930 Sony WH-H900N
+5CC931 Sony WH-H900N
+5CC932 Sony WH-CH700N
+5CC933 Sony WH-CH700N
+5CC934 Sony WH-CH700N
+5CC935 Sony WH-CH700N
+5CC936 Sony WH-CH700N
+5CC937 Sony WH-CH700N
+5CC938 Sony WF-1000XM3
+5CC939 Sony WF-1000XM3
+5CC93A Sony WF-1000XM3
+5CC93B Sony WF-1000XM3
+5CC93C Sony WH-XB700
+5CC93D Sony WH-XB700
+5CC93E Sony WH-XB700
+5CC93F Sony WH-XB700
+5CC940 Sony WH-XB900N
+5CC941 Sony WH-XB900N
+5CC942 Sony WH-XB900N
+5CC943 Sony WH-XB900N
+5CC944 Sony WH-XB900N
+5CC945 Sony WH-XB900N
+5CEE3C Fitbit Charge 4
+6AD226 TicWatch Pro 3
+6B1C64 Pixel Buds
+6B8C65 oraimo FreePods 4
+6B9304 Nokia SB-101
+6BA5C3 Jabra Elite 4
+6C42C0 TWS05
+6C4DE5 JBL LIVE PRO 2 TWS
+89BAD5 Galaxy A23 5G
+8A31B7 Bose QC Ultra Headphones
+8A3D00 Cleer FLOW Ⅱ
+8A3D01 Cleer EDGE Voice
+8A8F23 WF-1000XM5
+8AADAE JLab GO Work 2
+8B0A91 Jabra Elite 5
+8B5A7B TicWatch Pro 3 GPS
+8B66AB Pixel Buds A-Series
+8BB0A0 Nokia Solo Bud+
+8BF79A Oladance Whisper E1
+8C07D2 Jabra Elite 4 Active
+8C1706 YY7861E
+8C4236 GLIDiC mameBuds
+8C6B6A realme Buds Air 3S
+8CAD81 KENWOOD WS-A1
+8CB05C JBL LIVE PRO+ TWS
+8CD10F realme Buds Air Pro
+8D13B9 BLE-TWS
+8D16EA Galaxy M14 5G
+8D5B67 Pixel 90c
+8E14D7 LG-TONE-TFP8
+8E1996 Galaxy A24 5g
+8E4666 Oladance Wearable Stereo
+8E5550 boAt Airdopes 511v2
+9101F0 Jabra Elite 2
+9128CB TCL MOVEAUDIO Neo
+913B0C YH-E700B
+915CFA Galaxy A14
+9171BE Jabra Evolve2 65 Flex
+917E46 LinkBuds
+91AA00 Beoplay E8 2.0
+91AA01 Beoplay H9 3rd Generation
+91AA02 B&O Earset
+91AA03 B&O Beoplay H8i
+91AA04 Beoplay H4
+91AA05 B&O Beoplay E6
+91BD38 LG HBS-FL7
+91C813 JBL TUNE770NC
+91DABC SRS-XB33
+92255E LG-TONE-FP6
+989D0A Set up your new Pixel 2
+9939BC ATH-SQ1TW
+994374 EDIFIER W320TN
+997B4A UA | JBL True Wireless Flash X
+99C87B WH-H810 (h.ear)
+99D7EA oraimo OpenCirclet
+99F098 Galaxy S22 Ultra
+9A408A MOTO BUDS 065
+9A9BDD WH-XB910N
+9ADB11 Pixel Buds Pro
+9AEEA4 LG HBS-FN4
+9B7339 AKG N9 Hybrid
+9B735A JBL RFL FLOW PRO
+9B9872 Hyundai
+9BC64D JBL TUNE225TWS
+9BE931 WI-C100
+9C0AF7 JBL VIBE BUDS
+9C3997 ATH-M50xBT2
+9C4058 JBL WAVE FLEX
+9C6BC0 LinkBuds S
+9C888B WH-H910N (h.ear)
+9C98DB JBL TUNE225TWS
+9CA277 YY2963
+9CB5F3 WH-1000XM5
+9CB881 soundcore Motion 300
+9CD0F3 LG HBS-TFN7
+9CE3C7 EDIFIER NeoBuds Pro 2
+9CEFD1 SRS-XG500
+9CF08F JLab Epic Air ANC
+9D00A6 Urbanears Juno
+9D7D42 Galaxy S20
+9DB896 Your BMW
+A7E52B Bose NC 700 Headphones
+A7EF76 JBL CLUB PRO+ TWS
+A8001A JBL CLUB ONE
+A83C10 adidas Z.N.E. 01
+A8658F ROCKSTER GO
+A8845A oraimo FreePods 4
+A88B69 WF-SP800N
+A8A00E Nokia CB-201
+A8A72A JBL LIVE670NC
+A8C636 JBL TUNE660NC
+A8CAAD Galaxy F04
+A8E353 JBL TUNE BEAM
+A8F96D JBL ENDURANCE RUN 2 WIRELESS
+A90358 JBL LIVE220BT
+A92498 JBL WAVE BUDS
+A9394A JBL TUNE230NC TWS
+C6936A JBL LIVE PRO+ TWS
+C69AFD WF-H800 (h.ear)
+C6ABEA UA | JBL True Wireless Flash X
+C6EC5F SRS-XE300
+C7736C Philips PH805
+C79B91 Jabra Evolve2 75
+C7D620 JBL Pulse 5
+C7FBCC JBL VIBE FLEX
+C8162A LinkBuds S
+C85D7A JBL ENDURANCE PEAK II
+C8777E Jaybird Vista 2
+C878AA SRS-XV800
+C8C641 Redmi Buds 4 Lite
+C8D335 WF-1000XM4
+C8E228 Pixel Buds Pro
+C9186B WF-1000XM4
+C9836A JBL Xtreme 4
+CA7030 ATH-TWX7
+CAB6B8 ATH-M20xBT
+CAF511 Jaybird Vista 2
+CB093B Urbanears Juno
+CB529D soundcore Glow
+CC438E WH-1000XM4
+CC5F29 JBL TUNE660NC
+CC754F YY2963
+CC93A5 Sync
+CCBB7E MIDDLETON
+D5A59E Jabra Elite Speaker
+D5B5F7 MOTO BUDS 600 ANC
+D5C6CE realme TechLife Buds T100
+D654CD JBL Xtreme 4
+D65F4E Philips Fidelio T2
+D69B2B TONE-T80S
+D6C195 LG HBS-SL5
+D6E870 Beoplay EX
+D6EE84 Rockerz 255 Max
+D7102F ATH-SQ1TW SVN
+D7E3EB Cleer HALO
+D8058C MOTIF II A.N.C.
+D820EA WH-XB910N
+D87A3E Pixel Buds Pro
+D8F3BA WH-1000XM5
+D8F4E8 realme Buds T100
+D90617 Redmi Buds 4 Active
+D933A7 JBL ENDURANCE PEAK 3
+D9414F JBL SOUNDGEAR SENSE
+D97EBA JBL TUNE125TWS
+D9964B JBL TUNE670NC
+DA0F83 SPACE
+DA4577 Jabra Elite 4 Active
+DA5200 blackbox TRIP II
+DAD3A6 Jabra Elite 10
+DADE43 Chromebox
+DAE096 adidas RPT-02 SOL
+DB8AC7 LG TONE-FREE
+DBE5B1 WF-1000XM4
+DC5249 WH-H810 (h.ear)
+DCF33C JBL REFLECT MINI NC
+DD4EC0 OPPO Enco Air3 Pro
+DE215D WF-C500
+DE577F Teufel AIRY TWS 2
+DEC04C SUMMIT
+DEDD6F soundcore Space One
+DEE8C0 Ear (2)
+DEEA86 Xiaomi Buds 4 Pro
+DEF234 WH-H810 (h.ear)
+DF01E3 Sync
+DF271C Big Bang e Gen 3
+DF42DE TAG Heuer Calibre E4 42mm
+DF4B02 SRS-XB13
+DF9BA4 Bose NC 700 Headphones
+DFD433 JBL REFLECT AERO
+E020C1 soundcore Motion 300
+E06116 LinkBuds S
+E07634 OnePlus Buds Z
+E09172 JBL TUNE BEAM
+E4E457 Galaxy S20 5G
+E5440B TAG Heuer Calibre E4 45mm
+E57363 Oladance Wearable Stereo
+E5B4B0 WF-1000XM5
+E5B91B SRS-XB33
+E5E2E9 Zone Wireless 2
+E64613 JBL WAVE BEAM
+E64CC6 Set up your new Pixel 3 XL
+E69877 JBL REFLECT AERO
+E6E37E realme Buds Air 5 Pro
+E6E771 ATH-CKS50TW
+E6E8B8 POCO Pods
+E750CE Jabra Evolve2 75
+00000C Google Gphones
+000049 Fast Pair Headphones
+0052DA blackbox TRIP II
+109201 Beoplay H9 3rd Generation
+124366 BLE-Phone
+126644 WH-1000XM4
+284500 Plantronics PLT_K2
+532011 Big Bang e Gen 3
+549547 JBL WAVE BUDS
+567679 Pixel Buds Pro
+575836 Sony WI-1000X
+596007 MOTIF II A.N.C.
+612907 Redmi Buds 4 Lite
+614199 Oraimo FreePods Pro
+625740 LG-TONE-NP3
+641372 Sony WI-1000X
+641630 boAt Airdopes 452
+664454 JBL TUNE 520BT
+706908 Sony WH-1000XM3
+837980 Sony WH-1000XM3
+855347 NIRVANA NEBULA
+861698 LinkBuds
+CB2FE7 soundcore Motion X500
diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.kt
index 193f7a8..4bbd41e 100644
--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt
@@ -982,6 +982,7 @@ class MainActivity : AppCompatActivity() {
else -> radioTag(s)
}
val alias = com.rfsentinel.app.data.DeviceNames.of(s.mac)
+ val lookalike = com.rfsentinel.app.data.DeviceNames.lookalike(s.mac, DeviceRegistry.fingerprintOf(s.mac))
return DeviceRow(
mac = s.mac,
title = alias ?: best?.label ?: s.name ?: s.deviceType,
@@ -990,6 +991,7 @@ class MainActivity : AppCompatActivity() {
// Under your own name, what it's heard as comes first.
if (alias != null) best?.label ?: s.name?.let { "\"$it\"" } ?: s.deviceType
else if (best != null && s.name != null) "\"${s.name}\"" else s.deviceType,
+ lookalike?.let { "like your \"$it\"" },
// Ordinary rows name the radio in their tag; flagged ones keep it here.
if (tag == radioTag(s)) null else s.sources.joinToString("+") { if (it == Advert.Source.BLE) "BLE" else "WiFi" },
"${ProximityUtil.band(s.rssi)} ${s.rssi} dBm ${DeviceIntel.formatDistance(s.distanceM)}",
diff --git a/app/src/main/java/com/rfsentinel/app/data/DeviceNames.kt b/app/src/main/java/com/rfsentinel/app/data/DeviceNames.kt
index c05160d..efc2797 100644
--- a/app/src/main/java/com/rfsentinel/app/data/DeviceNames.kt
+++ b/app/src/main/java/com/rfsentinel/app/data/DeviceNames.kt
@@ -1,24 +1,50 @@
package com.rfsentinel.app.data
import android.content.Context
+import com.rfsentinel.app.detect.AdvertFingerprint
/** Your own names for devices (known_devices.alias), kept in memory so the list and map needn't read the database per device. */
object DeviceNames {
+ private const val PREFS = "device_names"
+ private const val KEY_LOOKS = "looks"
+
@Volatile private var names: Map<String, String> = emptyMap()
+ /** Advert fingerprint hash ([AdvertFingerprint.hash]) of each named device -> its address, to spot it under a new address. */
+ @Volatile private var looks: Map<String, String> = emptyMap()
/** Your name for [mac], or null. */
fun of(mac: String): String? = names[mac]
+ /**
+ * Your name for another device whose adverts look exactly like this one's ([fingerprint], see
+ * [AdvertFingerprint.of]): most likely the same device under a new address, or one of the same model.
+ * Null when [mac] has a name of its own or nothing matches.
+ */
+ fun lookalike(mac: String, fingerprint: String?): String? {
+ if (fingerprint == null || mac in names) return null
+ val named = looks[AdvertFingerprint.hash(fingerprint)]?.takeIf { it != mac } ?: return null
+ return names[named]
+ }
+
suspend fun load(context: Context) {
names = AppDatabase.getInstance(context).knownDeviceDao().aliases().associate { it.mac to it.alias }
+ looks = context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getStringSet(KEY_LOOKS, null).orEmpty()
+ .mapNotNull { e -> e.split('=', limit = 2).takeIf { it.size == 2 }?.let { it[0] to it[1] } }.toMap()
}
- /** Names (or, with a blank [alias], un-names) a device, creating its history row if it hasn't been flushed yet. */
- suspend fun set(context: Context, mac: String, alias: String?, name: String?, vendor: String?, type: String?) {
+ /**
+ * Names (or, with a blank [alias], un-names) a device, creating its history row if it hasn't been flushed yet.
+ * Its advert [fingerprint], when it has one, is kept with the name so [lookalike] finds it again.
+ */
+ suspend fun set(context: Context, mac: String, alias: String?, name: String?, vendor: String?, type: String?, fingerprint: String? = null) {
val clean = alias?.trim()?.take(64)?.ifEmpty { null }
ensureRow(context, mac, name, vendor, type)
AppDatabase.getInstance(context).knownDeviceDao().setAlias(mac, clean)
names = if (clean != null) names + (mac to clean) else names - mac
+ val kept = looks.filterValues { it != mac }
+ looks = if (clean != null && fingerprint != null) kept + (AdvertFingerprint.hash(fingerprint) to mac) else kept
+ context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()
+ .putStringSet(KEY_LOOKS, looks.map { "${it.key}=${it.value}" }.toSet()).apply()
}
/** Saves your note on a device ([note] blank clears it). */
diff --git a/app/src/main/java/com/rfsentinel/app/detect/AdvertFingerprint.kt b/app/src/main/java/com/rfsentinel/app/detect/AdvertFingerprint.kt
index 9ab5f1e..4276d2a 100644
--- a/app/src/main/java/com/rfsentinel/app/detect/AdvertFingerprint.kt
+++ b/app/src/main/java/com/rfsentinel/app/detect/AdvertFingerprint.kt
@@ -34,10 +34,13 @@ object AdvertFingerprint {
* [of] as a short key for the watchlist ("adv:" rules): 8 hex digits (FNV-1a), the same
* for every advert the device sends, whatever its address. Null when [of] is.
*/
- fun key(a: Advert): String? = of(a)?.let { fp ->
+ fun key(a: Advert): String? = of(a)?.let(::hash)
+
+ /** A fingerprint from [of] as 8 hex digits (FNV-1a). */
+ fun hash(fp: String): String {
var h = 0x811C9DC5.toInt()
for (byte in fp.toByteArray(Charsets.UTF_8)) { h = h xor (byte.toInt() and 0xff); h *= 0x01000193 }
- "%08x".format(h)
+ return "%08x".format(h)
}
/** True when the address type means it's expected to rotate (or unknown on Android < 15). */
diff --git a/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt b/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt
index d578413..5db5841 100644
--- a/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt
+++ b/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt
@@ -58,6 +58,53 @@ object DeviceIntel {
/** Passenger trains' onboard WiFi (Wardrive Go's rail list, plus Deutsche Bahn's ICE network). */
internal val TRAIN_SSID = Regex("amtrak|brightline|eurostar|sncf|wifi_inoui|wifionice|via ?rail|^via[-_ ]?wi-?fi\$", RegexOption.IGNORE_CASE)
+ /**
+ * What a network is, from the default name its maker or internet provider gives it: home routers
+ * by provider (many countries, so a name says what, never where), providers' public hotspots,
+ * mobile hotspot boxes, and gadgets that make their own network (dashcams, drones, cameras, TVs,
+ * devices waiting to be set up). First match wins.
+ */
+ private val SSID_TYPES = listOf(
+ // Providers' public hotspots (before their home-router patterns).
+ "^xfinitywifi$|^xfinity ?mobile$" to "Public WiFi hotspot - Xfinity", "^coxwifi$" to "Public WiFi hotspot - Cox",
+ "^optimumwifi$" to "Public WiFi hotspot - Optimum", "^spectrumwifi( plus)?$" to "Public WiFi hotspot - Spectrum",
+ "^attwifi$" to "Public WiFi hotspot - AT&T", "^btwi-?fi|^bt-?fon$|^btopenzone" to "Public WiFi hotspot - BT",
+ "^shaw ?(open|go|passpoint)" to "Public WiFi hotspot - Shaw", "^telekom(_fon)?$|^telekom_fon" to "Public WiFi hotspot - Telekom",
+ "^vodafone ?(homespot|hotspot|wifi)$" to "Public WiFi hotspot - Vodafone", "^orange$|^freewifi(_secure)?$|^sfr wifi" to "Public WiFi hotspot - French provider",
+ "^_?the cloud$|^virgin ?media ?wifi|^skywifi$" to "Public WiFi hotspot - UK provider",
+ // Mobile hotspot boxes.
+ "^(verizon-)?mifi|^jetpack|^verizon-[a-z0-9]{4,6}-[a-z0-9]{4}$|^nighthawk ?m\\d|^netgear-?m[1-6]\\b|^moxee|^inseego|^t-mobile hotspot|^huawei-e5|^alcatel link|^zte[_-]?mf" to "Mobile hotspot box",
+ // Home routers by provider.
+ "^att(?=.*\\d)[a-z0-9]{6,7}$|^att-?wifi-" to "Home router - AT&T", "^fios-[a-z0-9]{5}$|^verizon_[a-z0-9]{6}$" to "Home router - Verizon",
+ "^spectrum(setup)?-[a-z0-9]{2,4}$|^myspectrumwifi" to "Home router - Spectrum", "^xfinity|^home-[0-9a-f]{4}(-5g)?$" to "Home router - Xfinity",
+ "^centurylink" to "Home router - CenturyLink", "^frontier\\d{3,4}$" to "Home router - Frontier",
+ "^cox-?wifi-" to "Home router - Cox", "^optimum ?\\d|^optimum-" to "Home router - Optimum", "^tmobile ?home|^t-mobile ?home|^tmobile-[0-9a-f]{4}$" to "Home router - T-Mobile",
+ "^bell\\d{3}$" to "Home router - Bell", "^telus\\d{4}" to "Home router - Telus", "^rogers|^ignite ?\\d|^ignite-" to "Home router - Rogers",
+ "^videotron|^helix-?" to "Home router - Videotron", "^shaw-[0-9a-f]{6}" to "Home router - Shaw", "^sasktel" to "Home router - SaskTel",
+ "^cogeco-" to "Home router - Cogeco", "^eastlink" to "Home router - Eastlink", "^virgin ?plus|^virgin-?\\d" to "Home router - Virgin Plus",
+ "^bt-[a-z0-9]{6,7}$|^bthub\\d|^btbhub|^bt ?smart ?hub" to "Home router - BT", "^sky(?=.*\\d)[a-z0-9]{5}$|^sky_?wifi_" to "Home router - Sky",
+ "^vm[0-9a-f]{7}$|^virgin ?media" to "Home router - Virgin Media", "^talktalk" to "Home router - TalkTalk",
+ "^plusnet-" to "Home router - Plusnet", "^ee-[a-z0-9]{5,7}$|^ee-hub|^ee ?smart" to "Home router - EE",
+ "^livebox-" to "Home router - Orange", "^freebox-" to "Home router - Free", "^sfr[-_]|^neufbox" to "Home router - SFR",
+ "^bbox-" to "Home router - Bouygues", "^magentawlan|^wlan-[0-9a-z]{6}$|^speedport" to "Home router - Telekom",
+ "^vodafone-?[0-9a-z]{4,}|^vodafone ?(station|homespot)" to "Home router - Vodafone", "^o2-wlan|^o2 ?homespot" to "Home router - O2",
+ "^movistar_|^miwifi_" to "Home router - Movistar", "^tim-\\d|^telecomitalia" to "Home router - TIM", "^fastweb" to "Home router - Fastweb",
+ "^telstra[0-9a-f]{4}" to "Home router - Telstra", "^optus_" to "Home router - Optus", "^ziggo" to "Home router - Ziggo",
+ "^kpn ?[0-9a-z]{4}|^experiabox" to "Home router - KPN", "^upc\\d{6,7}$" to "Home router - UPC",
+ // Gadgets that make their own network.
+ "^70mai|^viofo|^blackvue|^thinkware|^nextbase|^vantrue|^rexing|^garmin ?dash|^dashcam|^dash ?cam|^roav|^redtiger|^azdome" to "Dashcam",
+ "^gopro|^gp[0-9]{8}$|^hero\\d+|^insta360|^osmo ?action|^akaso" to "Action camera",
+ "^tello-|^dji[-_ ]|^mavic|^spark-|^phantom|^anafi|^skycontroller|^autel|^evo ?ii|^skydio|^parrot" to "Drone / controller",
+ "\\[tv\\]|^direct-[0-9a-z]{2}-(\\[tv\\]|samsung|lg|bravia|tcl|hisense|vizio)|^bravia|^lg[_ ]?(webos)?[_ ]?tv|^vizio|^roku-|^androidtv|^chromecast" to "Smart TV / streaming device",
+ "^esp[-_][0-9a-f]{4,6}$|^esp32|^esp8266|^tasmota-|^shelly|^sonoff|^espressif|^wled-|^openmqttgateway" to "IoT board (ESP / smart-home firmware)",
+ "^tp-?link_smart|^kasa_|^tapo_|^wemo\\.|^meross_|^smartlife-|^smart ?life|^tuya|^gosund|^govee|^wiz_|^hue-" to "Smart plug / bulb waiting to be set up",
+ "^ring setup|^ring-[0-9a-f]{4}|^nest-|^arlo|^blink-|^wyze|^eufy|^reolink|^ipc[-_]|^ezviz|^hikvision|^imou" to "Security camera / doorbell",
+ "^nintendo|^switch_|^ps[45]-|^xbox" to "Game console"
+ ).map { (re, type) -> Regex(re, RegexOption.IGNORE_CASE) to type }
+
+ /** What a network's name says it is ([SSID_TYPES]), or null. */
+ fun ssidType(ssid: String): String? = SSID_TYPES.firstOrNull { it.first.containsMatchIn(ssid.trim()) }?.second
+
/**
* A train's WiFi rides along with you, and its router often comes from the same vehicle-router
* makers police cars use (Cradlepoint, Sierra Wireless): those matches are dropped for it.
@@ -229,6 +276,11 @@ object DeviceIntel {
0x07 in typesIn(d) -> "AirPods / Beats"
0x12 in typesIn(d) -> "Apple Find My device (AirTag, iPhone, Mac...)"
0x09 in typesIn(d) -> "Apple TV / AirPlay speaker"
+ // Only a Watch reports being on a wrist or offers Magic Switch; only a phone drives,
+ // and only a phone or cellular iPad offers its hotspot.
+ 0x0B in typesIn(d) || appleActivity(d) == 0x0A -> "Apple Watch"
+ appleActivity(d) == 0x0D -> "iPhone"
+ 0x0E in typesIn(d) -> "iPhone or cellular iPad"
0x10 in typesIn(d) || 0x0C in typesIn(d) -> "Apple device (iPhone, iPad, Mac or Watch)"
else -> "Apple device"
}
@@ -246,8 +298,16 @@ object DeviceIntel {
}, "Microsoft beacon")
}
}
- if (a.serviceData.keys.any { Advert.shortOf(it) == 0xFE2C }) {
- facts += "Google Fast Pair" to "Pairing / account-key broadcast"
+ a.serviceData.entries.firstOrNull { Advert.shortOf(it.key) == 0xFE2C }?.value?.let { d ->
+ // In pairing mode the service data is just the 3-byte model ID; otherwise an account-key filter.
+ if (d.size == 3) {
+ val model = (Bytes.u8(d, 0) shl 16) or (Bytes.u8(d, 1) shl 8) or Bytes.u8(d, 2)
+ val product = VendorDb.fastPairModel(model)
+ facts += "Google Fast Pair" to "Ready to pair, model ID " + String.format("0x%06X", model) + (product?.let { " ($it)" } ?: "")
+ decide(product, "Fast Pair model ID")
+ } else {
+ facts += "Google Fast Pair" to "Pairing / account-key broadcast"
+ }
}
a.serviceData[Advert.uuid16(0xFEAA)]?.takeIf { it.isNotEmpty() }?.let { d ->
val frame = when (Bytes.u8(d, 0)) {
@@ -287,6 +347,18 @@ object DeviceIntel {
return Identity(type ?: "Bluetooth device", facts)
}
+ /** The activity code (low 4 bits of the status byte) of an Apple Nearby Info message, or null. */
+ private fun appleActivity(d: ByteArray): Int? {
+ var i = 0
+ while (i + 1 < d.size) {
+ val len = Bytes.u8(d, i + 1)
+ if (Bytes.u8(d, i) == 0x10 && len >= 1 && i + 2 < d.size) return Bytes.u8(d, i + 2) and 0x0F
+ if (len == 0) break
+ i += 2 + len
+ }
+ return null
+ }
+
private fun typesIn(d: ByteArray): Set<Int> {
val out = HashSet<Int>()
var i = 0
@@ -322,6 +394,7 @@ object DeviceIntel {
w?.standard == WIFI_AWARE -> "Drone Remote ID over Wi-Fi Aware"
ssid.isNullOrEmpty() -> "Hidden WiFi network"
TRAIN_SSID.containsMatchIn(ssid) -> "Train WiFi (passenger rail)"
+ ssidType(ssid) != null -> ssidType(ssid)!!
Regex("iphone|androidap|galaxy|pixel|hotspot|'s phone", RegexOption.IGNORE_CASE).containsMatchIn(ssid) -> "Phone hotspot"
Regex("direct-|printer|hp-print|epson|canon", RegexOption.IGNORE_CASE).containsMatchIn(ssid) -> "WiFi Direct / printer"
Regex("tesla|carplay|android auto|\\bcar\\b|bmw|mercedes|audi|toyota", RegexOption.IGNORE_CASE).containsMatchIn(ssid) -> "Vehicle WiFi"
diff --git a/app/src/main/java/com/rfsentinel/app/detect/VendorDb.kt b/app/src/main/java/com/rfsentinel/app/detect/VendorDb.kt
index 63e4683..6275055 100644
--- a/app/src/main/java/com/rfsentinel/app/detect/VendorDb.kt
+++ b/app/src/main/java/com/rfsentinel/app/detect/VendorDb.kt
@@ -15,6 +15,7 @@ object VendorDb {
@Volatile private var oui: Map<String, String> = emptyMap()
@Volatile private var companies: Map<Int, String> = emptyMap()
@Volatile private var uuids: Map<Int, String> = emptyMap()
+ @Volatile private var fastPair: Map<Int, String> = emptyMap()
/** (category shl 8 or subcategory, subcategory -1 stored as 0xFF) -> name. */
@Volatile private var appearance: Map<Int, String> = emptyMap()
@@ -28,6 +29,7 @@ object VendorDb {
oui = readTsv(open("vendors/oui.tsv")) { k, v -> k to v }
companies = readTsv(open("vendors/bt_company.tsv")) { k, v -> k.toInt(16) to v }
uuids = readTsv(open("vendors/bt_uuid16.tsv")) { k, v -> k.toInt(16) to v }
+ fastPair = readTsv(open("vendors/fast_pair.tsv")) { k, v -> k.toInt(16) to v }
val app = HashMap<Int, String>()
BufferedReader(InputStreamReader(open("vendors/bt_appearance.tsv"), Charsets.UTF_8)).useLines { lines ->
lines.filter { !it.startsWith("#") }.forEach { line ->
@@ -82,6 +84,9 @@ object VendorDb {
fun uuid16(short: Int): String? = uuids[short]
+ /** The product a Google Fast Pair model ID (24 bits) belongs to, or null. */
+ fun fastPairModel(id: Int): String? = fastPair[id]
+
/** Human description of a 16-bit GAP appearance value. */
fun appearance(value: Int): String? {
val cat = value ushr 6
diff --git a/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt b/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
index 7fbe3cc..f7455e4 100644
--- a/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
+++ b/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
@@ -35,6 +35,11 @@ object DeviceRegistry {
private const val HISTORY_MIN_SPACING_MS = 1000L
private const val LOCATION_SPACING_MS = 45_000L
private const val ROTATION_SILENCE_MS = 1_500L
+ /** Companions ([companions]): heard this close in time, at this many places this far apart, over this distance. */
+ private const val TOGETHER_MS = 90_000L
+ private const val TOGETHER_PLACES = 3
+ private const val PLACE_M = 300.0
+ private const val TOGETHER_SPREAD_M = 1_000.0
/** How long a device keeps a match after the evidence was last observed. */
const val HIT_HOLD_MS = 120_000L
/** Weight of each new RSSI reading (0..1): 0.3 settles in about a second of adverts. */
@@ -368,6 +373,46 @@ object DeviceRegistry {
fun sharingFingerprint(fp: String, now: Long = System.currentTimeMillis(), withinMs: Long = 10 * 60_000L): Int =
tracks.values.count { t -> synchronized(t) { t.fingerprint == fp && now - t.lastSeen <= withinMs } }
+ /** [mac]'s advert fingerprint ([AdvertFingerprint.of]), or null. */
+ fun fingerprintOf(mac: String): String? = tracks[mac]?.let { synchronized(it) { it.fingerprint } }
+
+ /**
+ * Devices that moved along with [mac]: heard within [TOGETHER_MS] of it at [TOGETHER_PLACES] or more
+ * places of your way, [PLACE_M] apart and spread over [TOGETHER_SPREAD_M]. Things that travel together
+ * (a phone with its watch and earbuds, a car's WiFi with a tag hidden in it) turn up this way.
+ * Most places first, at most [max], as (address, name or type).
+ */
+ fun companions(mac: String, max: Int = 3): List<Pair<String, String>> {
+ val t = tracks[mac] ?: return emptyList()
+ val mine = synchronized(t) { t.path.toList() }
+ if (mine.size < TOGETHER_PLACES) return emptyList()
+ return tracks.values.mapNotNull { o ->
+ if (o === t) return@mapNotNull null
+ val (theirs, label) = synchronized(o) { o.path.toList() to (o.name ?: o.identity.type) }
+ sharedPlaces(mine, theirs).takeIf { it > 0 }?.let { Triple(o.mac, label, it) }
+ }.sortedByDescending { it.third }.take(max).map { it.first to it.second }
+ }
+
+ /** How many separate places of [a] had [b] heard too (within [TOGETHER_MS]), when they make a companion; else 0. */
+ internal fun sharedPlaces(a: List<GeoSample>, b: List<GeoSample>): Int {
+ if (b.size < TOGETHER_PLACES) return 0
+ val places = ArrayList<GeoSample>()
+ var j = 0
+ for (p in a) {
+ while (j < b.size && b[j].time < p.time - TOGETHER_MS) j++
+ var k = j
+ var with = false
+ while (!with && k < b.size && b[k].time <= p.time + TOGETHER_MS) {
+ with = metersBetween(p.lat, p.lon, b[k].lat, b[k].lon) < PLACE_M
+ k++
+ }
+ if (with && places.none { metersBetween(it.lat, it.lon, p.lat, p.lon) < PLACE_M }) places += p
+ }
+ if (places.size < TOGETHER_PLACES) return 0
+ val spread = places.maxOf { x -> places.maxOf { y -> metersBetween(x.lat, x.lon, y.lat, y.lon) } }
+ return if (spread >= TOGETHER_SPREAD_M) places.size else 0
+ }
+
/** The last advert of every device in this session (to re-check them after the watchlist changes). */
fun lastAdverts(): List<Advert> = tracks.values.mapNotNull { t -> synchronized(t) { t.advert } }
diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceDetailActivity.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceDetailActivity.kt
index acda118..023471b 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceDetailActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceDetailActivity.kt
@@ -311,6 +311,12 @@ class DeviceDetailActivity : AppCompatActivity() {
a?.phy?.let { id += "PHY" to it }
a?.txPower?.let { id += "Advertised TX power" to "$it dBm" }
s?.facts?.forEach { id += it }
+ DeviceNames.lookalike(mac, DeviceRegistry.fingerprintOf(DeviceRegistry.currentAddress(mac)))?.let {
+ id += "Looks like" to "Your \"$it\": its adverts look the same, so it's that device under a new address, or one of the same model"
+ }
+ DeviceRegistry.companions(DeviceRegistry.currentAddress(mac)).takeIf { it.isNotEmpty() }?.let { c ->
+ id += "Moved together with" to c.joinToString("\n") { (m, label) -> (DeviceNames.of(m) ?: label) + " · " + m }
+ }
// Heard by a USB WiFi adapter / Marauder board: its WPS block, fingerprint, network requests.
com.rfsentinel.app.usb.ProbeIntel.of(mac)?.let { r ->
if (r.hidden) id += "Hidden network" to (s?.name?.let { "Its name, \"$it\", was revealed by a device joining or asking for it" }
@@ -535,7 +541,8 @@ class DeviceDetailActivity : AppCompatActivity() {
ask("Name this device", DeviceNames.of(mac).orEmpty(), heardAs ?: "Name", multiLine = false,
clear = DeviceNames.of(mac)?.let { "Use its own name" }) { text ->
lifecycleScope.launch {
- DeviceNames.set(this@DeviceDetailActivity, mac, text, s?.name ?: known?.name, s?.vendor ?: known?.vendor, s?.deviceType)
+ DeviceNames.set(this@DeviceDetailActivity, mac, text, s?.name ?: known?.name, s?.vendor ?: known?.vendor, s?.deviceType,
+ DeviceRegistry.fingerprintOf(mac))
known = AppDatabase.getInstance(this@DeviceDetailActivity).knownDeviceDao().get(mac)
refresh()
}
diff --git a/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt b/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt
new file mode 100644
index 0000000..ac594fc
--- /dev/null
+++ b/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt
@@ -0,0 +1,92 @@
+package com.rfsentinel.app.detect
+
+import com.rfsentinel.app.service.DeviceRegistry
+import com.rfsentinel.app.service.DeviceRegistry.GeoSample
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.BeforeClass
+import org.junit.Test
+import java.io.File
+
+/** Fast Pair models, Apple device kinds, network-name types, companions and advert look-alikes. */
+class IdentifyMoreTest {
+
+ companion object {
+ @BeforeClass
+ @JvmStatic
+ fun loadVendors() {
+ VendorDb.load { File("src/main/assets", it).inputStream() }
+ }
+ }
+
+ private fun ble(mfg: Map<Int, ByteArray> = emptyMap(), data: Map<java.util.UUID, ByteArray> = emptyMap()) =
+ Advert("C1:22:33:44:55:66", Advert.Source.BLE, -60, null, mfg, emptyList(), data)
+
+ private fun wifi(ssid: String) = Advert("02:00:00:00:00:01", Advert.Source.WIFI, -60, ssid,
+ wifi = Advert.WifiInfo(2437, "[WPA2-PSK-CCMP]", null, emptyList()))
+
+ private fun bytes(vararg b: Int) = ByteArray(b.size) { b[it].toByte() }
+
+ @Test
+ fun fastPairModelIdNamesTheProduct() {
+ val id = DeviceIntel.identify(ble(data = mapOf(Advert.uuid16(0xFE2C) to bytes(0xCD, 0x82, 0x56))))
+ assertEquals("Bose NC 700", id.type)
+ assertTrue(id.facts.contains("Identified by" to "Fast Pair model ID"))
+ // Not in pairing mode: an account-key filter, no model.
+ val paired = DeviceIntel.identify(ble(data = mapOf(Advert.uuid16(0xFE2C) to bytes(0x00, 0x40, 0x11, 0x22, 0x33, 0x44))))
+ assertTrue(paired.facts.contains("Google Fast Pair" to "Pairing / account-key broadcast"))
+ }
+
+ @Test
+ fun fastPairListHasNoTestOrSwappedEntries() {
+ assertNull(VendorDb.fastPairModel(0x00000A))
+ assertNull(VendorDb.fastPairModel(0xF00000))
+ assertEquals("Bose QuietComfort 35 II", VendorDb.fastPairModel(0x0000F0))
+ }
+
+ @Test
+ fun appleWatchAndIphoneAreToldApart() {
+ // Nearby Info (0x10), status byte low nibble 0x0A = on a wrist, unlocked.
+ assertEquals("Apple Watch", DeviceIntel.identify(ble(mapOf(0x004C to bytes(0x10, 0x05, 0x0A, 0x1C, 0x00, 0x00, 0x00)))).type)
+ assertEquals("Apple Watch", DeviceIntel.identify(ble(mapOf(0x004C to bytes(0x0B, 0x02, 0x00, 0x00)))).type)
+ assertEquals("iPhone", DeviceIntel.identify(ble(mapOf(0x004C to bytes(0x10, 0x05, 0x0D, 0x1C, 0x00, 0x00, 0x00)))).type)
+ assertEquals("Apple device (iPhone, iPad, Mac or Watch)",
+ DeviceIntel.identify(ble(mapOf(0x004C to bytes(0x10, 0x05, 0x03, 0x1C, 0x00, 0x00, 0x00)))).type)
+ }
+
+ @Test
+ fun networkNamesSayWhatTheNetworkIs() {
+ mapOf(
+ "BELL123" to "Home router - Bell", "Livebox-1A2B" to "Home router - Orange", "BT-ABC123" to "Home router - BT",
+ "ATT4b7Xq2" to "Home router - AT&T", "Fios-AB12C" to "Home router - Verizon", "SKY1A2B3" to "Home router - Sky",
+ "xfinitywifi" to "Public WiFi hotspot - Xfinity", "Verizon-MiFi8800L-1A2B" to "Mobile hotspot box",
+ "70mai_D06_1234" to "Dashcam", "TELLO-5A1B2C" to "Drone / controller", "GP25123456" to "Action camera",
+ "DIRECT-1F-[TV] Samsung Q60" to "Smart TV / streaming device", "ESP_1A2B3C" to "IoT board (ESP / smart-home firmware)",
+ "TP-LINK_Smart Plug_1A2B" to "Smart plug / bulb waiting to be set up", "Ring Setup 12" to "Security camera / doorbell"
+ ).forEach { (ssid, type) -> assertEquals(ssid, type, DeviceIntel.identify(wifi(ssid)).type) }
+ // Ordinary names stay ordinary.
+ listOf("attention", "Skyline", "Franklin Family", "Bellevue Cafe", "My Home").forEach {
+ assertNull(it, DeviceIntel.ssidType(it))
+ }
+ }
+
+ @Test
+ fun companionsAreDevicesHeardWithItAtSeveralPlaces() {
+ // Your way north, ~550 m per sample, one a minute.
+ val way = (0 until 5).map { GeoSample(it * 60_000L, 45.0 + it * 0.005, -70.0) }
+ val withIt = way.map { GeoSample(it.time + 20_000L, it.lat + 0.0005, it.lon) }
+ assertEquals(5, DeviceRegistry.sharedPlaces(way, withIt))
+ // Heard only at the start: one place, not a companion.
+ val parked = way.take(1) + way.take(1).map { it.copy(time = it.time + 30_000L) } + way.take(1).map { it.copy(time = it.time + 50_000L) }
+ assertEquals(0, DeviceRegistry.sharedPlaces(way, parked))
+ // Heard along the way but long after: not together.
+ assertEquals(0, DeviceRegistry.sharedPlaces(way, way.map { it.copy(time = it.time + 3_600_000L) }))
+ }
+
+ @Test
+ fun advertHashIsStable() {
+ assertEquals(AdvertFingerprint.hash("n=Buds|u=|d=|m=|t=|c="), AdvertFingerprint.hash("n=Buds|u=|d=|m=|t=|c="))
+ assertEquals(8, AdvertFingerprint.hash("x").length)
+ }
+}