50ButtonsEach / fliclib-linux-dist

114 stars 19 forks source link

Connecting issues #14

Open CheapB opened 8 years ago

CheapB commented 8 years ago

I dont think this is a general problem, but I have a hard time getting this to connect after having it working - any ideas:

sudo ./bluetoothd -nEd deamon is running interface up with sudo hciconfig hci0 up

This is what I am getting - an no reaction to button presses: list 80:E4:DA:70:0E:A1 [Disconnected] connect Connecting to: 80:E4:DA:70:0E:A1 Connected to: 80:E4:DA:70:0E:A1 Disconnecting from: 80:E4:DA:70:0E:A1 Disconnected from: 80:E4:DA:70:0E:A1

fabianbergmark commented 8 years ago

I need to see the daemon output

CheapB commented 8 years ago

deamonlog.txt

richbeales commented 8 years ago

Try using bluetoothctl and issue the 'power off' then 'power on' commands. I also used 'scan on' while trying to connect. It seemed to help

fabianbergmark commented 8 years ago

I still struggle to fix this connection failure. I think it's caused by a bug in bluez. As @richbeales said, 'power off' followed by 'power on' in bluetoothctl usually solves it.

CheapB commented 8 years ago

You may be right that it is a bluez issue. I am getting same behavior as this: http://unix.stackexchange.com/questions/169931/bluetoothctl-no-default-controller-available

Reboot does not help.

I had to working for a day or so and I dont think I have changed anything.

fabianbergmark commented 8 years ago

Have you tried re-plugging the bluetooth USB adapter?

fabianbergmark commented 8 years ago

@CheapB Do you still experience issues?

CheapB commented 8 years ago

Still have the same issues, but have not tried the bluez patches yet.

richbeales commented 8 years ago

The bluez patches worked for me On 9 Feb 2016 02:35, "CheapB" notifications@github.com wrote:

Still have the same issues, but have not tried the bluez patches yet.

— Reply to this email directly or view it on GitHub https://github.com/50ButtonsEach/fliclib-linux-dist/issues/14#issuecomment-181675009 .

CheapB commented 8 years ago

Patch installed and seems to be working. Some of the issues did not show up until after hours of use so I will report back when I have more data

CheapB commented 8 years ago

I have been running this for a few days no w/o a crash or a need to reboot or to manually bring up the bt device, So I am going to close this issue in a few days unless we see more comments

ryjogo commented 8 years ago

I'm having the same issue here:

Button::gdBusDeviceSignalCallback, message received: PropertiesChanged [80:E4:DA:70:C1:3B]('org.bluez.Device1', {'Connected': }, @as []) [80:E4:DA:70:C1:3B] check [80:E4:DA:70:C1:3B] Connecting -> Disconnecting [80:E4:DA:70:C1:3B] Button disconnecting [80:E4:DA:70:C1:3B] close [80:E4:DA:70:C1:3B] cancelCalls [80:E4:DA:70:C1:3B] stopCharacteristics [80:E4:DA:70:C1:3B] check [80:E4:DA:70:C1:3B] Disconnecting -> Disconnected [80:E4:DA:70:C1:3B] Button disconnected [80:E4:DA:70:C1:3B] check [80:E4:DA:70:C1:3B] Button::gdBusDeviceSignalCallback, message received: PropertiesChanged [80:E4:DA:70:C1:3B]('org.bluez.Device1', {'Connected': }, @as []) [80:E4:DA:70:C1:3B] check [80:E4:DA:70:C1:3B] Disconnected -> Connecting [80:E4:DA:70:C1:3B] Button connecting [80:E4:DA:70:C1:3B] check [80:E4:DA:70:C1:3B]

I've had it connected once.. however now it never really seems to connect:

root@raspberrypi:/home/ryan# hciconfig hci0: Type: BR/EDR Bus: USB BD Address: 5C:F3:70:76:B4:26 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING RX bytes:11103 acl:142 sco:0 events:738 errors:0 TX bytes:7510 acl:142 sco:0 commands:409 errors:1

root@raspberrypi:/home/ryan# service bluetooth status ● bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled) Active: active (running) since Wed 2016-02-17 14:40:05 UTC; 11min ago Docs: man:bluetoothd(8) Main PID: 957 (bluetoothd) Status: "Running" CGroup: /system.slice/bluetooth.service └─957 /usr/lib/bluetooth/bluetoothd

Feb 17 14:49:30 raspberrypi bluetoothd[957]: g_attrib_unregister: invalid id Feb 17 14:49:40 raspberrypi bluetoothd[957]: g_attrib_unregister: invalid id Feb 17 14:49:50 raspberrypi bluetoothd[957]: g_attrib_unregister: invalid id Feb 17 14:50:01 raspberrypi bluetoothd[957]: g_attrib_unregister: invalid id Feb 17 14:50:11 raspberrypi bluetoothd[957]: g_attrib_unregister: invalid id

Which patches have you installed?

fabianbergmark commented 8 years ago

Usually this fixes itself if you restart all the applications. Im still looking for bugs in the SDK, and this might be one of them.

ryjogo commented 8 years ago

Yeah i've restarted all aplications, even rebooted and changed the USB Bluetooth controller to another port. I can't seem to get this back up and running.

I think i will revert my SD card back to the vanilla installation and try a fresh install - i'm not too good with debugging bluetooth devices/connections.

CheapB commented 8 years ago

Only way I got out of this was to go back to a Vanilla image and then follow the guide. The patches for Bluez are in the current master

ryjogo commented 8 years ago

I've re-installed the vanilla image, and had it working most of the day. However i've just installed bluez and bluetooth via apt-get install - and added the -E flag to the service, reloaded the daemon and can confirm the bluetooth service is working OK.

However, the button now refuses to connect again..

`Feb 18 12:51:02 raspberrypi bluetoothd[1429]: ATT bt_io_connect(80:E4:DA:70:C1:3B): connect: No route to host (113)

Feb 18 12:52:58 raspberrypi bluetoothd[1429]: ATT bt_io_connect(80:E4:DA:70:C1:3B): connect: No route to host (113)`

Bluez Version: 5.23-2+b1

CheapB commented 8 years ago

It seems like you are running an old version of Bluez (5.23). Bluez was patched within the last weeks to make it stable working with Flic. I would suggest to download the lates version and compile on your system. Details are in the installation guide.

ryjogo commented 8 years ago

Of course, thanks. I just re-installed the new one.. seems to work OK. Any idea on how to daemonize the self compiled verison?

CheapB commented 8 years ago

I was planning on writing it up, but I have very limited time over the next weeks. You may get some hints here.. http://www.linuxfromscratch.org/blfs/view/svn/general/bluez.html

eisenbe7 commented 8 years ago

I'm also having connection issues. I'm running bluez 5.37 on a raspberry pi with Jessie with the recent patches.

The buttons will work great for about a day, and then they will all disconnect. The only way to reconnect them it seems, is to restart the adapter, get the buttons into public mode, and reconnect to them individually using the flic binary.

There's a lot of noise in the daemon and in bluetoothd, but it seems like something is timing out somewhere. Daemon output is "Failed to connect: GDBus.Error:org.bluez.Error.Failed: Software caused connection abort, 36" and in bluetoothd, although I haven't been able to identify the exact logging statements corresponding to the disconnect, I'm seeing "connect error: Transport endpoint is not connected {107} and some devices disconnections with reasons 0 or 1. Anyone else encountering similar issues?

eisenbe7 commented 8 years ago

As an update, I tried using a different bluetooth adapter - the second one listed in the readme: "Broadcom BCM20702 Bluetooth 4.0" instead of the first. I've been running the script for a few hours and I have yet to get any timeouts or disconnects, whereas I would be getting them every few minutes with the old adapter. The connection process is also much smoother. If you are having connection or timeout issues, try using a different bluetooth adapter in your pi. I'd recommend in the readme, swapping the two tested adapters as the second one is working much better than the first.

eisenbe7 commented 8 years ago

Any update on a new release? I'm still experiencing crashes every few days. One or two buttons in my setup will be stuck in a Connecting or Disconnecting state, and I often need to restart everything to get things working again. If I try and just remove and re-add the buttons that are failing, the daemon crashes, with:

GLib-CRITICAL **: g_variant_unref: assertion 'value->ref_count > 0' failed

which appears to be coming from the notification code when the button is transmitting it's capabilities. This also crashes my bluetooth adapter.

fabianbergmark commented 8 years ago

This should be fixed on bluez HEAD. Sorry for not posting this here. A good idea is to rebuild bluez every second day or so :)