Repository navigation
Page classic Bluetooth printers through each adapter - #391
Merged
Merged
Conversation
`transports.rfcomm()` never bound its socket, so the kernel paged printers on classic Bluetooth through its first adapter, the one added last. With a second adapter far away (e.g., one shared over USB/IP), a Nelko P21 next to the computer was never reached: every status query told `EHOSTDOWN`. Each connection now pages through each adapter that is on with classic Bluetooth until one reaches the printer: 1. The adapter that last reached it comes first, then the one that heard it, then the kernel's order. `bluetooth.classic_adapters()` reads them from the management channel, one with Bluetooth LE only is left out. 2. A refused pairing goes on to the next adapter, a pairing holds for one adapter only. A gone adapter (`EHOSTUNREACH`, `ENETDOWN`, `ENODEV`, `EADDRNOTAVAIL`) is forgotten and the next one paged; where only gone adapters answered, the printer is told as `EHOSTUNREACH`, "The printer cannot be reached". 3. Only giving way stops it early. A printer switched off costs one page per adapter, about 10 s with two. 4. The paging of a connection that timed out is canceled, so that it does not go on while the next adapter pages. The adapters on with Bluetooth LE and classic Bluetooth are read once for both and kept 60 s, 10 s where one did not tell what it is in time. That they cannot be read is logged once while it stays so. Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
1. A connection no adapter reached reads the adapters again, so that the next one pages through an adapter switched on since, one that told what it is too late, and no longer through one switched off as it paged. Where an adapter reached the printer, i.e., it is not paired or refused the connection, the adapters read are kept. 2. What paging told is ranked in one place: not paired, an answer of the printer (`ECONNREFUSED`, `ECONNRESET`), switched off, anything else, e.g., a timeout, `EALREADY` or `ECONNABORTED`, then gone adapters. 3. The paging of a connection that timed out is canceled within the turn of Bluetooth, as on the way that gives way, so that the next connection does not page through the same adapter meanwhile. 4. The adapters read are kept in one place, `_keep()`, under a lock shared with `forget_adapters()`. A read is stamped with the time it began and kept only over an older one; `forget_adapters()` keeps an expired read of its own time, so that a read that began before it is not kept. That they cannot be read is logged once the lock is released. Signed-off-by: DL6ER <dl6er@dl6er.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With two Bluetooth adapters, e.g., one shared over USB/IP from another room, the kernel paged printers on classic Bluetooth through whichever adapter it lists first. A Nelko P21 next to the computer was then never reached.
A connection now pages through each adapter with classic Bluetooth until one reaches the printer, starting with the one that last did. A pairing holds for one adapter only, so a refused pairing goes on to the next one too.
I tried it with the P21 and two adapters, one of them over USB/IP.