How to use bluez to connect the imx6dl controlled Bluetooth chip to mobile phone Bluetooth.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use bluez to connect the imx6dl controlled Bluetooth chip to mobile phone Bluetooth.

2,638 Views
weibinchi
Contributor II

hello

      I want to use bluez to connect the imx6dl controlled Bluetooth chip to mobile phone Bluetooth.

      My current Linux BSP version is 3.14.38 ;

      The bluez version is 5.28, and now bluez has been ported to imx6dl.

      Test with bluez tool bluetoothctl。The phenomenon is as follows:  

 root@imx6qsabresd:/# bluetoothctl
[NEW] Controller AA:AA:AA:AA:AA:AA %h-%d [default]
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# pair EC:D0:9F:A0:AC:42
Device EC:D0:9F:A0:AC:42 not available
[bluetooth]# scan on
Discovery started
[CHG] Device 7C:AB:9F:9F:1F:07 RSSI: -89
[NEW] Device EC:D0:9F:A0:AC:42 hongmi
[bluetooth]# pair EC:D0:9F:A0:AC:42
Attempting to pair with EC:D0:9F:A0:AC:42
[CHG] Device EC:D0:9F:A0:AC:42 Connected: yes
Request confirmation
[agent] Confirm passkey 335361 (yes/no): yes
[CHG] Device EC:D0:9F:A0:AC:42 Modalias: bluetooth:v001Dp1200d1436
[CHG] Device EC:D0:9F:A0:AC:42 UUIDs:
00001105-0000-1000-8000-00805f9b34fb
0000110a-0000-1000-8000-00805f9b34fb
0000110c-0000-1000-8000-00805f9b34fb
0000110e-0000-1000-8000-00805f9b34fb
00001112-0000-1000-8000-00805f9b34fb
00001115-0000-1000-8000-00805f9b34fb
00001116-0000-1000-8000-00805f9b34fb
0000111f-0000-1000-8000-00805f9b34fb
0000112d-0000-1000-8000-00805f9b34fb
0000112f-0000-1000-8000-00805f9b34fb
00001132-0000-1000-8000-00805f9b34fb
00001200-0000-1000-8000-00805f9b34fb
00001800-0000-1000-8000-00805f9b34fb
00001801-0000-1000-8000-00805f9b34fb
[CHG] Device EC:D0:9F:A0:AC:42 Paired: yes
Pairing successful
[CHG] Device EC:D0:9F:A0:AC:42 Connected: no
[bluetooth]# connect EC:D0:9F:A0:AC:42
Attempting to connect to EC:D0:9F:A0:AC:42
Failed to connect: org.bluez.Error.Failed

Now I don't know what caused the connection error.

0 Kudos
10 Replies

2,305 Views
diegoadrian
NXP Employee
NXP Employee

Hello,

Could you please try the following:

First, modify the following file 

/usr/bin/start-pulseaudio-x11

add the following line:

   if [ x”$SESSION_MANAGER” != x ] ; then

        /usr/bin/pactl load-module module-x11-xsmp “display=$DISPLAY session_manager=$SESSION_MANAGER” > /dev/null

    fi

  +  /usr/bin/pactl load-module module-bluetooth-discover

Then turn on the Bluetooth module.

# hciconfig hci0 up

Then bring up manually the Bluetooth-discover module:

pactl load-module module-bluetooth-discover

After that, the Bluetooth service is ready to be used.

Whit that you should be able to connect with your mobile device.

Hope this could help you.

Best regards,

Diego.

0 Kudos

2,305 Views
weibinchi
Contributor II

Hello

       I find that I did not transplant pulseaudio.So I follow the instructions in the connection documentation:https://community.nxp.com/docs/DOC-103385,but I use pulseaudio  version is 8.0.

       I tried to execute the command “pulseaudio --system --realtime & ”, start pulseaudio. But the error is as follows:

 root@imx6qsabresd:/etc# pulseaudio --system --realtime &

27683

root@imx6qsabresd:/etc# W: main.c: Running in system mode, but --disallow-exit not set.

W: main.c: Running in system mode, but --disallow-module-loading not set.

N: main.c: Running in system mode, forcibly disabling SHM mode.

W: main.c: OK, so you are running PA in system mode. Please note that you most likely shouldn't be doing that.

W: main.c: If you do it nonetheless then it's your own fault if things don't work as expected.

W: main.c: Please read http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ for an explanation why system mode is usually a bad idea.

W: pid.c: Stale PID file, overwriting.

Inconsistency detected by ld.so: dl-open.c: 678: dlopen: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed!

     How to solve this?

0 Kudos

2,305 Views
diegoadrian
NXP Employee
NXP Employee

Hello

Did you try with the procedure that I commented on before?

Best regards,

Diego.

0 Kudos

2,305 Views
weibinchi
Contributor II

Hello diego

         I am trying to manually add the /usr/bin/start-pulseaudio-x11 file, and try with the procedure that you commented on before. But no effect, I feel that adding files doesn't work.

          In addition, I execute the following command: pactl load-module module-bluetooth-discover. The phenomenon is as follows:  

          root@imx6qsabresd:/# pactl load-module module-bluetooth-discover
          Home directory not accessible: Permission denied
          Connection failure: Connection refused
          pa_context_connect() failed: Connection refused

          root@imx6qsabresd:/# 

          What is going on here?

           Thanks

0 Kudos

2,305 Views
diegoadrian
NXP Employee
NXP Employee

Hello,

How did you add the Pulse audio libraries into your Yocto environment?

Best regards,

Diego.

0 Kudos

2,305 Views
weibinchi
Contributor II

Hello

      I add the Pulse audio libraries into my Yocto environment steps as follows:

      1.DISTRO=fsl-imx-wayland MACHINE=imx6sxsabresd source fsl-setup-release.sh -b build-wayland

      2.bitbake fsl-image-gui

      The yocto project uses linux kernel version is 4.1.15, but the kernel version of the actual project is 3.14.38.So I follow the instructions in the connection documentation:https://community.nxp.com/docs/DOC-103385, and copy the relevant libraries, tools and files generated by the above steps to the file system with kernel version 3.14.38.

      

0 Kudos

2,305 Views
diegoadrian
NXP Employee
NXP Employee

Hello,

You are only building the Yocto image. You are not adding the Bluez recipe into the local.conf

please add as following:

DISTRO_FEATURES_append += " bluez5"

Best regards,

Diego.

0 Kudos

2,305 Views
weibinchi
Contributor II

Hello

       Now I can connect the imx6dl controlled Bluetooth chip to mobile phone Bluetooth.

       I execute the command “/usr/libexec/bluetooth/obexd -r /mnt -a -n & ”, start the obexd service. I Successfully send text files to my phone with obexctl,but the following error occurred when sending a file on my phone to imx6:

obexd[833]: CONNECT(0x0), <unknown>(0xff)
obexd[833]: CONNECT(0x0), <unknown>(0x0)
obexd[833]: disconnected: Unicode conversion failed: Conversion from character set 'UTF-16BE' to 'UTF-8' is not supported

        How to solve this?

        Thank you!

       

0 Kudos

2,305 Views
diegoadrian
NXP Employee
NXP Employee

Hello,

I suggest you see the following community thread. Probably it could help you.

https://community.nxp.com/thread/510538 

Best regards,

Diego.

0 Kudos

2,305 Views
weibinchi
Contributor II

Hello Diego

         Thank  you for your answer.

        I did not find the start-pulseaudio-x11 file in my ported pulseaudio. So I did not  try with the procedure that you commented on before.

        Is there a problem with my transplanted pulseaudio?

        What should I pay attention to when transplanting pulseaudio?

         Thanks.

        

0 Kudos