d-aro
Posts: 6
Joined: Tue May 10, 2016 8:49 am

Bluetooth not ready in init.d Script?

Wed May 11, 2016 1:27 pm

Well... I just installed the last raspian Wheezy 2016-05-05
(I did the same below last year with all the same steps and it worked)

Updated everything and installed these Packages

Code: Select all

sudo apt-get install bluetooth bluez-utils blueman cups obexpushd
In the init.d I made a script which includes following commands:

Code: Select all

sudo hciconfig hci0 name "BTName"
sudo hciconfig hci0 sspmode 0
sudo hciconfig hci0 piscan
sudo /usr/bin/bluetooth-agent 1234 &
But Bluetooth is not comming after boot! I can restart the script then and everything works fine!

So i installed bootlogd to check the output of the script on boot. This is what I get:

Code: Select all

Wed May 11 14:58:34 2016: [....] Starting NTP server: ntpd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Wed May 11 14:58:34 2016: [....] Starting periodic command scheduler: cron^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Wed May 11 14:58:34 2016: [....] Starting OpenBSD Secure Shell server: sshd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Wed May 11 14:58:34 2016: [....] Starting system message bus: dbus^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Wed May 11 14:58:34 2016: [....] Starting bluetooth: bluetoothd rfcomm^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Wed May 11 14:58:34 2016: [....] Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Wed May 11 14:58:34 2016: saned disabled; edit /etc/default/saned
Wed May 11 14:58:34 2016: setting bluetooth discoverable
Wed May 11 14:58:34 2016: Can't change local name on hci0: Network is down (100)
Wed May 11 14:58:34 2016: Can't set Simple Pairing mode on hci0: Network is down (100)
Wed May 11 14:58:34 2016: Can't set scan mode on hci0: Network is down (100)
Wed May 11 14:58:34 2016: Can't get default adapter
Wed May 11 14:58:34 2016: No such adapter
Wed May 11 14:58:35 2016: [....] Starting Common Unix Printing System: cupsd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Wed May 11 14:58:35 2016: dhcpcd[1970]: version 6.7.1 starting
Wed May 11 14:58:35 2016: dhcpcd[1970]: all: IPv6 kernel autoconf disabled
Wed May 11 14:58:35 2016: dhcpcd[1970]: eth0: adding address fe80::9449:4637:137c:17c5
Wed May 11 14:58:35 2016: dhcpcd[1970]: if_addaddress6: Operation not supported
Wed May 11 14:58:35 2016: dhcpcd[1970]: DUID 00:01:00:01:1c:dd:60:5f:b8:27:eb:70:97:e1
Wed May 11 14:58:35 2016: dhcpcd[1970]: eth0: IAID eb:70:97:e1
Wed May 11 14:58:35 2016: dhcpcd[1970]: eth0: rebinding lease of 192.168.5.235
Wed May 11 14:58:44 2016: dhcpcd[1970]: eth0: leased 192.168.5.235 for 172800 seconds
Wed May 11 14:58:44 2016: dhcpcd[1970]: eth0: adding route to 192.168.5.0/24
Wed May 11 14:58:44 2016: dhcpcd[1970]: eth0: adding default route via 192.168.5.1
Wed May 11 14:58:44 2016: dhcpcd[1970]: forked to background, child pid 2402
It seems like the Bluetooth Adapter is not ready yet. But its started after /etc/init.d/bluetooth
Is there anything else I can check?

Thanks all

d-aro
Posts: 6
Joined: Tue May 10, 2016 8:49 am

Re: Bluetooth not ready in init.d Script?

Wed May 11, 2016 2:08 pm

After a lot of trying and trying...

By just connectin the Bluetooth Adapter into any of the other USB Ports everything works fine.
Connecting it Back to the first one and rebooting gives the same error again!

But the port can't be damaged, because after login and restarting the script everything works fine too!

Confusing, but the problem seems solved for now!

d-aro
Posts: 6
Joined: Tue May 10, 2016 8:49 am

Re: Bluetooth not ready in init.d Script?

Thu May 12, 2016 1:02 pm

I'm still having some troubles... :(

I'ts only while booting up.

If i do a

Code: Select all

hcitool dev
in the init.d script it shows no devices MAC in bootlog.

but after a login via ssh and manually executing the command it shows the devices MAC address and everything is good.

Anyone here that knows how to wait until bluetooth dongle is ready in the script?

thanks all

d-aro
Posts: 6
Joined: Tue May 10, 2016 8:49 am

Re: Bluetooth not ready in init.d Script?

Thu May 12, 2016 1:22 pm

Current workaround I did is letting the script run after ALL others with Required-Start: $ALL
It does not seem to be the best way to do it. So any further help would be nice

Code: Select all

### BEGIN INIT INFO
# Provides:        myScript
# Required-Start: $ALL

Aydan
Posts: 729
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Bluetooth not ready in init.d Script?

Thu May 12, 2016 1:53 pm

You could try with a udev rule which executes your script when udev loads the driver for the bluetooth module.

Regards
Aydan

Return to “Troubleshooting”