Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: The_f3l1x on December 27, 2020, 04:24:27 PM

Title: RPi4, Bluetooth and devices on boot
Post by: The_f3l1x on December 27, 2020, 04:24:27 PM
Hello,

after a bit of fighting with my rpi, I've finally managed to connect a bluetooth keyboard to the system, and to initialize the BT subsystem on boot. WOHO!

Thank you everyone for the great guides. :)

For the question in the topic: How do I wait for the internal pi's bluetooth (as in a script) to be ready before powering it on with

Code: [Select]
bluetoothctl power on
also, will a paired device connect automatically if in range? Or I have to trigger something on the Pi?

Thank you in advance!
Title: Re: RPi4, Bluetooth and devices on boot
Post by: Paul_123 on December 27, 2020, 04:40:20 PM
normally you just have to turn on the "trust" for the device.

Done in bluetoothctl
Title: Re: RPi4, Bluetooth and devices on boot
Post by: Rich on December 27, 2020, 04:41:50 PM
Hi The_f3l1x
Maybe this is of some use:
http://forum.tinycorelinux.net/index.php/topic,24427.msg154846.html#msg154846
Be sure to read reply #8 too.
Title: Re: RPi4, Bluetooth and devices on boot
Post by: The_f3l1x on December 27, 2020, 04:52:59 PM
Quote from: Rich
Hi The_f3l1x
Maybe this is of some use:
http://forum.tinycorelinux.net/index.php/topic,24427.msg154846.html#msg154846
Be sure to read reply #8 too.

normally you just have to turn on the "trust" for the device.

Done in bluetoothctl

Hi Paul, hi Rich, thank you for the quick replies.

@Rich: that's the guide I followed :)

@both: The whole initialization procedure works fine and if I get into bluetoothctl after a reboot the trusted status of the device seems to "stick", although not only it never connects automatically again, I seem to need to "power on" the internal BT again :/

any ideas?
Title: Re: RPi4, Bluetooth and devices on boot
Post by: The_f3l1x on December 27, 2020, 04:57:49 PM
Just checked again (I thought I had missed a step) and just after boot if I do

Code: [Select]
bluetoothctl
and then

Code: [Select]
show
I get

Code: [Select]
...
Powered: no
...
Title: Re: RPi4, Bluetooth and devices on boot
Post by: Rich on December 27, 2020, 05:20:25 PM
Hi The_f3l1x
Based on this thread:
http://forum.tinycorelinux.net/index.php/topic,23895.0.html
It looks like the  bluetoothctl  command can power it up.
Title: Re: RPi4, Bluetooth and devices on boot
Post by: The_f3l1x on December 27, 2020, 05:28:40 PM
Hi The_f3l1x
Based on this thread:
http://forum.tinycorelinux.net/index.php/topic,23895.0.html
It looks like the  bluetoothctl  command can power it up.

Hi Rich,

yeah, I found that topic too but it's talking about turning the power on manually, not automatically. I'm trying to get everything setup on boot, and I either need another way to turn on the card, or find some trigger that I can use in a script when the device firmware is loaded before i can power it on.

In my linux noobiness i tried

Code: [Select]
wc -l `bluetoothctl list`
but there's something I must be missing something 'cause[/s]

Solution found! I think I get a 1 on

Code: [Select]
bluetoothctl list | wc -l
when the device is ready to be powered up. I'll wait for that and trigger the power on. I

'll report back if it works for anyone with the same problem :)

Confirmed!
you can tell when to power up the internal BT card using bluetoothctl and wc :)

Now the problem of the keyboard not reconnecting on boot despite being trusted still remains..
Unless I need to persist something else other than /var/lib/bluetooth
Title: Re: RPi4, Bluetooth and devices on boot
Post by: Rich on December 27, 2020, 06:04:17 PM
Hi The_f3l1x
The only thing I've done with Buetooth involved an old Asus netbook. The netbooks keyboard is Bluetooth. I think this command
turned it on:
Code: [Select]
sudo hciconfig hci0 up
Title: Re: RPi4, Bluetooth and devices on boot
Post by: Paul_123 on December 27, 2020, 07:27:36 PM
I guess I did not give away all my secrets in that previous outline.

bluetoothctl can run interactively or process commandline.  You do need to wait for the controller to populate before executing power up.

Code: [Select]
bluetoothctl power on

If you had more than one controller, it might be a bit more difficult.  Then you might want to play with dbus.....  This will also power on the controller.

Code: [Select]
gdbus call -y -d "org.bluez" -o "/org/bluez/hci0" -m "org.freedesktop.DBus.Properties.Set" "org.bluez.Adapter1" "Powered" "<true>"
Title: Re: RPi4, Bluetooth and devices on boot
Post by: The_f3l1x on December 27, 2020, 07:30:58 PM
Hi The_f3l1x
The only thing I've done with Buetooth involved an old Asus netbook. The netbooks keyboard is Bluetooth. I think this command
turned it on:
Code: [Select]
sudo hciconfig hci0 up

That seems a different way to turn on the internal BT card. I'll keep looking around but if I can't find anything else I guess I'll either have to go wired or trigger the connection differently, like on a timer. Thank you anyway :)
Title: Re: RPi4, Bluetooth and devices on boot
Post by: Paul_123 on December 27, 2020, 07:32:51 PM
I've run into auto connection issues before with audio devices.  Does powering up the keyboard after the system is booted and the controller is started work?


If not use a script to do the connection for you....
Title: Re: RPi4, Bluetooth and devices on boot
Post by: The_f3l1x on December 27, 2020, 07:36:03 PM
I guess I did not give away all my secrets in that previous outline.

bluetoothctl can run interactively or process commandline.  You do need to wait for the controller to populate before executing power up.

Code: [Select]
bluetoothctl power on

If you had more than one controller, it might be a bit more difficult.  Then you might want to play with dbus.....  This will also power on the controller.

Code: [Select]
gdbus call -y -d "org.bluez" -o "/org/bluez/hci0" -m "org.freedesktop.DBus.Properties.Set" "org.bluez.Adapter1" "Powered" "<true>"

Hi Paul,

I managed to power on the device on boot, since I'm planning on only having one BT card on this Pi my system works fine :)

I'm now trying to connect to the bt keyboard once the card is powered up, but I can't seem to find a way. It's both paired and trusted, even after a reboot, but no connection, even after power cycling the keyboard itself..

Would a infinite loop waiting for the keyboard to show up work?