Monday, April 11, 2016

[RR Bluetooth] Compile Bluez 5.39

Refer to page:

To configure compile environment:

./configure  --prefix=$PWD/built --enable-experimental  --enable-maintainer-mode


The first error is:
checking for DBUS... no
configure: error: D-Bus >= 1.6 is required

Check D-Bus version:
$ dbus-daemon --version
D-Bus Message Bus Daemon 1.6.18
Copyright (C) 2002, 2003 Red Hat, Inc., CodeFactory AB, and others
Fix by:
apt-get install libdbus-1-dev

Next error:
checking for UDEV... no
configure: error: libudev >= 172 is required
Check udev version:
$ udevd --version
204
Fixed by:
apt-get install libudev-dev

Next error:
checking for ICAL... no
configure: error: libical is required
Fixed by:

apt-get install libical-dev


Next error:
checking for readline/readline.h... no
configure: error: readline header files are required
Fixed by:
apt-get install libreadline-dev

Next error:
checking systemd system unit dir... configure: error: systemd system unit directory is required
The problem is more annoyed, by here  and here, Fixed by changing configuring parameters:
./configure  --prefix=$PWD/built --enable-experimental  --enable-maintainer-mode --with-systemdsystemunitdir=/lib/systemd/system --with-systemduserunitdir=/usr/lib/systemd





Thursday, March 31, 2016

[RR Bluetooth] Failed to connect: org.bluez.Error.NotAvailable when trying to connect bluetooth device by bluetoothctl

I tried to connect my OBDII bluetooth device by bluetoothctl. The pairing process is smooth but connecting is not.

The console shows "Failed to connect: org.bluez.Error.NotAvailable"


However, connect to my bluetooth travel mouse is successful

After digging out a little bit, it seems that the profile of my OBDII, Serial Port probably, is not attached automatically.

Someone discussed this issue here

[RR Bluetooth] Class of Device - output of hciconfig

"hciconfig" -a can show information of attached bluetooth device. The "Class" means "Class of Device" or "COD"





Someone makes a nice CoD generator and a CoD caculator which are handy for using.


Monday, March 14, 2016

[RR Bluetooth] Strange Return Byte when Using hcitool to send HCI command

First of all it's a silly problem but I struggled in for few hours.

While using hcitool to issue command to bluetooth controller, I found the response bytes are strange since they are not conform with spec.

for HCI command packet format:


As I tried to test if the hcitool works, I send LE Rand Command:
sudo hcitool -i hci0 cmd 0x08 0x0018


The response I got is:
< HCI Command: ogf 0x08, ocf 0x0018, plen 0
> HCI Event: 0x0e plen 12
  01 18 20 00 5F CD 97 0D DB 36 C4 F5 

Bluetooth Event format is:

There is not doubt that the event code is 0x0e, which means Command Complete. Per spec below
Num_HCI_Command_Packet: 0x01
Command_OPcode: 0x18 0x20  <= strange here
The first byte (0x18) surely matches OCF of sending command which is LE Rand. However, the 0x20 is not the OGF(0x08) we send.


After digging deeper, I found OCF is actually 12 bits while OGF is only 6 bits. Thus, the OGF 0x08 'value' when sending in command turns out 0x20 of response of byte boundary: 0x08 == 0x20 >> 4