Bluetooth on GhostBSD

Add your Tips and tricks to configure and tweak your GhostBSD System here.
Post Reply
Posts: 492
Joined: Thu Dec 22, 2016 10:30 pm
Location: Japan
Has thanked: 8 times
Been thanked: 12 times

Bluetooth on GhostBSD

Post by NevilleGoddard » Wed Jan 03, 2018 12:44 am

I've read in many places on the web that Bluetooth on FreeBSD is broken and unusable.
I was pleasantly surprised to find that this is not the case and Bluetooth works surprisingly well, for transferring files anyway.
I managed to find a Bluetooth 2.0 USB dongle for about $1.50 including postage. Not bad.
I can now successfully send files between my android phone and my computer using Bluetooth.

Insert usb Bluetooth device.

To start Bluetooth, load the kernel modules:

#kldload ng_ubt

just to be sure:

#kldload ubtbcmfw

If you want these to load at boot time put in /boot/loader.conf:


you may want to look in /var/log/messages for something like this:

ubt0: vendor 0x0a12 product 0x0001, rev 1.10/5.25, addr 2
ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2
ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3,
wMaxPacketSize=49, nframes=6, buffer size=294

start the Bluetooth service:

#service bluetooth start ubt0

You may get a warning here like :

/etc/rc.d/bluetooth: ERROR: Unable to setup Bluetooth stack for device ubt0

just try the command again:

#service bluetooth start ubt0

again you may get the same warning but the service may have started anyway.

Next try as normal user to search for nearby Bluetooth devices:

$hccontrol -n ubt0hci inquiry

If Bluetooth is working you'll get your phone discovered and see output like this:

Inquiry result, num_responses=1
Inquiry result #0
BD_ADDR: 11:31:55:90:xx:v8
Page Scan Rep. Mode: 0x1
Page Scan Period Mode: 0x2
Page Scan Mode: 00
Class: 5a:02:0c
Clock offset: 0x1052
Inquiry complete. Status: No error [00]

If you get errors here you're Bluetooth device is probably not supported.

If you just get "Inquiry complete. Status: No error [00]" , turn Bluetooth on on your phone.
Take note of the Bluetooth address - 11:31:55:90:xx:v8 Obviously your number will be different.
To find the name of your phone:

hccontrol -n ubt0hci remote_name_request 11:31:55:90:xx:v8 (use your BD_ADDR)

and you should get:

BD_ADDR: 11:31:55:90:xx:v8
Name: MyPhoneModel

Then edit the /etc/bluetooth/hcsecd.conf file and add these lines or edit on of the example entries that is already there:

device {
bdaddr 11:31:55:90:xx:v8;
name "MyPhoneModel";
key nokey;
pin "1234";

The pin can be any number you want "0000" or "1111" are also fine. Use your bdaddr and name

Then :

Turn on authentication:

# hccontrol -n ubt0hci write_authentication_enable 1
# hccontrol -n ubt0hci read_authentication_enable
#hcsecd -d
And pair from your phone. Your bluetooth device should show up in your phone as "yourcomputername(ubt0)". Tap on it and enter the password you put in your hcsecd.conf entry.
If you want to start hcsecd at boot put this into /etc/rc.conf


Now your phone and computer should be paired. Now to transfer some files. To find the channel your phone uses to transfer files:

#service sdpd start
If you want this to start at boot put into /etc/rc.conf

Browse your phone:

$sdpcontrol -a 11:31:55:90:xx:v8 browse

You should get output like this:

Record Handle: 00000000
Service Class ID List:
Service Discovery Server (0x1000)
Protocol Descriptor List:
L2CAP (0x0100)
Protocol specific parameter #1: u/int/uuid16 1
Protocol specific parameter #2: u/int/uuid16 1

Record Handle: 0x00000001
Service Class ID List:
Browse Group Descriptor (0x1001)

Record Handle: 0x00000002
Service Class ID List:
LAN Access Using PPP (0x1102)
Protocol Descriptor List:
L2CAP (0x0100)
RFCOMM (0x0003)
Protocol specific parameter #1: u/int8/bool 1
Bluetooth Profile Descriptor List:
LAN Access Using PPP (0x1102) ver. 1.0

In this example the correct channel is 1 from this line:

RFCOMM (0x0003)
Protocol specific parameter #1: u/int8/bool 1 <------

Now install obexapp

#pkg ins obexapp


$obexapp -c -a 11:31:55:90:xx:v8 -C 1 (change to your channel and bdaddr)

if the connection is successful, you'll get the obex prompt which means obexapp can send the files you want. You may have to do this command 3 or even 4 times until you get the obex prompt.
When you get the prompt it looks like this:

Send a file to your phone

obex> put /file/name/youwanttosend

and hit enter and you should get a notification on your phone for accepting incoming bluetooth file.
When you've finished enter di.

obex> di

If you get any errors, make sure you have no quotation marks around the file you're sending and the file name has no gaps. i.e. /home/username/Pictures/my image.jpg will not be sent but /home/username/Pictures/myimage.jpg will.

To send from your phone to computer, make a folder at /var/spool/ called obex

#mkdir /var/spool/obex

And send file from phone to computer, choosing the yourcomputername(ubt0) device. You'll see the file at /var/spool/obex

If you want to send files automatically without all the obexapp commands, use the script here :


# $FreeBSD$

# PROVIDE: obexapp

. /etc/rc.subr


rc_flags="-s $rc_flags -C ${obexapp_channel}"

if [ -n "${obexapp_username}" ]; then
rc_flags="$rc_flags -u ${obexapp_username}"

if [ -n "${obexapp_rootdir}" ]; then
rc_flags="$rc_flags -r ${obexapp_rootdir}"

load_rc_config $name

: ${obexapp_enable="NO"}
: ${obexapp_flags="-S"}
: ${obexapp_channel="5"}
: ${obexapp_username="yourloginname"}
: ${obexapp_rootdir="/some/directory/"}

run_rc_command "$1"


Copy into your favourite text editor (pluma or mousepad) and call it

In the section

: ${obexapp_enable="NO"}
: ${obexapp_flags="-S"}
: ${obexapp_channel="1"}
: ${obexapp_username=""}
: ${obexapp_rootdir=""}

edit the channel number, obexapp_username to your login name and obexapp_rootdir to wherever you want the files sent from your phone to go to. e.g /home/yourloginname/obex. Save the file and copy it to


#cp /path/to/downloaded/ /usr/local/etc/rc.d/

chmod it to make it executable:

#chmod 577 /usr/local/etc/rc.d/

Then add these to /etc/rc.conf


also make sure devd_enable="YES" is also in /etc/rc.conf. This will start Bluetooth on boot up.

Start the script:

# /etc/rc.d/sdpd onestart
# /usr/local/etc/rc.d/ start

Now you should be able to send file from your phone without any commands at all.

To send file to your phone, make this script:
Copy these lines to a mousepad (or other text editor) file:

obexapp -c -a 11:31:55:90:xx:v8 -C 1

Again edit bdaddr and channel number for your phone and save in your home folder or wherever you like and give it any name you like i.e. transfer

Make it executable:

#chmod 755 /path/to/file/transfer

Now to begin transferring files, run the script:
Open a terminal and type as user:


Again do this until you get the obex prompt. Usually you only need to do it once, but sometimes it takes 3 times.

obex >

Then use the put command to send files. :mrgreen:

obex> put /your/file/name

I've found sending files to be a little slow as I'm using Bluetooth version 2.0 but 4.0 is much faster. I'm wauting for the device and I'll test it when it comes. Also obexapp won't send odt files but will send mp4, mp3 and jpg files. :D

User avatar
Posts: 1459
Joined: Mon Nov 19, 2012 7:54 pm
Has thanked: 40 times
Been thanked: 59 times

Re: Bluetooth on GhostBSD

Post by ericbsd » Tue Jan 23, 2018 10:27 am

Nice I might look to integrate that in the next release.

Posts: 492
Joined: Thu Dec 22, 2016 10:30 pm
Location: Japan
Has thanked: 8 times
Been thanked: 12 times

Re: Bluetooth on GhostBSD

Post by NevilleGoddard » Sat Jan 27, 2018 9:55 am

Thanks ericbsd. I can't wait to test GhostBSD12.

Have you tried this on TrueOS?
I've tried it on FreeBSD 12 and I can transfer files from my computer to my phone, but to transfer files from phone to computer doesn't work anymore unless I run the command

obexapp -c -a 24:31:84:90:11:22 -C 5

then it will work. Maybe because I'm using CURRENT. I don't know.

Is there any way to get this command to start automatically at boot time?

Posts: 492
Joined: Thu Dec 22, 2016 10:30 pm
Location: Japan
Has thanked: 8 times
Been thanked: 12 times

Re: Bluetooth on GhostBSD

Post by NevilleGoddard » Sun Feb 04, 2018 8:12 am

Just a quick update.

It looks like bluetooth 4.0 is supported under GhostBSD/FreeBSD.

I've tested a couple of Bluetooth 4.0 dongles and they work quite well. Probably a little better than the Bluetooth 2.0 dongles I tested before.

So far all dongles I've bought have worked. They are very cheap. Only around $5 US. However 4.0 speed is apparently much faster than 2.0 but it didn't seem to be a lot faster. I'll need to test more.

The latest dongles both had the same chip set, unfortunately. I was hoping to try a couple of different chip sets.

The chip is a CSR8510 A10. CSR stands for Cambridge Silicon Radio.

Apparently the Broadcom Corp BCM20702A0 also works.

Post Reply