I have a Raspberry Py OS based on Debian Stretch broadcasting an iBeacon with my UUID and Major/Minor. Through an APP built by our team, I was able to identify it by the UUID and read its Major/Minor.
Now, I'll have to read this same iBeacon through Chrome Browser. However, I am not being able to broadcast with the iBeacon a meaningful name to help the user to find the device,
it only shows to me "Unknown or unsupported device"
As far as I could understand from iBeacon and AltBeacon, it isn't possible to send extra data in addition to UUID and Major/Minor. Is this correct? Is it possible to advertise this information within the beacon frame?
Command used to advertise the beacon.
sudo hciconfig hci0 leadv 3
sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 06 1A FF 4C 00 02 15 <<UUID>> <<Major/Minor>> C8 00
Consulting the Specification of the Bluetooth System I tried to change several name or ID features, none of them worked, such as:
sudo hcitool -i hci0 cmd 0x03 0x0013 <<Local Name>>
sudo hcitool -i hci0 cmd 0x03 0x0014
I would like to ask the community if it is possible to advertise this name while using beacons or if I should start using a GATT server to perform it.
Thank you all in advance.
Yes, it is possible for Linux to advertise both the local name and the iBeacon manufacturer advertisement. The way you are setting it up is correct, so it's unclear why you aren't seeing it in the Chrome web browser.
One thing to know is that the local name is not advertised in the same packet along with the iBeacon data that you show in your question. (There simply isn't room in the main advertising packet.) Instead, the local name is put in what is called a scan response packet. This is an additional packet that a Bluetooth LE Peripheral will send out in response to an active scan request packet from the Bluetooth LE Central (e.g. your Chrome device). It may be that Chrome does not send out scan request packets, which is why it won't read the local name.
You can confirm this by using a different device (like an Android or iOS phone using the Nordic nRF Connect Bluetooth test app) to see if they read the local name during a scan.
If you find that this these other devices do read the local name, then your next step would be to try to configure Chrome to do an active scan so it requests the scan response packets. It's unclear how or if this is possible.
Related
In my current project, I am working with iBeacon in the area of IoT. Basically iBeacon works on Bluetooth wireless technology. I am using Raspberry Pi 3 (which is available with in-built wifi and bluetooth). Pi 3 Bluetooth display and detect the iBeacon but not able to do pairing with it and display the following error:
GDBus.Error:org.bluez.Error.AuthenticationFailed
I also tried with bluetoothctl command also but again display the Failed to pair: org.bluez.Error.AuthenticationFailed
error.
Am I missing something? I am able to pair iBeacon with my mobile and windows based lapotop.
Understand that iBeacon is a transmit only Bluetooth LE device. It is Bluetooth LE manufacturer advertisements to send a unique identifier, something you have seen if you have detected it with the Raspberry Pi 3.
But a basic iBeacon device is not designed to be connectable over Bluetooth LE. Some beacon manufacturers may expose a secondary configuration service that is connectable, but this is not universal and if it exists it is entirely outside the beacon spec.
Bottom line: you are not supposed to be able to connect.
If you have a specific model of beacon that does have a config interface, and you want to connect to that, you may want to put that in your question.
I'm working on setting up two Linux systems for a BLE demo. Obviously one system will be the peripheral and one will be the central devices. I have several questions surrounding both of these configurations.
Environment
2x Ubuntu 14.04 systems
2x Pluggable USB-BT4LE dongles (http://plugable.com/products/usb-bt4le)
Peripheral Device Setup
The first order of business is getting the peripheral system setup and advertising with a GATT server configured. At this time, it does not seem possible to configure a GATT server from the command line. So, while it is a simple task bringing a USB dongle up and advertising it, this does not allow the creation of custom services and characteristics. The only example of a GATT server I could find was the gatt-example.c file in the Bluez package. So I downloaded and built the latest bluez-5.23 source. (http://www.linuxfromscratch.org/blfs/view/svn/general/bluez.html). Additionally configured using the --enable-maintainer-mode flag to force build the gatt-example.c plugin into bluetoothd. And I validated post-build from the ~/bluez-5.23/plugins directory that there was a bluetoothd-gat-example.o file. Which tells me that the gatt-example was at least successfully built.
I then modified the configuration file to enable LE and the attribute server.
$ sudo vi /etc/bluetooth/main.conf
EnableLE = true // Enable Low Energy support. Default is false.
AttributeServer = true // Enable the GATT attribute server. Default is false.
Then simply reboot or restart the bluetooth daemon...
Central Device Setup
As the central device does not need any special plugins built like the peripheral, I just installed bluez using apt-get. This appears to have installed v4.101 according to bluetoothd -v.
Session Setup
The connection process then should be fairly simple. I setup the peripheral to advertise and then connect with the central device:
Peripheral:
$ sudo hciconfig hci0 up // Make sure the interface is up
$ sudo hciconfig hci0 leadv // Set the interface to advertise
Central:
$ sudo hcitool -i hci0 lescan // Scan for nearby devices advertising
LE Scan ...
00:02:72:C9:5E:0F (unknown) // Not sure why two of the same MAC are found?
00:02:72:C9:5E:0F (unknown) // but I know this is my device...
$ sudo gatttool -i hci0 -b 00:02:72:C9:5E:0F -m 48 --interactive // Connect interactively
[ ][00:02:72:C9:5E:0F][LE]> connect
[CON][00:02:72:C9:5E:0F][LE]> primary
attr handle: 0x0001, end grp handle: 0x0008 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0010, end grp handle: 0x0010 uuid: 00001801-0000-1000-8000-00805f9b34fb
[CON][00:02:72:C9:5E:0F][LE]> characteristics
handle: 0x0004, char properties: 0x02, char value handle: 0x0006, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0007, char properties: 0x02, char value handle: 0x0008, uuid: 00002a01-0000-1000-8000-00805f9b34fb
And we see not one of the services or characteristics from the gatt-example are available.
Questions
--Peripheral Device
How would I go about creating my own custom GATT server? Can it be a stand-alone C application or does it need to be built into bluetoothd as a plugin like the gatt-example? The answer to this question (Creating a Gatt Server?) implies you do the following: "start by initializing the GATT library and additional modules" and then "register your GATT database". But there isn't a single example of how to implement those generic statements and the link provided is simply a URL to the Bluetooth website.
The GATT specifications (https://developer.bluetooth.org/gatt/Pages/default.aspx) provide numerous "adopted" services and characteristics that are downloadable in XML format. But there is no instructions for how to use them?!
How do a validate my GATT server is running?
--Central Device
Why is my central device not seeing the services and characteristics from the GATT server running on the peripheral?
I can provide any additional information necessary. Thanks.
To create a GATT server into a separate process you have (at least) two cases:
Bluez v4.x: your GATT service must be a Bluez plugin
Bluez v5.x: your GATT service should use the new GATT DBus API (but it is recommended to use at least Bluez v5.39 (from April 2016). Otherwise it is safer (in term of Bluez GATT Server API) to use the Bluez v4.x plugin approach.
If your Central Device does not see the newly exported GATT service is probably an issue on the periphal rather than to be an issue on the Central Device.
When you will need to implement the GATT client on the Central Device you still have two cases:
Bluez v4.x: Bluez does not expose the GATT API. Either you use a shell script to launch gatttool commands, or you use a GATT library such as gattlib to interact with the BLE device
Bluez v5.x: Same thing, if you cannot migrate to Bluez v5.39 then it is better to use Bluez v4.x methodology.
How do you retrieve the advertising payload for a Bluetooth LE emitter in Linux?
Specifically, I've configured Arduinos and Raspberry Pis using hcitool to act as iBeacons.
What I'm looking for is a command to print out what the current advertising payload is for the device.
At Radius Networks, we put together a set of scripts that parse the iBeacon identifiers out of BLE advertisement detected on Linux. You can find a description of this here.
If you simply want to see the raw advertisement bytes, you can start scanning on Linux with:
sudo hcitool lescan --duplicates &
And then see the results with:
sudo hcidump --raw
More details are in the answer linked above.
Since libpcap-1.0+ now supports Bluetooth capture you can use Wireshark/tshark/tcpdump to capture and display Bluetooth packets - both BTLE and other packet types.
To capture the LE packets with Wireshark you will still need to tell the Bluetooth interface to query for LE packets, as mentioned in the previous answer:
sudo hcitool lescan --duplicates &
In addition if you want the adapter to do a periodic query for Bluetooth devices, which are in discoverable mode, you can run (though these queries won't pick up BTLE emissions):
sudo hcitool spinq
sudo hcitool lescan --duplicates &
sudo hcitool spinq
Both commands runs an infinite loop
how to run a finite loop and get the data
I am working on using the Bluetooth low energy modem with Linux. I am using the command line option for that i.e. hcitool . I am able to the find the devices using the command: $ hcitool scan
It is working fine for me, also I am able to broadcast my device using :
sudo hciconfig hci0 leadv
It is also working fine. But I want to add the services and characteristic to the modem device which can be detected by other device. I have tried sdptool add but it is not working for me. Does anyone know how to add the services and characteristics to the peripheral using the command line tools in ubuntu?
Edit: My modem is broadcasting but not able to explore the services and characteristic to the other BLE device. Now I am able to set the name of device using hcio name command
Edit: Now I am able to render the services and characteristic, by simultaneously running sudo hcidump command. But I am not able to track from where I am getting those services and characteristics. One definite observation is those services are rendering from the machine.
SDP is absent in BLE. Broadcast/advertise frame and GATT client/server are used instead.
Several links:
BlueZ gatttool: command line tool to run common GATT procedures
BlueZ GATT's ready profiles
hint: DBUS
GATT and DBUS example
How can I connect to the FitBit Zip over Bluetooth 4.0 LE on Linux with bluez?
Bluetooth Low Energy: listening for notifications/indications in linux
http://comments.gmane.org/gmane.linux.bluez.kernel/29547
I used to broadcast BT services by following this article. This page not only shouws you how to advertise a profile, but also gives you an example on how to implement the HSP profile.
To know the bt class you need to announce, you can check this other page.
I need to use a USB Bluetooth dongle on a linux server.
Actually it works and I can discover other bluetooth devices, but if I try to connect with one of them (with rfcomm) it says Can't connect RFCOMM socket: Connection refused.
I think that the problem is the pairing, because when I type the same command on desktop systems, it asks the passkey to me, in a dialog window (not in the terminal).
So the question is: how can I pair a device without a desktop environment?
Thanks in advice.
This command works for me:
echo [PIN] | bluez-simple-agent hci0 [BT_MAC_ADDRESS]
If your device is already paired, then to request pairing again, commands as below. Or else error mesage as Creating device failed: org.bluez.Error.AlreadyExists: Already Exists
To remove pairing: bluez-test-device remove XX:XX:XX:XX:XX:XX
To pair again : bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX
If you happen to have than 1 bluetooth hardware and would like to use second one, use hciconfig to find adapter name and then use that name in place of hci#. Command as below
bluez-simple-agent hci# XX:XX:XX:XX:XX:XX