Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example keyboard.py connect stopped. #375

Open
joyhope opened this issue Dec 15, 2023 · 6 comments
Open

example keyboard.py connect stopped. #375

joyhope opened this issue Dec 15, 2023 · 6 comments

Comments

@joyhope
Copy link

joyhope commented Dec 15, 2023

I try to connect Logica Master 3, the process is stopped.

sudo ../venv/bin/python keyboard.py device1.json  usb:0 connect DA:BA:FC:8D:3E:37
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:bumble.transport.usb:loading libusb library at ... /bumble/venv/lib/python3.10/site-packages/libusb_package/libusb-1.0.so
DEBUG:bumble.transport.usb:USB Device: Bus 003 Device 005: ID 33fa:0001
DEBUG:bumble.transport.usb:selected endpoints: configuration=1, interface=0, setting=0, acl_in=0x82, acl_out=0x04, events_in=0x81, 
DEBUG:bumble.transport.usb:auto-detaching kernel driver
DEBUG:bumble.transport.usb:current configuration = 1
DEBUG:bumble.transport.usb:starting USB event loop
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_RESET_COMMAND
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_RESET_COMMAND
  return_parameters:       HCI_SUCCESS
DEBUG:bumble.drivers.rtk:USB device (33FA, 0001) not in known list
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_READ_LOCAL_SUPPORTED_COMMANDS_COMMAND
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_READ_LOCAL_SUPPORTED_COMMANDS_COMMAND
  return_parameters:       
    status:             HCI_SUCCESS
    supported_commands: bfffff03ccffefff3ffffc1ff20fe8fe3ff78fff1c00040061f7ffff7f3800007effffffffffff07000000000000000000000000000000000000000000000000
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_LE_READ_LOCAL_SUPPORTED_FEATURES_COMMAND
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_LE_READ_LOCAL_SUPPORTED_FEATURES_COMMAND
  return_parameters:       
    status:      HCI_SUCCESS
    le_features: fff8010000000000
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_READ_LOCAL_VERSION_INFORMATION_COMMAND
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_READ_LOCAL_VERSION_INFORMATION_COMMAND
  return_parameters:       
    status:             HCI_SUCCESS
    hci_version:        12
    hci_subversion:     3
    lmp_version:        12
    company_identifier: 2279
    lmp_subversion:     3
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_SET_EVENT_MASK_COMMAND:
  event_mask: ffffffffffffff3f
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_SET_EVENT_MASK_COMMAND
  return_parameters:       HCI_SUCCESS
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_LE_SET_EVENT_MASK_COMMAND:
  le_event_mask: ffffffff00000000
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_LE_SET_EVENT_MASK_COMMAND
  return_parameters:       HCI_SUCCESS
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_READ_BUFFER_SIZE_COMMAND
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_READ_BUFFER_SIZE_COMMAND
  return_parameters:       
    status:                                HCI_SUCCESS
    hc_acl_data_packet_length:             1021
    hc_synchronous_data_packet_length:     255
    hc_total_num_acl_data_packets:         9
    hc_total_num_synchronous_data_packets: 4
DEBUG:bumble.host:HCI ACL flow control: hc_acl_data_packet_length=1021,hc_total_num_acl_data_packets=9
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_LE_READ_BUFFER_SIZE_COMMAND
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_LE_READ_BUFFER_SIZE_COMMAND
  return_parameters:       
    status:                           HCI_SUCCESS
    hc_le_acl_data_packet_length:     251
    hc_total_num_le_acl_data_packets: 6
DEBUG:bumble.host:HCI LE ACL flow control: hc_le_acl_data_packet_length=251,hc_total_num_le_acl_data_packets=6
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_COMMAND
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH_COMMAND
  return_parameters:       
    status:                  HCI_SUCCESS
    suggested_max_tx_octets: 27
    suggested_max_tx_time:   328
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_COMMAND:
  suggested_max_tx_octets: 251
  suggested_max_tx_time:   2120
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH_COMMAND
  return_parameters:       HCI_SUCCESS
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_READ_BD_ADDR_COMMAND
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_READ_BD_ADDR_COMMAND
  return_parameters:       
    status:  HCI_SUCCESS
    bd_addr: 04:7F:0E:7C:48:C8/P
DEBUG:bumble.device:BD_ADDR: 04:7F:0E:7C:48:C8/P
DEBUG:bumble.keys:JSON keystore: /root/.local/share/Bumble/Pairing/04-7f-0e-7c-48-c8-p.json
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_WRITE_LE_HOST_SUPPORT_COMMAND:
  le_supported_host:    1
  simultaneous_le_host: 0
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_WRITE_LE_HOST_SUPPORT_COMMAND
  return_parameters:       HCI_SUCCESS
DEBUG:bumble.device:LE Random Address: F0:F1:F2:F3:F4:F5
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_LE_SET_RANDOM_ADDRESS_COMMAND:
  random_address: F0:F1:F2:F3:F4:F5
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_COMPLETE_EVENT:
  num_hci_command_packets: 1
  command_opcode:          HCI_LE_SET_RANDOM_ADDRESS_COMMAND
  return_parameters:       HCI_SUCCESS
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_LE_EXTENDED_CREATE_CONNECTION_COMMAND:
  initiator_filter_policy: 0
  own_address_type:        RANDOM
  peer_address_type:       RANDOM_DEVICE_ADDRESS
  peer_address:            DA:BA:FC:8D:3E:37
  initiating_phys:         LE_1M_PHY
  LE_1M_PHY.scan_interval:           96
  LE_1M_PHY.scan_window:             96
  LE_1M_PHY.connection_interval_min: 12
  LE_1M_PHY.connection_interval_max: 24
  LE_1M_PHY.max_latency:             0
  LE_1M_PHY.supervision_timeout:     72
  LE_1M_PHY.min_ce_length:           0
  LE_1M_PHY.max_ce_length:           0
DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_STATUS_EVENT:
  status:                  PENDING
  num_hci_command_packets: 1
  command_opcode:          HCI_LE_EXTENDED_CREATE_CONNECTION_COMMAND

I am not know which kind of problem happened.

@joyhope
Copy link
Author

joyhope commented Dec 18, 2023

I found the mouse required encryption link. But I have no idea how to implement it with Bumble Library. Is there any encryption-related demo for the connection?

@joyhope
Copy link
Author

joyhope commented Dec 20, 2023

All the Bumble connect processes will stop on the HCI_LE_EXTENDED_CREATE_CONNECTION_COMMAND.

I am not sure whether it is caused by the USB dongle or other reasons.

=== Connecting to FC:D0:33:FF:2F:20... DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_LE_CREATE_CONNECTION_COMMAND: le_scan_interval: 96 le_scan_window: 96 initiator_filter_policy: 0 peer_address_type: RANDOM_DEVICE_ADDRESS peer_address: FC:D0:33:FF:2F:20 own_address_type: RANDOM connection_interval_min: 12 connection_interval_max: 24 max_latency: 0 supervision_timeout: 72 min_ce_length: 0 max_ce_length: 0 DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_STATUS_EVENT: status: PENDING num_hci_command_packets: 2 command_opcode: HCI_LE_CREATE_CONNECTION_COMMAND

@barbibulle
Copy link
Collaborator

I found the mouse required encryption link. But I have no idea how to implement it with Bumble Library. Is there any encryption-related demo for the connection?

If you need an encrypted connection, you should 1/ pair the two devices that communicate (you can use the pair.py app for that), then, once you've paired and the pairing keys are stored in the key store (you only need to pair once, the key store will remember the keys), you can enable encryption on the connection by calling await connection.encrypt()

@barbibulle
Copy link
Collaborator

All the Bumble connect processes will stop on the HCI_LE_EXTENDED_CREATE_CONNECTION_COMMAND.

I am not sure whether it is caused by the USB dongle or other reasons.

=== Connecting to FC:D0:33:FF:2F:20... DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_LE_CREATE_CONNECTION_COMMAND: le_scan_interval: 96 le_scan_window: 96 initiator_filter_policy: 0 peer_address_type: RANDOM_DEVICE_ADDRESS peer_address: FC:D0:33:FF:2F:20 own_address_type: RANDOM connection_interval_min: 12 connection_interval_max: 24 max_latency: 0 supervision_timeout: 72 min_ce_length: 0 max_ce_length: 0 DEBUG:bumble.host:### CONTROLLER -> HOST: HCI_COMMAND_STATUS_EVENT: status: PENDING num_hci_command_packets: 2 command_opcode: HCI_LE_CREATE_CONNECTION_COMMAND

Most likely here you're trying to connect to a random address that doesn't exist. If the device you're connecting to has LE privacy enabled (most phones and devices would have), their BLE random address changes periodically (typically every 15 minutes or so, plus every time a connection is established). So unless you're paired the devices (in which case the scanner can resolve those changing random addresses back to a fixed one), you'll need to scan and find out the current address of your target device each time before connecting to it.

@joyhope
Copy link
Author

joyhope commented Dec 23, 2023

I tried pair

`sudo ../venv/bin/python pair.py --mode le --sc true --mitm false device1.json usb:0 DF:85:B6:69:32:A6
<<< connecting to HCI...
<<< connected
=== Connecting to DF:85:B6:69:32:A6...
<<< Connection: Connection(handle=0x0E01, role=CENTRAL, address=DF:85:B6:69:32:A6)
***-----------------------------------
*** Pairing starting
***-----------------------------------
Traceback (most recent call last):
File "...bumble/apps/pair.py", line 404, in pair
await connection.pair()
File "...bumble/venv/lib/python3.10/site-packages/bumble/device.py", line 811, in pair
return await self.device.pair(self)
File "...bumble/venv/lib/python3.10/site-packages/bumble/device.py", line 2661, in pair
return await self.smp_manager.pair(connection)
File "...bumble/venv/lib/python3.10/site-packages/bumble/smp.py", line 1970, in pair
return await session.pair()
File "...bumble/venv/lib/python3.10/site-packages/bumble/smp.py", line 1288, in pair
await self.connection.abort_on('disconnection', self.pairing_result)
asyncio.exceptions.CancelledError: abort: disconnection event occurred.

During handling of the above exception, another exception occurred:
`

I found the mouse will disconnect , and make active connect aagain. (I am not sure for this.)

@joyhope
Copy link
Author

joyhope commented Dec 23, 2023

If runs without connect

sudo ../venv/bin/python pair.py device1.json usb:0 <<< connecting to HCI... <<< connected ^C

Nothing happened.

i use scan find the address, and then make pare. I test two different logi mice, the result is the same. I'm pretty sure all the mice with security connection features.

Bumble is the most easy to use tool, I hope it could work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants