Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell whether bluetooth adapter supports bluetooth LE (4.0)?

I have two Bluetooth adapters, an old internal adapter and a new Bluetooth 4.0 adapter.

I am writing an application that uses a socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP) to connect to a Bluetooth LE device on Linux. When I call connect() with a sockaddr_l2 {.l2_family = AF_BLUETOOTH, .l2_bdaddr = {...}, .l2_cid = L2CAP_CID_ATT, .l2_bdaddr_type = BRADDR_LE_PUBLIC}, connect fails with errno=0x38000000=939524096 Unknown error, because Linux arbitrarily chooses the old adapter that only supports Bluetooth 2.1, not Bluetooth 4.0. The solution is to bind the socket to the bd_addr of the adapter that supports Bluetooth 4.0.

Question: How to tell which adapter is the Bluetooth 4.0 adapter? hciconfig does not tell which one is the one to use; they both say BR/EDR and not LE.

$ hciconfig
hci1:   Type: BR/EDR  Bus: USB
    BD Address: 00:25:00:F6:97:F0  ACL MTU: 1021:5  SCO MTU: 64:1
    UP RUNNING PSCAN 
    RX bytes:1074 acl:0 sco:0 events:56 errors:0
    TX bytes:1462 acl:0 sco:0 commands:56 errors:0

hci0:   Type: BR/EDR  Bus: USB
    BD Address: 00:02:72:D6:A0:BF  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING PSCAN 
    RX bytes:146505 acl:328 sco:0 events:4189 errors:0
    TX bytes:6213 acl:215 sco:0 commands:83 errors:0
$ modinfo bluetooth | grep ^version:
version:        2.17
$ modinfo btusb | grep ^version:
version:        0.6
$ lsb_release --description
Description:    Ubuntu 14.04.1 LTS
$ uname --kernel-release
3.13.0-40-generic
like image 592
yonran Avatar asked Dec 08 '14 22:12

yonran


People also ask

How do I find my Bluetooth adapter version?

Right-click the Bluetooth adapter and select the Properties option. Click the Advanced tab. Under the “Bluetooth Radio Information” section, check the “Firmware Version” field and note the LMP (Link Manager Protocol) version number.

Which Bluetooth versions are capable of low energy le mode?

Versions 4.0 – 5.0: Bluetooth Low Energy In order to meet the increasing demand for wireless connectivity between small devices, Bluetooth 4.0 was introduced to the market with a new category of Bluetooth: Bluetooth Low Energy (BLE).

How do I know if my computer supports BLE?

Select Device Manager. Select Bluetooth from the sidebar on the left. This will expand to show Bluetooth drivers. If there is a driver named Microsoft Bluetooth LE Enumerator then your Windows 10 computer supports Bluetooth Low Energy.

What is a Bluetooth 4.0 USB Adapter?

This adapter lets users connect up to seven Bluetooth-enabled devices to a Bluetooth-compatible computer. It works with laptops and desktops running Microsoft Windows 10. This Insignia Bluetooth USB adapter maintains connections with devices up to 20 feet away.


2 Answers

To answer your question there is btmgmt info which will list the HCI version (on the same line as addr), you will have to look into Host Controller Interface Assigned numbers for the meaning of the numbers, version 6 below mean Bluetooth 4.0.

# btmgmt info
hci0:   Primary controller
addr 5C:F3:70:XX:XX:XX version 6 manufacturer 15 class 0x1c010c
supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy configuration static-addr 
current settings: powered bondable ssp br/edr le secure-conn 
name BlueZ 5.47
short name 

If you need to know if the adapter support LE, you will have to look for le in Supported settings: because LE is not mandatory in bluetooth 4.0/4.1.

like image 51
lumostor Avatar answered Oct 04 '22 19:10

lumostor


Try: hciconfig hci[0|1] version

like image 38
kaylum Avatar answered Oct 04 '22 17:10

kaylum