louiscar
Posts: 19
Joined: Wed May 18, 2016 3:08 am

Can't get pi3 bluetooth working

Sat Mar 18, 2017 7:36 pm

I'm having a lot of trouble getting the bluetooth working on my new Pi3.

When I type the following no matter what I do I'll get this output:

Code: Select all

sudo hcitool lescan
Set scan parameters failed: File descriptor in bad state
I have followed the following articles to the letter and also done an rpi-update which appears to have updated the firmware.
viewtopic.php?uid=191342&f=63&t=141850&start=0
http://www.techradar.com/how-to/computi ... -3-1316938

There is one thing that seems a little clue here but not sure.
In the graphical interface I see two bluetooth icons - one is greyed out and the other is blue with a cross on it.

After right-clicking the blue one there's an option to turn it on which I do seemingly successfully but there are no options to scan or 'make discoverable' and if I click on devices it says 'no adapters found'.

The greyed out one though is always there after following the above and I believe it was there to start with before I began this attempt.

Any help to get this going would be appreciated.

User avatar
Douglas6
Posts: 4860
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Can't get pi3 bluetooth working

Sat Mar 18, 2017 10:52 pm

The easiest way to get Bluetooth working on the Pi, is to load up an SD card with the latest version of Raspbian. Older versions, even when completely updated, don't always seem to work.

The reason for the two Bluetooth icons is that you installed blueman, which really isn't needed (and may conflict) with the Raspbian Bluetooth GUI plug in.

louiscar
Posts: 19
Joined: Wed May 18, 2016 3:08 am

Re: Can't get pi3 bluetooth working

Sun Mar 19, 2017 12:03 am

Thanks Douglas,

I am going to try a clean install however, I've managed to get it working using the advice I found here

viewtopic.php?f=28&t=148305&start=25
I did the following to get the bt working.

Code: Select all

sudo apt-get update
sudo apt-get dist-upgrade
sudo rm /etc/udev/rules.d/99-com.rules
sudo apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall raspberrypi-sys-mods
sudo systemctl reboot
Whilst that was encouraging the bluetooth is completely useless. Testing with my Samsung note 3 or Tab s they see each other and sometimes pair - Samsung to pi only. Pi request always fail and sometimes so do Samsung. However once paired I can do absolutely nothing with that. Sending files from pi > samsung will result in an error or any attempt to connect.

It all seems pretty screwed. I have tried removing blueman but in the Gui it they do coexist they just have different errors when I try to do things.

Eg.
When trying to pair and Samsung actually gets a request through to the pi. I accept the passkey. The a popup asks if I want to accept (again?!!) and responds:

Code: Select all

GDbus.error.org.bluez.error.failed: no such file of directory
.. or without blueman and I try to 'connect' to the samsung which is paired as far as the pi is concerned.

Code: Select all

connection failed no useable services on this device
Searching I found http://stackoverflow.com/questions/4222 ... ry-pi-zero
which appears to be the same problem.

I WILL try a new installation and restore this image back to the pi2 but I'm really beginning to hate bluetooth. :-)

User avatar
Douglas6
Posts: 4860
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Can't get pi3 bluetooth working

Sun Mar 19, 2017 12:21 am

OK, if bluetoothctl shows an adapter, or 'hciconfig -a' shows the adapter up and running, that's definite progress. The next step is to determine what you want to do over Bluetooth. The answer will determine what software or services you will need to add to the Pi. By default, there are no services on the Pi that will allow it to connect to another Bluetooth device.

louiscar
Posts: 19
Joined: Wed May 18, 2016 3:08 am

Re: Can't get pi3 bluetooth working

Sun Mar 19, 2017 2:45 pm

Thanks again Douglas,
I now get this:

Code: Select all

hci0:   Type: BR/EDR  Bus: UART
        BD Address: B8:27:EB:8F:5E:F5  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING PSCAN
        RX bytes:717 acl:0 sco:0 events:42 errors:0
        TX bytes:1501 acl:0 sco:0 commands:42 errors:0
        Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
        Link policy: RSWITCH SNIFF
        Link mode: SLAVE ACCEPT
        Name: 'raspberryjaws'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous,
        HCI Version: 4.1 (0x7)  Revision: 0xb6
        LMP Version: 4.1 (0x7)  Subversion: 0x2209
        Manufacturer: Broadcom Corporation (15)
I've been reading through some of your other posts helping people and now realise that it needs a lot more. I assumed that the Pi3 having bluetooth would act as any other device such as smartphones and would have a range of services, file transfer being one but frankly I have better methods of doing that.

I would probably like eventually to look at connecting to a bluetooth speaker, a cheap media center that would stream from my Nas and send to the speakers.

Currently though I am probably in a mess simply because I experimented by backing up my image from the pi2 and put into the pi3. I have a new SD card on its way and will start from scratch as you suggest it would probably be easier to get things running smoothly that way.

louiscar
Posts: 19
Joined: Wed May 18, 2016 3:08 am

Re: Can't get pi3 bluetooth working

Sun Mar 19, 2017 3:37 pm

I think I still have problems as I followed your very helpful guide: viewtopic.php?p=963751#p963751

The guide suggests that blueman is already setup to send files to the phone when paired but this has always failed.
I tried it the other way around and ... a quick aside - I was unable to pair using bluetoothctl as there was no way of accepting the passkey. I had to go to the gui and do it there.

After setting it up on channel 23 all appeared ok and this time the raspberry appears in the bluetooth transfer options on the phone. It didn't before so it's clear the phone now sees the service available.

But the send fails everytime telling me connection unsuccessful.

bluetoothctl# connect <dev>
seems to fail too.
bluetoothctl# paired-devices
shows the phone is paired ok.

Odd

User avatar
Douglas6
Posts: 4860
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Can't get pi3 bluetooth working

Sun Mar 19, 2017 4:07 pm

I can't really speak to situations where an older updated Raspbian is being used, but I would think that if the adapter is recognized, you should be OK. I'd recommend getting familiar with bluetoothctl for pairing and statuses. Start with the following command

Code: Select all

info <bdaddr>
The phone should be both paired and trusted. Leave bluetoothctl open when you try to send a file from the phone to see any messages it reports.

louiscar
Posts: 19
Joined: Wed May 18, 2016 3:08 am

Re: Can't get pi3 bluetooth working

Mon Mar 20, 2017 12:14 am

ok - can you tell me when pairing with bluetoothctl how do I accept the request. I couldn't see how to do that as nothing seemed to come up. I had to go to the gui to see the pairing request prompt and confirm / accept the request.

info <btaddr> gives me:

Code: Select all

        Name: Galaxy Note4
        Alias: Galaxy Note4
        Class: 0x5a020c
        Icon: phone
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: no
        LegacyPairing: no
I don't get any message from bluetoothctl when I try to send a file.
I tried to connect and get :

Code: Select all

Attempting to connect to A8:##:##:##:##:##
Failed to connect: org.bluez.Error.NotReady
What it Legacypairing btw? ..and could that be significant?

User avatar
Douglas6
Posts: 4860
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Can't get pi3 bluetooth working

Mon Mar 20, 2017 12:37 am

It looks like you're paired and trusted just fine. I don't recognize the 'NotReady' message, which leads me to believe there's still something wrong with the Bluetooth stack. Again, I'd try a fresh Raspbian install.

Pairing from the phone is the easiest way to go. You'll want to start a pairing agent and make the Pi discoverable. Start bluetoothctl and enter these two commands:

Code: Select all

agent on
discoverable on
Leave bluetoothctl open. Then scan for the Pi on the phone and initiate pairing. Check the bluetoothctl window and answer any messages. Once paired, on the Pi, enter

Code: Select all

trust <bdaddr>
You can then quit bluetoothctl.

Legacy pairing is just an older (less secure) method of pairing. It's not an issue, the Pi can pair with legacy or modern pairing methods.

louiscar
Posts: 19
Joined: Wed May 18, 2016 3:08 am

Re: Can't get pi3 bluetooth working

Mon Mar 20, 2017 1:59 am

Leave bluetoothctl open. Then scan for the Pi on the phone and initiate pairing. Check the bluetoothctl window and answer any messages. Once paired, on the Pi, enter
ok this is where I have the difficulty - I get no response or messages from blootoothctl

Just now though I did have some progress. I was getting in response to

Code: Select all

hciconfig hci0 up
and error .. can't due to rfkill and looking this up I used rfkill unblock all and that got me a little bit further.

Now for a couple of attempts at file transfer I got a difference failed message which was more hopeful. It was 'refused by host' or something like that instead of 'unable to connect'.
That's a bit closer but then subsequent tries get the latter message again. Still trying ..

raspberryberry
Posts: 1
Joined: Thu Apr 06, 2017 8:27 pm

Re: Can't get pi3 bluetooth working

Thu Apr 06, 2017 8:30 pm

Did you find the solution yet? I'm experiencing he same problem

User avatar
Douglas6
Posts: 4860
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Can't get pi3 bluetooth working

Thu Apr 06, 2017 10:32 pm

Chances are it's not the same problem. Load a card with the latest version of Raspbian. Then, in a new post, describe what you are trying to do, and what errors you are receiving.

louiscar
Posts: 19
Joined: Wed May 18, 2016 3:08 am

Re: Can't get pi3 bluetooth working

Thu Apr 06, 2017 10:37 pm

raspberryberry wrote:Did you find the solution yet? I'm experiencing he same problem
I did get it working by starting again with a fresh Jessie install (before I had an image of my Pi2's setup and went from there).
I didn't install any of the other stuff - blueman etc or anything else and ran a few tests and managed to get file transfers working fairly well after installing obexpushd. I also connected successfully to a bt speaker but unable to test as I didn't have anything installed to handle the sound side of things.

Alan_uk
Posts: 10
Joined: Fri Apr 14, 2017 7:03 pm

Re: How I got pi3 bluetooth working

Sat Apr 15, 2017 10:02 pm

I spent a day working on this to connect a BT speaker (BETRON KB-S08 or KBS08) and eventually got it working without using the GUI.

[In this post I've left in many comments after the command lines, so it's best to copy all of this to a text file and then copy and post the commands]

1. To start with I used a Jessie image from a RasPi 1 B+ created on 1/1/17 from NOOBS_v2_1_0.zip, and using Win32DiskImager on a PC, copied it to my new Pi 3 SD card and it worked.
2. I then followed the instructions here: https://www.raspberrypi.org/magpi/bluet ... erry-pi-3/:
sudo apt-get update - 4 packages updated
sudo apt-get dist-upgrade - 126 upgrades; 51 newly installed
sudo apt-get install pi-bluetooth blueman
but instead of this:
sudo apt-get install pulseaudio pavucontrol pulseaudio-module-bluetooth
I did this:
sudo apt-get install bluez pulseaudio-module-bluetooth python-gobject python-gobject-2 bluez-tools

The speaker worked via the GUI (right click on the speaker icon and select the KBS08) but not through the command line (note: I may of tested the GUI later, after doing some of the following).

3. I then visited loads of websites and made the following changes. They may or may not be critical. Changes were made from a Windows PC using Putty. Note: zz:zz:zz:zz:zz:zz is the MAC address of the speakers.

bluetoothctl - fines BT controller at xx:xx:xx:xx:xx:xx raspberrypi
agent on - replies agent registered
default-agent - replies successful
scan on - replies no default controller available
[NEW] Device zz:zz:zz:zz:zz:zz zz-zz-zz-zz-zz-zz
[CHG] Device zz:zz:zz:zz:zz:zz Name: B-BETRON KB-S08
[CHG] Device zz:zz:zz:zz:zz:zz Alias: B-BETRON KB-S08
pair B-BETRON KB-S08 - using alias says not available
pair zz:zz:zz:zz:zz:zz - pairing successful using MAC address
trust zz:zz:zz:zz:zz:zz - RasPi should remember this device
connect zz:zz:zz:zz:zz:zz - sometimes works sometimes fails to connect: oreg.bluez.Error.Failed
- was never asked for any pairing number
- KB-S08 speaker will announce if it is connected.
quit - says DEL controller at xx:xx:xx:xx:xx:xx raspberrypi

sudo usermod –a –G lp pi - add user pi to the Pulse audio group

sudo nano /etc/bluetooth/audio.conf - enable A2DP in Bluetooth configuration:
Enable=Source,Sink,Media,Socket - add this line under [General] section and exit and save

sudo nano /etc/pulse/daemon.conf - modify Pulse daemon configuration file to change its resampling method.:
; resample-method = speex-float-3 - make sure this line starts with a semi-colan
resample-method = trivial - then add this line afterwards; exit & save

sudo nano /etc/bluetooth/main.conf
Enable=Source,Sink,Media - add this line in the [General] section:
Class = 0x00041C - modify this line to set the Bluetooth Class as headphones & speakers; exit & save

pulseaudio --start - start pulseaudio
pacmd set-default-sink bluez_sink.12_04_78_71_6B_56 - set default sink
wget http://www.freespecialeffects.co.uk/sou ... lice_s.wav - download this audio file
aplay police_s.wav - speakers should play the sound

--------------------------------------------------------
To check run:
pacmd list-cards

You should see something like this:
index: 3
name: <bluez_card.zz_zz_zz_zz_zz_zz>
driver: <module-bluez5-device.c>
owner module: 27
properties:
device.description = "B-BETRON KB-S08"
device.string = "zz:zz:zz:zz:zz:zz"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_zz_zz_zz_zz_zz_zz"
bluez.class = "0x240404"
bluez.alias = "B-BETRON KB-S08"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
profiles:
a2dp: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
off: Off (priority 0, available: yes)
active profile: <a2dp>
sinks:
bluez_sink.zz_zz_zz_zz_zz_zz/#3: B-BETRON KB-S08
sources:
bluez_sink.zz_zz_zz_zz_zz_zz.monitor/#4: Monitor of B-BETRON KB-S08
ports:
headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
properties:
headset-input: Headset (priority 0, latency offset 0 usec, available: no)
properties:

Key sections are: active profile, sinks & sources

------------------------------------------------------------
IN FUTURE AFTER POWER ON you will need to do this:
Switch on speakers
pulseaudio --start
pacmd set-default-sink bluez_sink.zz_zz_zz_zz_zz_zz
aplay police_s.wav speakers should play

Best to set up a bash script and add to the Pi start up.

Hope this helps.
Alan

Return to “Troubleshooting”