WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Bluetooth problem  (Read 9451 times)

Offline bukashka

  • Newbie
  • *
  • Posts: 18
Bluetooth problem
« on: September 04, 2016, 01:35:43 PM »
Hi all! I have problem with pairing with HC-06 BT module. In bluez.tcz info I have find this:
                Howto pair:
                $ echo "0000" | simple-agent hci0 00:1B:66:00:31:88 [0000 for a bt headset]
but when I try to run this script I have message:
ImportError: libgiropositary-1.0.so.1: cannot open shared object file: No such file or directory.
May be somebody knows what my problem is? Is there most simple way to pair with BT module and communicate through virtual serial port? Thanks for any help!

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Bluetooth problem
« Reply #1 on: September 05, 2016, 12:29:38 AM »
It looks like you need to load the gobject-introspection extension.

Note that you can also use the blueman gui.

Offline bukashka

  • Newbie
  • *
  • Posts: 18
Re: Bluetooth problem
« Reply #2 on: September 05, 2016, 01:51:47 AM »
After loading gobject-introspection extension I have new Import Error: /usr/local/lib/libgmodule-2.0.0.so.0: undefined symbol: g_rec_mutex_lock
pygobject was installed. Is any idea?
BTW, as I can see, blueman was removed from 5.x TCE. Now I use exactly 5.2 environment..

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Bluetooth problem
« Reply #3 on: September 05, 2016, 03:19:12 AM »
Assuming you have dbus-python and pygobject (and their deps) loaded..

..and the dbus and bluetooth daemons started, it should work.

However, it would perhaps be easier to update to tc-7.2.

Offline bukashka

  • Newbie
  • *
  • Posts: 18
Re: Bluetooth problem
« Reply #4 on: September 05, 2016, 04:36:56 AM »
Juanito, thanks a lot for your help. dbus is loaded, but when I try to start bluez (sudo /usr/local/etc/init.d/bluez start) I get the message:
no /usr/local/bin/dbus-daemon found; none killed
rm: can't remove '/var/run/dbus/pid': No such file or directory

Although /usr/local/bin/dbus-daemon exists.. What happens?

Update to 7.2 is last chance for me, but preferable stay on 5.2

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Bluetooth problem
« Reply #5 on: September 05, 2016, 04:44:09 AM »
no /usr/local/bin/dbus-daemon found; none killed
rm: can't remove '/var/run/dbus/pid': No such file or directory

This usually happens the first time you start the bluetooth daemon - basically a (not very elegant) script tests if the dbus daemon is running and, if not (you get the error messages), starts it

You can check if both daemons are running using:
Code: [Select]
$ ps aux | grep dbus
$ ps aux | grep blue

Offline bukashka

  • Newbie
  • *
  • Posts: 18
Re: Bluetooth problem
« Reply #6 on: September 05, 2016, 05:39:20 AM »
Both ps return result (as I understand I have dbus and blue processes loaded). Although sudo /usr/local/etc/init.d bluez status return "bluetoothd is not running."

Offline bukashka

  • Newbie
  • *
  • Posts: 18
Re: Bluetooth problem
« Reply #7 on: September 05, 2016, 06:03:04 AM »
BTW, when I try to scan BT modules I get the right result. TCL enumerate all avialable BT devices. But pairing with simple-agent not success. Because I need to communicate with BT device through serial (rfcomm), Is there another way to pair?

after sudo rfcomm bind /dev/rfcomm0 11:22:33:44:55:66 device not connected.
after this technique on ubuntu system ask me for PIN code of my device. After I wrote right pin device connect. In TCL I have not request for PIN and my suggest is why I can't connect with BT device (HC-06 module).

Very appreciate for any suggestion!!

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Bluetooth problem
« Reply #8 on: September 05, 2016, 06:04:07 AM »
I just tested on x86 tc-7.2:

Code: [Select]
$ tce-load -i bluez dbus-python pygobject

$ sudo /usr/local/etc/init.d/bluez start
no /usr/local/bin/dbus-daemon found; none killed
rm: can't remove '/var/run/dbus/pid': No such file or directory

$ sudo /usr/local/etc/init.d/bluez status
bluetoothd is running

$ hcitool scan [find address of bluetooth device]
Scanning ...
        00:1B:66:00:31:88       Sennheiser PXC310BT

[put headphones into pairing mode - flash blue and red to confirm pairing mode]
$ echo "0000" | simple-agent hci0 00:1B:66:00:31:88 [to pair]
Release
New device (/org/bluez/6362/hci0/dev_00_1B_66_00_31_88)
[headphones flash blue only to confirm paired]

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Bluetooth problem
« Reply #9 on: September 05, 2016, 06:12:07 AM »
I'm not sure what version of bluez ubuntu uses, but there is a significant difference in the commands used with bluez-4 (x86 tc-7.2) and bluez-5 (x86_64 tc-7.2).

The example I used below works (with bluez-4) because the PIN for headphones is always "0000". Where the device has a different PIN that is generated when a pairing request is received, the command sequence is probably different.

You'll probably need some serious google foo to find the correct command sequence, so I'd recommend using the blueman gui if at all possible.

Of course if you like a challenge...

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Bluetooth problem
« Reply #10 on: September 05, 2016, 06:28:56 AM »
see screenshot attached showing blueman being used to direct audio output to bluetooth headphones.

This and what you are trying to achieve would be really non-obvious without a gui  :(

Offline bukashka

  • Newbie
  • *
  • Posts: 18
Re: Bluetooth problem
« Reply #11 on: September 05, 2016, 06:31:55 AM »
My device always have pin "1234" so this sequence is acceptable. But as I wrote, simple-agent hci0 cause Import Error.

BTW, Is it normal to have not running bluetoothd daemon and correct result of hcitool scan (in my example)?

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Bluetooth problem
« Reply #12 on: September 05, 2016, 06:38:39 AM »
"hcitool scan" will not work if the bluetooth daemon is not running.

Note that it would be better to use "ps aux | grep blue" to test if the daemon is running or not.

I haven't got x86 tc-5.2 to test, but referring to the error "/usr/local/lib/libgmodule-2.0.0.so.0: undefined symbol: g_rec_mutex_lock", did you see it again or did loading all required extensions cure this?

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: Bluetooth problem
« Reply #13 on: September 05, 2016, 06:49:05 AM »
Would modifying this file help:
Code: [Select]
$ cat /usr/local/etc/bluetooth/rfcomm.conf
#
# RFCOMM configuration file.
#

#rfcomm0 {
#       # Automatically bind the device at startup
#       bind no;
#
#       # Bluetooth address of the device
#       device 11:22:33:44:55:66;
#
#       # RFCOMM channel for the connection
#       channel 1;
#
#       # Description of the connection
#       comment "Example Bluetooth device";
#}

Offline bukashka

  • Newbie
  • *
  • Posts: 18
Re: Bluetooth problem
« Reply #14 on: September 05, 2016, 07:13:30 AM »
I still have Import Error even after install extension: dbus-python, pygobject and gobject-introspection

When I manually edit rfcomm.conf and after:
sudo rfcomm bind /dev/rfcomm0 hci0 11:22:33:44:55:66 1 (Indeed real mac)
sudo rfcomm connect /dev/rfcomm0 11:22:33:44:55:66 1
I get: Can't connect RFCOMM socket: Connection refused