Pepinho
Posts: 6
Joined: Wed Apr 20, 2016 6:53 pm

Code Obtain RSSI from raspberry3

Thu Apr 28, 2016 2:43 pm

Hi all, I need to know how I can obtain de REAL RSSI from a non-connected bluetooth device with my RPi3.

I know there is a program named bluetoothctl which I don't know how it works, I can't find anything about how it works bluetootctl. But when I used it, I can obtain ALL the REAL RSSI of ALL the bluetooth devices, only with a scanning. (scan on)

I do this.

1) bluetoothctl
2) scan on
(you will obtain something like this: "Device XX:XX:XX:XX:XX:XX RSSI: -48" )

It's so simple, but, the problem, it's that I need to work with this data, I am not able to get this data to process later. So I need some code, in c++(better) to do this.

I know hcitool, but you have to be connected and they not give you data until you are at a distance.

Thanks ;)

Dutch_Master
Posts: 360
Joined: Sat Jul 27, 2013 11:36 am

Re: Code Obtain RSSI from raspberry3

Thu Apr 28, 2016 2:59 pm

You need to redirect the output of the program to a file, so it can be stored until you can process it.

I'm not familiar with the tool but in general you should be able to do this (experiment a bit and study the various man pages!)

Code: Select all

bluetoothctl
scan on > rssi.txt
This redirects the output of the scan to the text file rssi.txt which you can then process later. No C++ code required ;)

Pepinho
Posts: 6
Joined: Wed Apr 20, 2016 6:53 pm

Re: Code Obtain RSSI from raspberry3

Thu Apr 28, 2016 3:09 pm

Dutch_Master wrote:You need to redirect the output of the program to a file, so it can be stored until you can process it.

I'm not familiar with the tool but in general you should be able to do this (experiment a bit and study the various man pages!)

Code: Select all

bluetoothctl
scan on > rssi.txt
This redirects the output of the scan to the text file rssi.txt which you can then process later. No C++ code required ;)
Yes, I try it, but this is not a command, sorry, I dont know how to explain exactly.

this is the code of terminal

[email protected]:~ $ bluetoothctl

[NEW] Controller B8:27:EB:90:E8:79 raspberrypi [default]

[bluetooth]#

and now you are able to use, only the commands of bluetoothctl where you can do a scan on
which it's scanning all the time for devices, and updating with new rssis until you do a scan off (even you can make another commands during the scan)

User avatar
Douglas6
Posts: 4645
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Code Obtain RSSI from raspberry3

Thu Apr 28, 2016 4:33 pm

Bluetoothctl is a CLI, and not very useful for piping into or out of. I've just started looking into this, but you might be able to monitor the scan events using hcidump (I THINK RSSI data is included.)

Code: Select all

sudo apt-get install bluez-hcidump 

Pepinho
Posts: 6
Joined: Wed Apr 20, 2016 6:53 pm

Re: Code Obtain RSSI from raspberry3

Thu Apr 28, 2016 5:57 pm

It seems incredible that bluez don't have anything done to get a simple data like this....bluez or anything...this is not new....and I kow a lot of projects that they use it. But I dont know how.

Thanks, Im going to invesigate about that.

emw
Posts: 44
Joined: Tue Apr 12, 2016 2:53 pm

Re: Code Obtain RSSI from raspberry3

Thu Apr 28, 2016 6:39 pm

Here is some sample code that does an lescan with rssi: https://github.com/glock45/intel-edison ... ter/scan.c

Pepinho
Posts: 6
Joined: Wed Apr 20, 2016 6:53 pm

Re: Code Obtain RSSI from raspberry3

Thu Apr 28, 2016 8:44 pm

I found this, https://stackoverflow.com/questions/217 ... 4#21790504

but the

Code: Select all

 sudo hcitool lescan --duplicates & 

retrieves me this : Set scan parameters failed: Input/output error.

so I google it and found this... https://stackoverflow.com/questions/220 ... -i-o-error

and I try but I can't fixed it.

So, now I have to say, I'm working on a virtual machine (ubuntu 12.04), and I am using the bluetooth of the integrated motherbase of my laptop. This could be a problem? I try with the hcitool scan and it works, returns all the bluetooth devices.


Yes, It was problem of the VM.
I tested on RPi3 and it works, now I'm trying to run the example provided here http://developer.radiusnetworks.com/ibe ... eacon_scan I, think you only have to run, because they only make this two commands (hcitool + hcidump) to get the data of a package an then filter.

First I do a chmod 777 (skipping all possible problems) and then ./nameScript but, nothing returns. And if you run it another time, you will get this, Set scan parameters failed: Input/output error. (the same as before with my laptop and VM) . You can fixed it by rebooting the system.

Return to “General discussion”