-
|
I have implemented game controller emulation using BlueZ and now intend to achieve the same functionality via HCI sockets with Bumble. I originally thought there would be few differences between the two solutions, yet I have run into a tough issue that I cannot resolve. I have attached two sets of btmon logs; the upper one is captured under BlueZ, and the lower one under Bumble. It is obvious that once Bumble receives the first data packet from the remote host, the remote device immediately initiates a disconnection. In contrast, stable connections can be established smoothly with BlueZ. I noticed that BlueZ triggers Sniff mode entry and exit around the transmission and reception of the first data packet. Could this disconnection issue be related to Sniff mode behavior? I sincerely hope experienced developers can offer guidance and solutions. Your help is highly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 12 replies
-
Analysis Report: Game Controller Emulation Disconnection Issue (Bumble Discussion #927)This report analyzes the connection instability issue reported in Bumble Discussion #927, where an emulated game controller (targeting the Nintendo Switch) is immediately disconnected by the host after receiving the first data packet. 1. Log Comparison AnalysisBased on the Successful Connection Flow (BlueZ)
Failed Connection Flow (Bumble)
2. Root Cause AnalysisThe Nintendo Switch has strict power management policies for its wireless controllers. It aggressively requires controllers to enter Sniff Mode shortly after connection to conserve battery.
3. SolutionTo resolve this issue, the Bumble application must explicitly configure the adapter's default link policy to enable Sniff Mode during initialization. Code ExampleYou can send the from bumble.hci import HCI_Write_Default_Link_Policy_Settings_Command
async def initialize_device(device):
# ... your existing device setup ...
# Enable Role Switch (0x01) and Sniff Mode (0x04) -> 0x0005
print("Configuring default link policy to enable Sniff Mode...")
await device.send_command(
HCI_Write_Default_Link_Policy_Settings_Command(
default_link_policy_settings=0x0005
)
)
# ... proceed with connection ...Implementing this configuration allows the emulated controller to successfully negotiate Sniff Mode with the Nintendo Switch, resolving the premature disconnection. |
Beta Was this translation helpful? Give feedback.
-
|
I might have questions about reconnection issues tomorrow. Anyway, I’ve successfully established the first connection with unbonded devices now. Thank you so much. |
Beta Was this translation helpful? Give feedback.
-
|
In BlueZ, I have following code to reconnect from a disconnected socket. def reconnect(self, reconnect_address) -> tuple:
ctrl = socket.socket(
family=socket.AF_BLUETOOTH,
type=socket.SOCK_SEQPACKET,
proto=socket.BTPROTO_L2CAP,
)
itr = socket.socket(
family=socket.AF_BLUETOOTH,
type=socket.SOCK_SEQPACKET,
proto=socket.BTPROTO_L2CAP,
)
addresses = (
reconnect_address
if isinstance(reconnect_address, list)
else [reconnect_address]
)
for address in addresses:
try:
ctrl.connect((address, 17))
itr.connect((address, 19))
return itr, ctrl
except OSError:
pass
itr.close()
ctrl.close()
raise OSError(
"Unable to reconnect to sockets at the given address(es)",
reconnect_address,
)Is there any approach to do so in Bumble? |
Beta Was this translation helpful? Give feedback.
-
|
Another question: what is the detail meaning of L2CAP ERROR——Connection refused – no resources available? |
Beta Was this translation helpful? Give feedback.
-
|
I suggest you to get answers from some AI tools like Antigravity, Codex or Claude Code first. I used Antigravity CLI to answer all the questions here. |
Beta Was this translation helpful? Give feedback.
-
|
The only noticeable difference would be |
Beta Was this translation helpful? Give feedback.
Here is the analysis of the logs you provided (
bluez.logandbumble.log).Analysis Report: Bumble L2CAP Reconnection Failure Issue
1. Issue Overview
The reconnection attempt receives an L2CAP connection response error:
Connection refused - no resources available (0x0004)when using Bumble, but succeeds smoothly when using BlueZ.Comparing
bluez.logandbumble.logreveals the root cause.2. Log Comparison Analysis
Failed Reconnection Flow (Bumble)
nxbt) initiates a new L2CAP connectio…