3

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)?

3

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!

| improve this answer | |
  • 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. – Bruno Feb 19 '15 at 1:16
  • Sorry, a bit late, probably a udev rule would have solved. – Alex Aug 15 '15 at 19:31
  • 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)). – wojciii Dec 16 '15 at 9:26
0

At this time, there is another option in the Debian Wiki:

hciconfig hci0 piscan

This works for me.

Unfortunately I have still do not found how to setup pin code for local device. (may be is it my light English knowledge, but in many documents out there I'm confused what pin they are talking about).

| improve this answer | |
  • 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 Feb 19 '15 at 1:15
0

The argument for bluetooth-agent sets the PIN.

Now append the following to /etc/inittab (using nano - and substituting for your own):

#Bluetooth Channel 22
PA22:23:respawn:/usr/bin/bluetooth-agent 1234
BS22:23:once:/usr/bin/sdptool add --channel=22 SP
BT22:23:once:/usr/bin/rfcomm -r watch 0 22 /sbin/agetty -L rfcomm0 115200

See also this question.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.