fix(ble): Add scanner-connection coordination to prevent "InProgress" errors

Scanner was calling BleakScanner.start() during active connection attempts,
causing BlueZ "Operation already in progress" errors. This fix adds coordination
between scanner and connection operations:

- Add _should_pause_scanning() method to check for active connections
- Modify _perform_scan() to skip scan cycle when connections in progress
- Scanner automatically pauses when _connecting_peers is not empty
- Scanner automatically resumes when connections complete

Impact:
- Eliminates scan-induced connection failures
- Reduces BlueZ error log spam
- Improves overall connection reliability

Files changed:
- src/RNS/Interfaces/linux_bluetooth_driver.py: Add pause logic
- tests/test_scanner_connection_coordination.py: Add test coverage
- BLE_PROTOCOL_v2.2.md: Document scanner coordination
- CHANGELOG.md: Record fix details

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
torlando-tech 2025-11-10 19:44:20 -05:00
commit d2f75c0f39
4 changed files with 395 additions and 0 deletions

View file

@ -26,6 +26,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixes issue where devices could not reconnect after multiple failed attempts due to corrupted BlueZ state
- Files: `src/RNS/Interfaces/linux_bluetooth_driver.py` (lines 786-830, 980-1069), `src/RNS/Interfaces/BLEInterface.py` (lines 1475-1490)
- **Scanner interference causing "Operation already in progress" errors during connection attempts**
- Added `_should_pause_scanning()` method to check for active connections before starting scanner
- Modified `_perform_scan()` to skip scan cycle when connections are in progress
- Scanner automatically pauses when `_connecting_peers` is not empty
- Scanner automatically resumes when connections complete
- Prevents BlueZ "InProgress" errors from scanner.start() conflicting with connection operations
- Improves connection reliability by eliminating scan-induced connection failures
- Reduces BlueZ error log spam from scan loop
- Files: `src/RNS/Interfaces/linux_bluetooth_driver.py` (lines 539-551, 586-588)
- Tests: `tests/test_scanner_connection_coordination.py`
## [0.1.1] - 2025-11-10
### Fixed