Enabling Bluetooth discoverability upon start-up

26,045

You could try this:

Add the bash command hciconfig hci0 piscan in the /etc/rc.local (before the last line of "exit 0").

Note: any bash command you add to the /etc/rc.local will execute without the environment variables being loaded yet. So used absolute paths!

Share:
26,045

Related videos on Youtube

Bruno
Author by

Bruno

Updated on September 18, 2022

Comments

  • Bruno
    Bruno over 1 year

    I would like to make a USB Bluetooth dongle discoverable upon start-up (or whenever it's plugged in) on Debian Squeeze or Wheezy.

    If I use hciconfig initially, I can see the device in this mode:

        UP RUNNING PSCAN
    

    Using hciconfig hci0 piscan manually works fine. This puts the device in this mode (and the device can be discovered):

        UP RUNNING PSCAN ISCAN
    

    A number of documents (for example, on the Debian wiki or this Ubuntu issue) point to settings in /etc/bluetooth/hcid.conf. It would seem that setting iscan enable; pscan enable; in this file should work. Unfortunately, the versions of Bluez I'm using (4.x) don't have this file (even with the bluez-compat package installed).

    /etc/bluetooth/main.conf says:

    # How long to stay in discoverable mode before going back to non-discoverable
    # The value is in seconds. Default is 180, i.e. 3 minutes.
    # 0 = disable timer, i.e. stay discoverable forever
    DiscoverableTimeout = 0
    

    This doesn't work, though. The device starts up in PSCAN mode, but not PSCAN ISCAN.

    Even manually, the following command taken from the Debian wiki doesn't work:

    dbus-send --system --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable
    

    Is there a recommended way to set the device in PSCAN ISCAN mode upon start-up (or when the dongle is inserted)?

  • Bruno
    Bruno about 9 years
    Sorry about the delay, I hadn't noticed the answers... As I was saying in the question, I can do that manually and it works, I was looking for something more dynamic in terms of configuration.
  • Bruno
    Bruno about 9 years
    Sorry about the delay, I hadn't noticed the answers... That would work fine upon start-up, but not if you plug in the USB dongle later.
  • Alex
    Alex over 8 years
    Sorry, a bit late, probably a udev rule would have solved.
  • wojciii
    wojciii over 8 years
    I was expecting the following udev rule to work: ACTION=="add", KERNEL=="hci1", RUN+="/usr/sbin/hciconfig hci1 piscan; /usr/sbin/hciconfig hci1 name LubaLuft1" with USB bluetooth devices but it was executed and had no effect. I think that an upstart job is required (or similar (I'm using Ubuntu)).