50ButtonsEach / fliclib-linux-dist

114 stars 19 forks source link

Possible issue when more than 1 bluetooth controllers on PC #30

Open Ziemowit opened 8 years ago

Ziemowit commented 8 years ago

Hi!

I have the newest up-to date Ubuntu 15.10. My PC has built in bluetooth controller 2.1. I have bought also USB bluetooth controller stick 4.0 which is compatible with Your button to be able to connect with it.

Everything is working on my 1st computer where I have no built in bluetooth. So only USB bluetooth used (version 4.0). But on my 2nd computer when built in bluetooth exists (version 2.1) it does not even if I plug in USB bluetooth (version 4.0)...

$: hciconfig -a


hci1:   Type: BR/EDR  Bus: USB
    BD Address: 00:27:13:F3:5F:84  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING 
    RX bytes:3326 acl:0 sco:0 events:100 errors:0
    TX bytes:4021 acl:0 sco:0 commands:81 errors:0
    Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x79 0x83
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
    Link policy: RSWITCH HOLD SNIFF PARK 
    Link mode: SLAVE ACCEPT 
    Name: 'ziemowit-ESGroup'
    Class: 0x4c010c
    Service Classes: Rendering, Capturing, Telephony
    Device Class: Computer, Laptop
    HCI Version: 2.1 (0x4)  Revision: 0x168
    LMP Version: 2.1 (0x4)  Subversion: 0x4203
    Manufacturer: Broadcom Corporation (15)

hci0:   Type: BR/EDR  Bus: USB
    BD Address: 5C:F3:70:6D:7A:F9  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING 
    RX bytes:4190 acl:0 sco:0 events:153 errors:0
    TX bytes:5640 acl:0 sco:0 commands:153 errors:0
    Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
    Link policy: RSWITCH SNIFF 
    Link mode: SLAVE ACCEPT 
    Name: 'ziemowit-ESGroup #1'
    Class: 0x4c010c
    Service Classes: Rendering, Capturing, Telephony
    Device Class: Computer, Laptop
    HCI Version: 4.0 (0x6)  Revision: 0x1000
    LMP Version: 4.0 (0x6)  Subversion: 0x220e
    Manufacturer: Broadcom Corporation (15)

When I do startScan no error appears:


Successfully created D-Bus connection
Successfully created D-Bus object manager
Manager: checkObjects
Manager: new adapter, 00:27:13:F3:5F:84
Adapter: setProxies
Successfully registered profile
Manager: new adapter, 5C:F3:70:6D:7A:F9
Adapter: setProxies
Successfully registered profile
Successfully watching D-Bus
...
Starting scan
Successfully started scan

but clicking on the button gives nothing. Button is not scanned...

When I am checking the output of the bluetooth service it seems that only old controller is used for scanning (hci1 type 1 discovering 1 method 0 - no information about discovering by hci0) :


bluetoothd[3243]: src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 0
bluetoothd[3243]: src/adapter.c:start_discovery_complete() status 0x00
bluetoothd[3243]: src/adapter.c:discovering_callback() hci1 type 1 discovering 1 method 0
bluetoothd[3243]: src/adapter.c:discovering_callback() hci1 type 1 discovering 0 method 0
bluetoothd[3243]: src/adapter.c:trigger_start_discovery() 
bluetoothd[3243]: src/adapter.c:start_discovery_timeout() 
bluetoothd[3243]: src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 0
bluetoothd[3243]: src/adapter.c:start_discovery_complete() status 0x00
bluetoothd[3243]: src/adapter.c:discovering_callback() hci1 type 1 discovering 1 method 0
bluetoothd[3243]: src/adapter.c:discovering_callback() hci1 type 1 discovering 0 method 0
bluetoothd[3243]: src/adapter.c:trigger_start_discovery() 
bluetoothd[3243]: src/adapter.c:start_discovery_timeout() 
bluetoothd[3243]: src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 0
bluetoothd[3243]: src/adapter.c:start_discovery_complete() status 0x00
bluetoothd[3243]: src/adapter.c:discovering_callback() hci1 type 1 discovering 1 method 0
bluetoothd[3243]: src/adapter.c:device_found_callback() hci1 addr 5C:AC:4C:CD:C8:58, rssi -64 flags 0x0000 eir_len 39
bluetoothd[3243]: src/device.c:device_create() dst 5C:AC:4C:CD:C8:58
bluetoothd[3243]: src/device.c:device_new() address 5C:AC:4C:CD:C8:58
bluetoothd[3243]: src/device.c:device_new() Creating device /org/bluez/hci1/dev_5C_AC_4C_CD_C8_58
bluetoothd[3243]: src/device.c:device_set_legacy() legacy 0
bluetoothd[3243]: src/device.c:device_set_rssi_with_delta() rssi -64
bluetoothd[3243]: src/device.c:device_set_tx_power() tx_power 0
bluetoothd[3243]: src/device.c:device_set_class() /org/bluez/hci1/dev_5C_AC_4C_CD_C8_58 0x0C010C
bluetoothd[3243]: src/adapter.c:discovering_callback() hci1 type 1 discovering 0 method 0
bluetoothd[3243]: src/adapter.c:trigger_start_discovery() 
bluetoothd[3243]: src/adapter.c:start_discovery_timeout() 
bluetoothd[3243]: src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 0
bluetoothd[3243]: src/adapter.c:start_discovery_complete() status 0x00
bluetoothd[3243]: src/adapter.c:discovering_callback() hci1 type 1 discovering 1 method 0
bluetoothd[3243]: src/adapter.c:device_found_callback() hci1 addr 5C:AC:4C:CD:C8:58, rssi -73 flags 0x0000 eir_len 39
bluetoothd[3243]: src/device.c:device_set_legacy() legacy 0
bluetoothd[3243]: src/device.c:device_set_rssi_with_delta() rssi -73 delta 9
^Cbluetoothd[3243]: Terminating
bluetoothd[3243]: src/adapter.c:adapter_shutdown() 
bluetoothd[3243]: src/adapter.c:set_mode() sending set mode command for index 1
bluetoothd[3243]: src/adapter.c:set_mode() sending set mode command for index 0
bluetoothd[3243]: src/adapter.c:discovering_callback() hci1 type 1 discovering 0 method 0

My thought was - hmm maybe it uses wrong controller for scan. SO I do:

sudo hciconfig hci1 down

to make down this old 2.1 controller and leave up hci0. But then when I make startScan I receive error:

Failed to start scan: GDBus.Error:org.bluez.Error.NotReady: Resource Not Ready, 36

Why it returns error when 2nd controller (bluetooth 4.0) is still up and ready for use?

hci1:   Type: BR/EDR  Bus: USB
    BD Address: 00:27:13:F3:5F:84  ACL MTU: 1021:8  SCO MTU: 64:1
    DOWN 
    RX bytes:7706 acl:0 sco:0 events:247 errors:0
    TX bytes:9231 acl:0 sco:0 commands:216 errors:0

hci0:   Type: BR/EDR  Bus: USB
    BD Address: 5C:F3:70:6D:7A:F9  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING 
    RX bytes:9399 acl:0 sco:0 events:432 errors:0
    TX bytes:13775 acl:0 sco:0 commands:432 errors:0

I don't have any idea where the problem on the 2nd computer may be :/ Did I provide enough amount of information?

richbeales commented 8 years ago

I'm in the same boat - I have to use bluetoothctl application, and type 'select 5C:F3:70:6D:7A:F9' to make bluetoothd use the right controller as default

fabianbergmark commented 8 years ago

I have been a bit overwhelmed the last two weeks. I will go trough all the feedback and make a new release as soon as possible!

Ziemowit commented 8 years ago

Heh thanks. After select appropriate adapter and turn on scanning via bluetoothctl it works.

@fabianbergmark maybe the logic should be like:

allBluetoothControllers.filter( e.controllerCanHandleBluetoothVersion_4_0() ).findFirst()?

or

allBluetoothControllers.filter( e -> e.isRunning() && e.controllerCanHandleBluetoothVersion_4_0() ).findFirst()?

But as the owner of the code for sure You know better! :) Thanks for willing to fix it!

Ziemowit commented 8 years ago

Is there any update according to this issue?