Uniquely identifying bluetooth devices - linux

I am new to bluetooth development and recently started reading about it.
I am trying to develop ble devices scanner and I need to provide an option to mark specific devices as trusted or untrusted.
I am able to get list of discoverable ble devices using hcitool lescan. But bluetooth addresses returned here can be random addresses. I need to uniquely identify trusted neighbouring ble devices to mark them as trusted even after changing random address. Static/public bluetooth address seems to be the only option to uniquely identify ble devices.
AFAIK static bluetooth address and IRK are shared during pairing. So after pairing with trusted BLE devices, I can get static bluetooth address and IRK which can be used for uniquely identifying trusted bluetooth devices. Also post pairing device can be uniquely identified when resolvable random address is used by paired ble device.
gatttool can be used to connect to scanned BLE devices. But how can I get the static/public address after I connect to BLE device (assuming gatttool connect will perform pairing).
I am not able to find any out of the box tool like hcitool which can be used to pair to get static bluetooth address and uniquely identify when trusted ble device is scanned with resolvable random address.
Is there any tool which can be used to uniquely identify trusted bluetooth device?

Related

Is just the BD_ADDR of responding devices shared with the master during inquiry?

Is the Bluetooth address exchanged between two Bluetooth devices if no connection is made yet?
As when a device is in discovery mode, and you see for example a tv, headphones, or a different computer show up, is the Bluetooth address of that device being shared with the device making the inquiry, or are the others also getting the Bluetooth address of the inquiring device?
Alternatively, is the Bluetooth address only shared upon selection of the device for connection?
Thanks!
Edit: spelling
Advertising devices broadcast one-way. They do not know what devices have discovered them. Scanning for advertisements is passive. It does not require sending any packets, so neither the advertising device, nor other scanners in the area, will be aware of the scanning device.
Note that Bluetooth addresses are quite complex and varied, so how they are shared is not trivial. Devices have many kinds of addresses and change what they publicize frequently. But to the question of when an address (rather than the address) is shared, that is during connection.

Bluetooth BLE Beacon, Advertise

when starting with this Bluetooth low Energy (BLE) development, i come across some questions:
with my development board, I can send out advertisement beacons, they are recognized by Windows 7 (Bluetooth, Add Device). The demo application on the board sends out beacons which are in length <31 bytes. In this data there is included the data for length, an ID byte and a string.
But how is Windows able to identify the Bluetooth device address (BD) and the name of my device? This data is not included in the advertisement beacon, but I cannot find any document which describes how this data is transported.
So the relevant data is:
the Beacon .. the BD address .. the device name
The Bluetooth MAC address is sent in the header of any packet a BLE device transmits. This is added at the hardware layer, so you probably do not realize it is happening.
Similarly, when a BLE device is configured with a local name, it is transmitted by the chip automatically in a separate advertisement packet. Since this packet also had a header with the MAC address, the receiving chip uses this address to align the received name/MAC with any other packet received for that MAC.
This is how the Windows device knows the name and MAC for your received advertisements.

BLE peripheral: scanning while connected

Is it possible to make a peripheral scan for advertisments while connected to a central? It seems like it is either scanning for advertisments or have your peripheral connected but I need to do both. The peripheral should be able to report RSSI measurements from advertisements it picks up.
I'm using 'bleno' for the peripheral and 'noble' for the scanning on a linux box (bluez)
The answer to this differs depending on the version of Bluetooth that your device is on.
For Bluetooth v4.0:
A peripheral cannot scan at all, whether in a connection or not. The peripheral can only send out adverts or accept incoming connections. For more information you can have a look at this document, page 18:-
http://chapters.comsoc.org/vancouver/BTLER3.pdf
For Bluetooth v4.1 onwards:
A device can be in central and peripheral role at the same time. By implication, this means that if a peripheral is connected to a central device, it can still scan for devices in it's "central mode". More information can be found in this link, page 5:-
http://www.ietf.org/proceedings/89/slides/slides-89-6lo-4.pdf
So in conclusion, if your device is BT v4.1 or newer, then this is dependant on the chip manufacturer, and if it is v4.0, then no, because the Bluetooth specification does not allow it.

Bluetooth profile info in linux

As bluetooth device has a number of bluetooth profiles. when want to do communication is bluetooth device, first pair bluetooth device and then starts sending data using bluetooth.
In linux, hcitool is used to scan nearby bluetooth devices.
Questions:
1) How can i know which bluetooth profile is supported by selected nearby bluetooth device?Is there any particular command to know bluetooth profile supported by selected nearby bluetooth device in linux?
2) suppose, i come to know selected nearby bluetooth device support abcd and xyz bluetooth profiles. How can i select particular bluetooth profile in linux?, example abcd out of supported profiles.
2) How can i connect to that selected bluetooth device as SPP profile for transferring data as serial port in linux?
Regards,
Sukhdeep Singh
In linux, sdptool utility is provided with which you can search your own device supported profiles and other devices supported profiles(sdptool browse local/).
Since you know the peer device support abcd/xyz profile, you dont have to select any profile, you have to intiate a profile level connection request(pairing/authentication also needs to be taken care)
For SPP connection, rfcomm tool is provided by bluez

USB device address on Windows

I'm using node-serialport to work with USB devices, however on Windows I can't find out how can I connect to specific device. When I use list function there is only one item with COM3 address, however that is present always, even when no other devices are connected. How can I find out what is the USB device address that can be used for setting up communication?

Resources