How do I know if the 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 socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)

to connect to a Bluetooth LE device on Linux. When I call connect()

with sockaddr_l2 {.l2_family = AF_BLUETOOTH, .l2_bdaddr = {...}, .l2_cid = L2CAP_CID_ATT, .l2_bdaddr_type = BRADDR_LE_PUBLIC}

, the connection fails with errno = 0x38000000 = 939524096 Unknown error because Linux randomly chooses an old adapter that only supports Bluetooth 2.1 and not Bluetooth 4.0. The solution is to bind the socket to the bd_addr of an adapter that supports Bluetooth 4.0.

Q: How to know which adapter is Bluetooth 4.0 adapter? hciconfig does not indicate which one to use; they both say BR / EDR, 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

      

+3


source to share


2 answers


Try: hciconfig hci[0|1] version



+3


source


To answer your question, there is btmgmt info

one that will display the HCI version (on the same line as addr

), you will need to look into Host Controller Interface Assigned Numbers to denote numbers, version 6 below means 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 supports LE, you need to search le

in Supported settings:

because LE is optional in bluetooth 4.0 / 4.1.

+2


source







All Articles