I am looking for a solution to monitor BLE devices near my raspberry with their RSSI value. So far I am done with monitoring, all devices and the current rssi value is displayed on screen, but I would like to
store the values in a database or
send them to RabbitMQ (either solution is fine).
I am using btmon for monitoring which has a switch "-s" or "--server". Unfortunately I did not find any useful documentation on it (might be my fault). I thought this might start monitoring in a way that I can query it from another application. Any clue?
The other solution could be node.js/noble, but noble installation always fails.
Well, btmon could not be my solution as device discovery needs to be triggered with hcitool lescan which does not have a recurrence parameter (only hcitool scan has). The solution finally was node.js/noble. The installation failed, because I tried to do it with the latest version of noble.js. Going back to 10.x solved the problem.
Related
I'm trying to build a small program that reads the BLE beacons around my devices and parses the ones that I'm interested in to publish on MQTT. I'm using Raspberry Pis to run the code, I develop using my mac. The language is JS (Node 10.x), my Pis are running latest Buster, that is Bluez 5.50 and a fork of Noble to interface with the bluetooth layer.
For some reason, on one of the Pis that I moved to an open area (in order to get clear readings), I only receive the Scan Response Packets. I never receive the Advertisement Packet. I do sometimes receive the Advertisement packet for one of the device that is quite far away, making me suspect that signal comes in play here. From the Pis in the network cabinet (small Faraday cage) I do get inconsistently both packets every now and then (reason for dedicating a Pi in an open location).
Is there any way to force Bluez to always receive the Advertisement packet? Is there a bug somehow or a feature that I am not using properly?
EDIT
I installed tshark to monitor closely, and I do see the advertisement packet reaching my device. This means that BlueZ is ignoring them. Is there some complete documentation on how to use bluetoothctl and how to configure the bluetooth deamon/tool in order for these packets to be read?
After many days investigating, I manage to get the desired result for my project. I first thought of using the bluewalker project to access the raw packets. With this you can scan in passive mode, meaning only the advertising packet is retrieved.
By looking more in depth into noble project, the one I actually use to interface with, there is a workaround to scan in passive mode (https://github.com/noble/noble/issues/701), but also a variable to capture both advertising and response packets: NOBLE_REPORT_ALL_HCI_EVENTS. Setting this to 1 will give me exactly what I need, both the scan request which contains the data that changes more frequently, and the scan response that contains more data, such as min/max 24h values. And as a matter of fact, combining this setting with duplicates=false seems to give me only the scan request data, just like in passive mode.
Question still opened:
Having this, I still don't know how to use bluetoothctl to display both scan request data along with the scan response. Nor did I find a way to force the scan mode to passive. I could investigate more hcitool hciconfig, but they are deprecated (although every article on the internet refers to them).
like the title says, i am not able to connect to a le device on my raspberry pi 3.
I tried:
- via bluetoothctl i get an AutenthicationFailure
- via gatttool i get connection refused (111)
I searched a lot for a solution and already tried (made sure that):
- btmgmt le up
- reinstalling bluez/bluez to the newest version
- use of "-t random" when using gatttool
And know i really have no idea what to do next.
What might be important:
uname -r = 4.19.58-v7+
bluetoothctl -v = 5.50
Using the Android App nRF Connect the connection to the le device works fine.
Can somebody help me please?
Thanks in advance,
Magda
It looks like your device needs to be bonded and Bluez fails to successfully bond...
I have the same issue with several devices that need bonding. Bluez can apparently only deal with some variants of bonding but certainly not all. On iOS and Android I have no issues at all with those devices...
Unless you fancy digging into Bluez source code and fixing the issue yourself, I think you can only wait for some Bluez update to fix the issue...
I have set up a gatt Server on an raspberry pi using bluetoothctl and BlueZ 5.50 (according to this thread: BlueZ: How to set up a GATT server from the command line)
I can connect to the gatt server from an other machine and also read the given value. Now I want to try notify.
The subscription works fine, but how do I update the value on the local gatt server? I can't use select-attribute because my local services an characteristics do not show up in the list that appears when using autocomplete.
Would be nice if someone can help me with this problem.
I too faced the same prob and i found solution for the same.
i am using bluez5.49. whenever notify was enabled in client, notify_io will be created and pipe will be established.
so if you write data in pipe fd, then it will be notified to client.
I am working on emulating a Bluetooth headphone for automated testing using a raspberry pi as my headphone. Part of the challenge I was facing initially was to send AVRCP commands from the PI to the source device. I was delighted to find dbus and its capabilities in sending pause, play, next, and all the other commands. I wound up hitting a brick wall when it came to volume changes though. As it turns out the stock PulseAudio 9.0 binary doesn’t support absolute volume. After finding this patch - https://patchwork.freedesktop.org/patch/76558/ - I was able to set my volume on the source device (in my case an iPhone). After getting this fixed I went about trying to figure out how to send volume change commands from the PI to the source device. There is a property called Volume in org.bluez.MediaTransport1 that I can read but setting it has been a nightmare. I am always getting the following problems.
Command
qdbus --system org.bluez /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fdX
org.freedesktop.DBus.Properties.Set org.bluez.MediaTransport1 Volume
127
Response
Error: org.freedesktop.DBus.Error.InvalidSignature Invalid signature
for ‘Volume’
I have tried scouring the internet to come up with various payloads and nothing has worked. I’ve hit a brick wall in finding the proper way to set the volume. Any help would be greatly appreciated.
Thanks!
Little late, but let it be just in case:
dbus-send --system --type=method_call --print-reply=literal --dest=org.bluez /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/fdX org.freedesktop.DBus.Properties.Set string:org.bluez.MediaTransport1 string:Volume variant:uint16:127
As the title suggest, then I am trying to set a fixed bit rate on my dongle.
I am using a TP-Link wifi dongle model TL-WN722N. However, when I give the
command: iwconfig wlanX rate 2M fixed iget the following response:
Error for wireless request "Set Bit Rate" (8B20). But if i give it as sudo, then i dont get this error but running iwconfig reveals that it is not set.
My question is do any one have some experience in setting a fixed data rate on their wifi dongle ? ... if yes what kind of dongle are you using ... and also what command (if it is not iwconfig rate)
thx in advance
You should run this command with Sudo as you did.
The command will take, but the driver will not listen to this for the WN722N.
I am sure if you try this with your built in adapter or any other adapter if present; you will see that your command works.
I have personally tested this right now with the WN722N on Ubuntu v14 and I'm getting the same error.
Also, iw may give you more control for setting bitrate: http://linuxwireless.org/en/users/Documentation/iw/#Modifying_transmit_bitrates