Order scan lists by discovery time, not RSSI, so they stay still

bc_snapshot re-sorted by RSSI every refresh, so entries jumped around as
signal fluctuated. Sort by first-seen instead: the list is stable and new
devices append at the bottom. Applies to every app that uses the shared
snapshot (BT Inspector, HID Host, Sensor Dashboard, GATT Fuzzer).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LEaD4ZeAfvWLBUxXp8G11r
This commit is contained in:
2026-09-10 23:50:00 +01:00
co-authored by Claude Fable 5.1
parent def0fc070b
commit 4214dcaf98
+4 -2
View File
@@ -351,10 +351,12 @@ size_t bc_snapshot(BleCentral* bc, BcDevice* out, size_t max) {
d->logged = true; d->logged = true;
} }
furi_mutex_release(bc->mutex); furi_mutex_release(bc->mutex);
for(size_t i = 1; i < n; i++) { // insertion sort by RSSI, strongest first (n <= 32) // Order by discovery time (first seen) so the list is stable and doesn't
// jump around as RSSI changes. Insertion sort, n <= 32.
for(size_t i = 1; i < n; i++) {
BcDevice d = out[i]; BcDevice d = out[i];
size_t j = i; size_t j = i;
while(j > 0 && out[j - 1].rssi < d.rssi) { while(j > 0 && out[j - 1].first_seen > d.first_seen) {
out[j] = out[j - 1]; out[j] = out[j - 1];
j--; j--;
} }