Skip to main content

Bluetooth

3DV-EdgeAI-32 supports wireless connectivity via Bluetooth when the appropriate module is available. To display information about Bluetooth devices, execute the following command:

root@Airbox:/tmp# hciconfig -a

Example output:

hci0:   Type: Primary  Bus: USB
BD Address: 64:82:14:70:8C:2B ACL MTU: 1021:6 SCO MTU: 255:12
UP RUNNING
RX bytes:1401 acl:0 sco:0 events:91 errors:0
TX bytes:2411 acl:0 sco:0 commands:91 errors:0
Features: 0xff 0xff 0xff 0xfe 0xdb 0xfd 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: 'Airbox'
Class: 0x000000
Service Classes: Unspecified
Device Class: Miscellaneous
HCI Version: (0xb) Revision: 0xb
LMP Version: (0xb) Subversion: 0x8852
Manufacturer: Realtek Semiconductor Corporation (93)

If you meet the error when executing the command:

Can't open HCI socket.: Address family not supported by protocol

there may be issues with the dependencies of the loaded modules. In this case, execute the following commands:

sudo -i
depmod -a
reboot
Checking the device operating mode

(1) Determine whether the device is a master or slave:

root@Airbox:/tmp# hciconfig hci0 lm
hci0: Type: Primary Bus: USB
BD Address: 64:82:14:70:8C:2B ACL MTU: 1021:6 SCO MTU: 255:12
Link mode: SLAVE ACCEPT

(2) Start the PulseAudio server as a media device:

admin@Airbox:~$ pulseaudio --start --log-target=syslog

Connecting a Bluetooth device

(1) Start the Bluetooth management tool:

root@Airbox:/tmp# bluetoothctl

Output:

Agent registered
[CHG] Controller 64:82:14:70:8C:2B Pairable: yes

(2) Turn on the Bluetooth controller:

admin@Airbox:~$ bluetoothctl

Output:

Agent registered
[bluetooth]# power on
Changing power on succeeded
[bluetooth]#

(3) Set the default Bluetooth agent:

[bluetooth]# agent on
Agent is already registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]#

(4) Allow the device to be discoverable by others:

[bluetooth]# discoverable on

Output:

Changing discoverable on succeeded
[CHG] Controller 64:82:14:70:8C:2B Discoverable: yes

(5) Find the 3DV-EdgeAI-32 device on your smartphone and perform pairing:

[NEW] Device A4:90:CE:DF:64:4F iQOO Neo6 SE
[CHG] Device A4:90:CE:DF:64:4F Modalias: bluetooth:v001Dp1200d1436
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 0000112d-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 2c042b0a-7f57-4c0a-afcf-1762af70257c
[CHG] Device A4:90:CE:DF:64:4F UUIDs: 8fa9c715-bd1f-596c-a1b0-13162b15c892
[CHG] Device A4:90:CE:DF:64:4F ServicesResolved: yes
[CHG] Device A4:90:CE:DF:64:4F Paired: yes
[CHG] Device A4:90:CE:DF:64:4F ServicesResolved: no
[CHG] Device A4:90:CE:DF:64:4F Connected: no
[CHG] Controller 20:57:9E:BA:7C:EC Discoverable: no

(6) Connect the mobile device:

[bluetooth]# connect A4:90:CE:DF:64:4F

Output:

Attempting to connect to A4:90:CE:DF:64:4F
[CHG] Device A4:90:CE:DF:64:4F Connected: yes
Connection successful
[CHG] Device A4:90:CE:DF:64:4F ServicesResolved: yes
[iQOO Neo6 SE]#

(7) Establish trust with the mobile device:

[iQOO Neo6 SE]# trust A4:90:CE:DF:64:4F
[CHG] Device A4:90:CE:DF:64:4F Trusted: yes
Changing A4:90:CE:DF:64:4F trust succeeded

Connecting Bluetooth audio

3DV-EdgeAI-32 supports Bluetooth audio using the bluez-alsa utility.

Installing bluez-alsa 1.3.0

(1) Download the package from https://github.com/Arkq/bluez-alsa/releases/tag/v1.3.0

(2) Install the dependencies:

sudo apt install -y libasound2-dev libbluetooth-dev libglib2.0-dev libsbc-dev libfdk-aac-dev pkgconf

(3) Extract and install:

tar xzvf bluez-alsa-1.3.0.tar.gz
cd bluez-alsa-1.3.0
autoreconf --install
mkdir build && cd build
../configure --enable-aac --enable-debug
make && make install

Audio testing

(1) Set the Bluetooth controller to master mode:

sudo hciconfig hci0 lm master

(2) Stop the PulseAudio process (bluez-alsa is incompatible with PulseAudio):

killall pulseaudio

(3) Start the bluez-alsa service:

bluealsa -p a2dp-source -p hsp-ag &

(4) Connect your Bluetooth headset:

[bluetooth]# connect 0C:AE:BD:9B:BB:5C
Attempting to connect to 0C:AE:BD:9B:BB:5C
[CHG] Device 0C:AE:BD:9B:BB:5C Connected: yes
Connection successful
[CHG] Device 0C:AE:BD:9B:BB:5C ServicesResolved: yes
[EDIFIER LolliPods 2022]#

(5) Open a terminal and run the following command to play audio:

aplay -D bluealsa:HCI=hci0,DEV=0C:AE:BD:9B:BB:5C,PROFILE=a2dp example.wav

After completing these steps, your Bluetooth audio setup will be ready for use.

For more information about bluez-alsa, please refer to the source repository: https://github.com/Arkq/bluez-alsa/tree/v1.3.0.

File transfer and receiving

Bluetooth uses the OBEX protocol for sending and receiving files, encapsulating information through an object model and transmitting it using the session protocol specification.

To use the OBEX service in Linux, follow these steps:

(1) Connect the 3DV-EdgeAI-32 device to the Bluetooth device as outlined in the previous steps.

(2) Start the OBEX daemon and set the directory for incoming files to /home/linaro/:

/usr/lib/bluetooth/obexd -r /home/linaro -a -d &

Using the OBEX Push service

(1) Set Bluetooth to master mode:

sudo hciconfig hci0 lm master

(2) Find the channel for the OBEX Push service on your mobile device (in this case, channel 12):

linaro@bm1684:~$ sdptool search --bdaddr A4:90:CE:DF:64:4F OPUSH
Searching for OPUSH on A4:90:CE:DF:64:4F ...
Service Name: OBEX Object Push
Service RecHandle: 0x1000d
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 12
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0102
Searching for OPUSH on A4:90:CE:DF:64:4F ...
Service Search failed: Invalid argument

(3) Send a file to your phone:

linaro@bm1684:~$ obexftp --nopath --noconn --uuid none --bluetooth A4:90:CE:DF:64:4F --channel 12 --put sn.txt
Suppressing FBS.
Connecting..done
Sending "sn.txt"...done
Disconnecting..done

A prompt will appear on your mobile device asking to receive the file.

Using the obexctl command

Follow these steps to receive files on 3DV-EdgeAI-32:

(1) Start the OBEX service on the device (slave device):

root@firefly:~# systemctl --user start obex

(2) Enter the interactive mode:

root@firefly:~# obexctl
[NEW] Client /org/bluez/obex

(3) Connect 3DV-EdgeAI-32 (master device):

[obex]# connect 20:57:9E:BA:7C:EC
Attempting to connect to 20:57:9E:BA:7C:EC
...
[NEW] Session /org/bluez/obex/client/session2 [default]
[NEW] ObjectPush /org/bluez/obex/client/session2

(4) Send a file:

[20:57:9E:BA:7C:EC]# send /root/test.txt
Attempting to send /root/test.txt to /org/bluez/obex/client/session1
[NEW] Transfer /org/bluez/obex/client/session1/transfer1
Transfer /org/bluez/obex/client/session1/transfer1
Status: queued
Name: test.txt
Size: 0
Filename: /root/test.txt
Session: /org/bluez/obex/client/session1
[CHG] Transfer /org/bluez/obex/client/session1/transfer1 Status: complete

(5) Check the file test.txt in the /home/admin/ directory of 3DV-EdgeAI-32:

admin@Airbox:~$ ls -l test.txt
-rw------- 1 linaro linaro 0 Nov 25 15:49 test.txt