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.
Kotlin airtagalprandroidandroid-autoanti-surveillancebluetooth-low-energybody-cameracounter-surveillancedrone-detectionflock-safetyimsi-catcher-detectorpolice-detectorpolice-scannerprivacyremote-idrtl-sdrsdrsurveillance-detectiontracker-detectionwifi
USB WiFi drivers: clear 'unplug and plug back in' message; all drivers claim with retry and clear stalled endpoints, start the dwell after the retune; RTL8812AU/8821AU drop cut-off frames and read 802.11ac-size frames; AR9271/RT3070 retry firmware chunks
CIS-C0ef0e722ec1d8
diff --git a/app/src/main/java/com/rfsentinel/app/usb/Ar9271Monitor.kt b/app/src/main/java/com/rfsentinel/app/usb/Ar9271Monitor.ktindex c3fda43..4619a72 100644--- a/app/src/main/java/com/rfsentinel/app/usb/Ar9271Monitor.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/Ar9271Monitor.kt@@ -72,7 +72,7 @@ object Ar9271Monitor {conn = ctry {val intf = device.getInterface(0)- if (!c.claimInterface(intf, true)) UsbWifi.log("AR9271: couldn't claim the USB interface (continuing)")+ BulkRx.claim("AR9271", c, intf) { stop }val eps = (0 until intf.endpointCount).map { intf.getEndpoint(it) }val rx = eps.firstOrNull { it.address == 0x82 }val inEp = eps.firstOrNull { it.address == 0x83 }; val outEp = eps.firstOrNull { it.address == 0x04 }@@ -91,11 +91,11 @@ object Ar9271Monitor {controlEp = connectService(0x0100, 3, 4)if (controlEp != null) UsbWifi.log("AR9271: firmware already running (from an earlier scan) - reusing it")else {- if (!uploadFirmware(ctx)) { onStatus("$chipName: firmware upload failed (replug)"); return }+ if (!uploadFirmware(ctx)) { onStatus("$chipName: firmware upload failed - unplug the adapter and plug it back in"); return }ready = awaitReady(5000)if (ready == null) {UsbWifi.log("AR9271: no HTC READY after the firmware upload")- onStatus("$chipName: firmware didn't start (replug)"); return+ onStatus("$chipName: firmware didn't start - unplug the adapter and plug it back in"); return}}}@@ -115,7 +115,7 @@ object Ar9271Monitor {}onStatus("$chipName · starting radio…")- if (!initRadio()) { onStatus("$chipName: radio didn't start (replug)"); return }+ if (!initRadio()) { onStatus("$chipName: radio didn't start - unplug the adapter and plug it back in"); return }UsbWifi.log("AR9271: started in ${System.currentTimeMillis() - t0} ms, noise floor $noiseFloor dBm, USB errors $ctlErrors - monitor live ch $curChannel")onStatus("$chipName · live · 2.4 GHz monitor")rxLoop(chipName, rx, onFrame, onStatus)@@ -136,7 +136,9 @@ object Ar9271Monitor {var addr = FW_ADDR; var off = 0while (off < fw.size) {val len = minOf(FW_BLOCK, fw.size - off)- if (conn.controlTransfer(0x40, FW_DOWNLOAD, addr ushr 8, 0, fw.copyOfRange(off, off + len), len, 2000) < 0) {+ val chunk = fw.copyOfRange(off, off + len)+ // a block now and then isn't taken right after plug-in: try it again before giving up+ if ((0 until 3).none { conn.controlTransfer(0x40, FW_DOWNLOAD, addr ushr 8, 0, chunk, len, 2000) >= 0 }) {UsbWifi.log("AR9271: firmware upload failed at $off B"); return false}off += len; addr += len@@ -460,7 +462,7 @@ object Ar9271Monitor {runCatching { hop(HOP[st.hopIdx]) }val (aps, clients) = frames.live(now, REPORT_MS)onStatus("$chipName · live · $aps access points · $clients devices · ch $curChannel")- st.hopAt = now+ st.hopAt = System.currentTimeMillis() // the dwell starts once the retune is done}}emit(onFrame)diff --git a/app/src/main/java/com/rfsentinel/app/usb/BulkRx.kt b/app/src/main/java/com/rfsentinel/app/usb/BulkRx.ktindex 6db153e..e4e72ca 100644--- a/app/src/main/java/com/rfsentinel/app/usb/BulkRx.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/BulkRx.kt@@ -122,6 +122,28 @@ internal object BulkRx {}}+ /**+ * Claims [intf], asking again for ~3 s (right after plug-in the system can still hold the+ * adapter, and without the interface every transfer fails), then clears any stall left on its+ * bulk endpoints by an earlier session. Linux resets the whole device instead, which apps can't.+ */+ fun claim(tag: String, conn: UsbDeviceConnection, intf: android.hardware.usb.UsbInterface, stopped: () -> Boolean = { false }): Boolean {+ var ok = conn.claimInterface(intf, true)+ var waits = 0+ while (!ok && waits < 10 && !stopped()) {+ try { Thread.sleep(300) } catch (_: InterruptedException) {}+ waits++; ok = conn.claimInterface(intf, true)+ }+ if (!ok) UsbWifi.log("$tag: couldn't claim the USB interface after ${waits * 300} ms (continuing)")+ else if (waits > 0) UsbWifi.log("$tag: USB interface claimed after ${waits * 300} ms")+ for (i in 0 until intf.endpointCount) {+ val ep = intf.getEndpoint(i)+ if (ep.type == android.hardware.usb.UsbConstants.USB_ENDPOINT_XFER_BULK)+ conn.controlTransfer(0x02, 0x01, 0, ep.address, null, 0, 1000) // CLEAR_FEATURE(ENDPOINT_HALT)+ }+ return ok+ }+/** The bulk-IN endpoint at [address], else the interface's first bulk-IN endpoint. */fun inEndpoint(intf: android.hardware.usb.UsbInterface, address: Int): UsbEndpoint? {var first: UsbEndpoint? = nulldiff --git a/app/src/main/java/com/rfsentinel/app/usb/Mt7612uMonitor.kt b/app/src/main/java/com/rfsentinel/app/usb/Mt7612uMonitor.ktindex fbe5ce0..1cc4c3b 100644--- a/app/src/main/java/com/rfsentinel/app/usb/Mt7612uMonitor.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/Mt7612uMonitor.kt@@ -170,13 +170,13 @@ object Mt7612uMonitor {if (!loadRomPatch(cmdOut, patch, e3, romProtect = chip != 0x7612)) continueif (loadFirmware(cmdOut, fw, e3)) { loaded = true; break }}- if (!loaded) { onStatus("$chipName: firmware didn't load (replug)"); return }+ if (!loaded) { onStatus("$chipName: firmware didn't load - unplug the adapter and plug it back in"); return }// ---- radio ----onStatus("$chipName · starting the radio…")// after the firmware: DMA idle, then the MAC ready again (as the kernel waits)if (!poll(100, 5) { regRd(WPDMA_GLO_CFG) and (WPDMA_TX_DMA_BUSY or WPDMA_RX_DMA_BUSY) == 0 }) UsbWifi.log("MT7612U: DMA still busy after the firmware (continuing)")- if (!poll(1000, 5) { regRd(MAC_CSR0).let { it != 0 && it != -1 } }) { onStatus("$chipName: MAC not ready (replug)"); return }+ if (!poll(1000, 5) { regRd(MAC_CSR0).let { it != 0 && it != -1 } }) { onStatus("$chipName: MAC not ready - unplug the adapter and plug it back in"); return }initDma()mcuCmd(cmdOut, CMD_FUN_SET_OP, leWords(Q_SELECT, 1), false)mcuCmd(cmdOut, CMD_POWER_SAVING_OP, leWords(RADIO_ON, 0), false)@@ -518,7 +518,7 @@ object Mt7612uMonitor {drainCmdResp()val (aps, clients) = frames.live(now, REPORT_MS)onStatus("$chipName · live · $aps access points · $clients devices · ch ${HOP[st.hopIdx]}")- st.hopAt = now+ st.hopAt = System.currentTimeMillis() // the dwell starts once the retune is done}}emit(onFrame)diff --git a/app/src/main/java/com/rfsentinel/app/usb/Mt7921uMonitor.kt b/app/src/main/java/com/rfsentinel/app/usb/Mt7921uMonitor.ktindex 5a7a488..d018504 100644--- a/app/src/main/java/com/rfsentinel/app/usb/Mt7921uMonitor.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/Mt7921uMonitor.kt@@ -139,7 +139,7 @@ object Mt7921uMonitor {UsbWifi.log("MT7921AU: no interface with class ff/ff/ff and 2 bulk IN + 6 bulk OUT endpoints")onStatus("$chipName: WiFi interface not found"); return}- if (!c.claimInterface(intf, true)) UsbWifi.log("MT7921AU: couldn't claim the USB interface (continuing)")+ BulkRx.claim("MT7921AU", c, intf) { stop }val (ins, outs) = bulkEndpoints(intf)epRx = ins[0]; epCmd = outs[0]; epData = outs[1]UsbWifi.log("MT7921AU: interface ${intf.id}, bulk IN [${ins.joinToString { "0x%02x".format(it.address) }}] " +@@ -154,7 +154,7 @@ object Mt7921uMonitor {val patch = ctx.assets.open("usbwifi/WIFI_MT7961_patch_mcu_1_2_hdr.bin").use { it.readBytes() }val ram = ctx.assets.open("usbwifi/WIFI_RAM_CODE_MT7961_1.bin").use { it.readBytes() }val err = bringUp(patch, ram)- if (err != null) { onStatus("$chipName: $err (replug)"); return }+ if (err != null) { onStatus("$chipName: $err - unplug the adapter and plug it back in"); return }onStatus("$chipName · starting monitor mode…")// Monitor: receive everything (other networks, control frames), sniffer on.diff --git a/app/src/main/java/com/rfsentinel/app/usb/Rt3070Monitor.kt b/app/src/main/java/com/rfsentinel/app/usb/Rt3070Monitor.ktindex de7c54a..6b2573f 100644--- a/app/src/main/java/com/rfsentinel/app/usb/Rt3070Monitor.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/Rt3070Monitor.kt@@ -95,13 +95,12 @@ object Rt3070Monitor {conn = c; ctlErrors = 0try {val intf = device.getInterface(0)- val claimed = c.claimInterface(intf, true)+ BulkRx.claim("RT3070", c, intf) { stop }val rx = BulkRx.inEndpoint(intf, 0x81)?: run { UsbWifi.log("RT3070: no bulk-IN endpoint"); onStatus("$chipName: no RX endpoint"); return }UsbWifi.log("=== RT3070 bring-up (rt2800usb) ===")- if (!claimed) UsbWifi.log("RT3070: couldn't claim the USB interface (continuing)")val t0 = System.currentTimeMillis()- if (!waitCsrReady()) { UsbWifi.log("RT3070: MAC_CSR0 never ready"); onStatus("$chipName: not responding (replug)"); return }+ if (!waitCsrReady()) { UsbWifi.log("RT3070: MAC_CSR0 never ready"); onStatus("$chipName: not responding - unplug the adapter and plug it back in"); return }val csr0 = regRd(MAC_CSR0)val rt = csr0 ushr 16; val rev = csr0 and 0xffffUsbWifi.log("RT3070: chip RT%04x rev 0x%04x, RX EP=0x%02x".format(rt, rev, rx.address))@@ -112,10 +111,10 @@ object Rt3070Monitor {readEeprom()onStatus("$chipName · loading firmware…")- if (!loadFirmware(ctx)) { onStatus("$chipName: firmware didn't start (replug)"); return }+ if (!loadFirmware(ctx)) { onStatus("$chipName: firmware didn't start - unplug the adapter and plug it back in"); return }onStatus("$chipName · starting radio…")- if (!enableRadio()) { onStatus("$chipName: radio didn't start (replug)"); return }+ if (!enableRadio()) { onStatus("$chipName: radio didn't start - unplug the adapter and plug it back in"); return }regWr(RX_FILTR_CFG, RX_FILTER_MONITOR)tune(HOP[0])UsbWifi.log(("RT3070: started in %d ms - SYS_CTRL 0x%08x WPDMA 0x%08x USB_DMA 0x%08x RX_FILTR 0x%08x MAC_STATUS 0x%08x PBF 0x%08x, " +@@ -201,7 +200,9 @@ object Rt3070Monitor {var off = 0 // the RT3070 runs the first 4 KB imagewhile (off < FW_LEN) {val len = minOf(CSR_CACHE, FW_LEN - off)- if (conn.controlTransfer(OUT_VENDOR, MULTI_WRITE, 0, FIRMWARE_BASE + off, fw.copyOfRange(off, off + len), len, 1000) < 0) {+ val chunk = fw.copyOfRange(off, off + len)+ // a write now and then isn't taken right after plug-in: try it again before giving up+ if ((0 until 3).none { conn.controlTransfer(OUT_VENDOR, MULTI_WRITE, 0, FIRMWARE_BASE + off, chunk, len, 1000) >= 0 }) {UsbWifi.log("RT3070: firmware write failed at $off"); return false}off += len@@ -439,7 +440,7 @@ object Rt3070Monitor {runCatching { tune(HOP[st.hopIdx]) }val (aps, clients) = frames.live(now, REPORT_MS)onStatus("$chipName · live · $aps access points · $clients devices · ch ${HOP[st.hopIdx]}")- st.hopAt = now+ st.hopAt = System.currentTimeMillis() // the dwell starts once the retune is done}}emit(onFrame)diff --git a/app/src/main/java/com/rfsentinel/app/usb/Rtl8187Monitor.kt b/app/src/main/java/com/rfsentinel/app/usb/Rtl8187Monitor.ktindex 24bbf59..8503620 100644--- a/app/src/main/java/com/rfsentinel/app/usb/Rtl8187Monitor.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/Rtl8187Monitor.kt@@ -89,9 +89,8 @@ object Rtl8187Monitor {conn = c; ctlErrors = 0try {val intf = device.getInterface(0)- val claimed = c.claimInterface(intf, true)+ BulkRx.claim("RTL8187", c, intf) { stop }UsbWifi.log("=== RTL8187 bring-up (rtl8187) ===")- if (!claimed) UsbWifi.log("RTL8187: couldn't claim the USB interface (continuing)")is8187b = (device.vendorId to device.productId) in B_IDSval t0 = System.currentTimeMillis()@@ -126,7 +125,7 @@ object Rtl8187Monitor {"TX_CONF 0x%08x, RX EP 0x%02x".format(r32(TX_CONF), rx.address))onStatus("$chipName · starting radio…")- if (!(if (is8187b) initHwB() else initHwL())) { onStatus("$chipName: reset timed out (replug)"); return }+ if (!(if (is8187b) initHwB() else initHwL())) { onStatus("$chipName: reset timed out - unplug the adapter and plug it back in"); return }start()tune(HOP[0], txPower = true)UsbWifi.log("RTL8187: started in ${System.currentTimeMillis() - t0} ms - RX_CONF 0x%08x TX_CONF 0x%08x CMD 0x%02x CONFIG3 0x%02x ANAPARAM 0x%08x ANAPARAM2 0x%08x, USB errors %d - monitor live ch %d".format(@@ -516,7 +515,7 @@ object Rtl8187Monitor {runCatching { tune(HOP[st.hopIdx]) }val (aps, clients) = frames.live(now, REPORT_MS)onStatus("$chipName · live · $aps access points · $clients devices · ch ${HOP[st.hopIdx]}")- st.hopAt = now+ st.hopAt = System.currentTimeMillis() // the dwell starts once the retune is done}}emit(onFrame)diff --git a/app/src/main/java/com/rfsentinel/app/usb/Rtl8812auMonitor.kt b/app/src/main/java/com/rfsentinel/app/usb/Rtl8812auMonitor.ktindex 26231ae..9a4858f 100644--- a/app/src/main/java/com/rfsentinel/app/usb/Rtl8812auMonitor.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/Rtl8812auMonitor.kt@@ -36,6 +36,7 @@ object Rtl8812auMonitor {private var rfe = 0/** The chip's revision: 0 = A, 1 = B, 2 = C... */private var cut = 0+ private const val MAX_PKT = 12000private const val DWELL_MS = 350Lprivate val FRESH_MS get() = (HOP.size * DWELL_MS * 9 / 5).coerceAtLeast(3000L)@@ -69,7 +70,7 @@ object Rtl8812auMonitor {var epRx: UsbEndpoint? = nulltry {val intf = device.getInterface(0)- conn.claimInterface(intf, true)+ BulkRx.claim("RTL8812AU", conn, intf) { stop }for (i in 0 until intf.endpointCount) {val ep = intf.getEndpoint(i)if (ep.type == UsbConstants.USB_ENDPOINT_XFER_BULK && ep.direction == UsbConstants.USB_DIR_IN) { epRx = ep; break }@@ -87,7 +88,7 @@ object Rtl8812auMonitor {val cr = r16(conn, Rtl8812auTables.REG_CR)cut = (r32(conn, REG_SYS_CFG) ushr 12) and 0xFUsbWifi.log("RTL8812AU: MAC on, REG_CR=0x%04x, chip revision %d".format(cr, cut))- if (cr == 0xEAEA) { onStatus("RTL8812AU: MAC didn't power on (replug)"); return }+ if (cr == 0xEAEA) { onStatus("RTL8812AU: MAC didn't power on - unplug the adapter and plug it back in"); return }rfe = runCatching { readRfeType(conn) }.getOrDefault(0)UsbWifi.log("RTL8812AU: board type (RFE) $rfe")@@ -266,7 +267,7 @@ object Rtl8812auMonitor {if (ni != st.hopIdx) { st.hopIdx = ni; runCatching { channelTune(conn, HOP[st.hopIdx]) } }val (aps, clients) = frames.live(now, REPORT_MS)onStatus("RTL8812AU · live · $aps access points · $clients devices · ch ${HOP[st.hopIdx]}")- st.hopAt = now+ st.hopAt = System.currentTimeMillis() // the dwell starts once the retune is done}}@@ -348,12 +349,16 @@ object Rtl8812auMonitor {while (off + size <= n) {val d0 = le32(b, off)val pkt = d0 and 0x3fff- if (pkt == 0 || pkt > 4096) break+ // up to the largest 802.11ac MPDU (11454 B), as the 8814AU parser allows+ if (pkt == 0 || pkt > MAX_PKT) breakval crc = (d0 ushr 14) and 1val drv = ((d0 ushr 16) and 0xf) * 8val shift = (d0 ushr 24) and 3val fs = off + size + drv + shift- val fe = minOf(n, fs + pkt)+ // A frame cut off at the end of the transfer isn't reported: its tail (and so a+ // complete header / IEs) is missing, and what follows in the next transfer isn't a descriptor.+ if (fs + pkt > n) break+ val fe = fs + pktif (crc == 0 && fe - fs >= 24) {val rate = b[off + 12].toInt() and 0x7fval rssi = if (drv >= 8 && off + size + drv <= n) rtlRssi(b, off + size, rate) else NOMINAL_RSSIdiff --git a/app/src/main/java/com/rfsentinel/app/usb/Rtl8814auMonitor.kt b/app/src/main/java/com/rfsentinel/app/usb/Rtl8814auMonitor.ktindex 3926fc0..a2dc9f6 100644--- a/app/src/main/java/com/rfsentinel/app/usb/Rtl8814auMonitor.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/Rtl8814auMonitor.kt@@ -49,7 +49,7 @@ object Rtl8814auMonitor {conn = ctry {val intf = device.getInterface(0)- if (!c.claimInterface(intf, true)) UsbWifi.log("RTL8814AU: couldn't claim the USB interface (continuing)")+ BulkRx.claim("RTL8814AU", c, intf) { stop }val rx = BulkRx.inEndpoint(intf, 0x81)?: run { UsbWifi.log("RTL8814AU: no bulk-IN endpoint"); onStatus("$chipName: no RX endpoint"); return }UsbWifi.log("=== RTL8814AU bring-up (8814au) ===")@@ -62,7 +62,7 @@ object Rtl8814auMonitor {w16(Rtl8814auTables.REG_CR, Rtl8814auTables.CR_INIT16)val cr = r16(Rtl8814auTables.REG_CR)UsbWifi.log("RTL8814AU: power-on %s, REG_CR 0x%04x, RX EP 0x%02x".format(if (powered) "ok" else "poll timed out", cr, rx.address))- if (cr == 0xEAEA) { onStatus("$chipName: MAC didn't power on (replug)"); return }+ if (cr == 0xEAEA) { onStatus("$chipName: MAC didn't power on - unplug the adapter and plug it back in"); return }initLlt(); initRqpn()onStatus("$chipName · loading MAC / BB / RF…")@@ -211,7 +211,7 @@ object Rtl8814auMonitor {runCatching { tune(HOP[st.hopIdx]) }val (aps, clients) = frames.live(now, REPORT_MS)onStatus("$chipName · live · $aps access points · $clients devices · ch ${HOP[st.hopIdx]}")- st.hopAt = now+ st.hopAt = System.currentTimeMillis() // the dwell starts once the retune is done}}emit(onFrame)diff --git a/app/src/main/java/com/rfsentinel/app/usb/Rtl8821auMonitor.kt b/app/src/main/java/com/rfsentinel/app/usb/Rtl8821auMonitor.ktindex 538ecce..2201027 100644--- a/app/src/main/java/com/rfsentinel/app/usb/Rtl8821auMonitor.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/Rtl8821auMonitor.kt@@ -35,6 +35,7 @@ object Rtl8821auMonitor {/** The adapter's light blinks with traffic (Settings > External hardware); off = it stays dark. Changes apply live. */@Volatile var lightEnabled = trueprivate var HOP = HOP_24+ private const val MAX_PKT = 12000private const val DWELL_MS = 350Lprivate val FRESH_MS get() = (HOP.size * DWELL_MS * 9 / 5).coerceAtLeast(3000L)@@ -68,7 +69,7 @@ object Rtl8821auMonitor {var epRx: UsbEndpoint? = nulltry {val intf = device.getInterface(0)- conn.claimInterface(intf, true)+ BulkRx.claim("RTL8821AU", conn, intf) { stop }for (i in 0 until intf.endpointCount) {val ep = intf.getEndpoint(i)if (ep.type == UsbConstants.USB_ENDPOINT_XFER_BULK && ep.direction == UsbConstants.USB_DIR_IN) { epRx = ep; break }@@ -86,7 +87,7 @@ object Rtl8821auMonitor {w16(conn, Rtl8821auTables.REG_CR, r16(conn, Rtl8821auTables.REG_CR) or Rtl8821auTables.CR_MACEN8)val cr = r16(conn, Rtl8821auTables.REG_CR)UsbWifi.log("RTL8821AU: MAC on, REG_CR=0x%04x".format(cr))- if (cr == 0xEAEA) { onStatus("RTL8821AU: MAC didn't power on (replug)"); return }+ if (cr == 0xEAEA) { onStatus("RTL8821AU: MAC didn't power on - unplug the adapter and plug it back in"); return }onStatus("RTL8821AU · loading MAC/BB/RF…")applyRegTable(conn, Rtl8821auTables.MAC_REG, rf = false)@@ -203,7 +204,7 @@ object Rtl8821auMonitor {if (ni != st.hopIdx) { st.hopIdx = ni; runCatching { channelTune(conn, HOP[st.hopIdx]) } }val (aps, clients) = frames.live(now, REPORT_MS)onStatus("RTL8811AU / 8821AU · live · $aps access points · $clients devices · ch ${HOP[st.hopIdx]}")- st.hopAt = now+ st.hopAt = System.currentTimeMillis() // the dwell starts once the retune is done}}@@ -285,12 +286,16 @@ object Rtl8821auMonitor {while (off + size <= n) {val d0 = le32(b, off)val pkt = d0 and 0x3fff- if (pkt == 0 || pkt > 4096) break+ // up to the largest 802.11ac MPDU (11454 B), as the 8814AU parser allows+ if (pkt == 0 || pkt > MAX_PKT) breakval crc = (d0 ushr 14) and 1val drv = ((d0 ushr 16) and 0xf) * 8val shift = (d0 ushr 24) and 3val fs = off + size + drv + shift- val fe = minOf(n, fs + pkt)+ // A frame cut off at the end of the transfer isn't reported: its tail (and so a+ // complete header / IEs) is missing, and what follows in the next transfer isn't a descriptor.+ if (fs + pkt > n) break+ val fe = fs + pktif (crc == 0 && fe - fs >= 24) {val rate = b[off + 12].toInt() and 0x7fval rssi = if (drv >= 8 && off + size + drv <= n) rtlRssi(b, off + size, rate) else NOMINAL_RSSIdiff --git a/app/src/main/java/com/rfsentinel/app/usb/Rtl8822buMonitor.kt b/app/src/main/java/com/rfsentinel/app/usb/Rtl8822buMonitor.ktindex 69c040b..60aae7d 100644--- a/app/src/main/java/com/rfsentinel/app/usb/Rtl8822buMonitor.kt+++ b/app/src/main/java/com/rfsentinel/app/usb/Rtl8822buMonitor.kt@@ -112,7 +112,7 @@ object Rtl8822buMonitor {// The WiFi function is the vendor-specific interface (combo chips add Bluetooth ones).val intf = (0 until device.interfaceCount).map { device.getInterface(it) }.firstOrNull { it.interfaceClass == UsbConstants.USB_CLASS_VENDOR_SPEC } ?: device.getInterface(0)- if (!conn.claimInterface(intf, true)) throw IOException("couldn't claim the USB interface")+ if (!BulkRx.claim(label, conn, intf) { stop }) throw IOException("couldn't claim the USB interface")var epIn: UsbEndpoint? = null; var epOut: UsbEndpoint? = nullfor (i in 0 until intf.endpointCount) {val ep = intf.getEndpoint(i)@@ -185,7 +185,7 @@ object Rtl8822buMonitor {val (aps, clients) = frames.live(now, REPORT_MS)val band = if (st.channel > 14) "5 GHz" else "2.4 GHz"onStatus("${st.label} · live · $aps access points · $clients devices · ch ${st.channel} ($band)")- st.hopAt = now+ st.hopAt = System.currentTimeMillis() // the dwell starts once the retune is done}}