Switch to bleak for reliable BLE scanning with RSSI

- Replace hcitool-based BT scanning with bleak Python library
- Bleak provides reliable RSSI values via D-Bus/BlueZ
- BLE scan now finds devices that hcitool missed
- Update project docs to reflect resolved BT RSSI blocker
- Add bleak>=0.21.0 to dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
User
2026-02-01 00:17:47 +01:00
parent 52df6421be
commit 0e99232582
6 changed files with 35 additions and 61 deletions

View File

@@ -23,7 +23,7 @@
| Status | Task | Notes |
|--------|------|-------|
| [-] | Fix Bluetooth RSSI acquisition | `hcitool rssi` only works for connected devices; `bluetoothctl` doesn't expose RSSI for cached devices |
| [x] | Fix Bluetooth RSSI acquisition | Switched to `bleak` Python library for reliable BLE scanning with RSSI |
---
@@ -38,7 +38,7 @@
| [x] | Live BT tracking mode | 4-second scan interval |
| [x] | Moving device detection | Purple markers for RSSI changes |
| [x] | Filter-aware scanning | Skip WiFi/BT based on toggle |
| [~] | Improve BT discovery reliability | Try alternative scanning methods |
| [x] | Improve BT discovery reliability | Using bleak library for BLE scanning |
| [ ] | Document API endpoints | docs/API.md |
| [ ] | Create CHEATSHEET.md | Quick reference guide |
@@ -78,28 +78,28 @@
| Live tracking button | 2026-01-31 |
| Purple moving indicators | 2026-01-31 |
| Smart scanning (filter-aware) | 2026-01-31 |
| SQLite historical database | 2026-02-01 |
| Bleak BLE scanning (reliable RSSI) | 2026-02-01 |
| Auto-start live BT tracking | 2026-02-01 |
---
## Blockers
### BT RSSI Acquisition
*No current blockers*
### ~~BT RSSI Acquisition~~ (RESOLVED)
**Problem:** Cannot get reliable RSSI values for Bluetooth devices
- `hcitool rssi <addr>` - Only works for connected devices
- `bluetoothctl info` - No RSSI for cached devices
- `btmgmt find` - Not providing output
- BLE scan (`hcitool lescan`) - I/O errors on this adapter
**Potential Solutions:**
1. Use D-Bus BlueZ API directly (needs dbus-python)
2. Keep devices paired/connected for RSSI polling
3. Focus on WiFi-based tracking instead
4. Use dedicated BLE beacon hardware
**Solution:** Switched to `bleak` Python BLE library which provides reliable RSSI via D-Bus/BlueZ.
---
## Notes
- Bluetooth scanning is unreliable on Raspberry Pi 5 with built-in adapter
- BLE scanning now uses `bleak` Python library (reliable RSSI via D-Bus)
- WiFi scanning works well with `iw` command
- Consider external USB Bluetooth adapter for better BLE support
- Live BT tracking auto-starts on page load (3-second scan interval)
- Historical data stored in SQLite database with auto-cleanup