delante_v
Posts: 4
Joined: Fri Oct 04, 2013 6:36 pm
Location: British Columbia, Canada

Constantly obtain RSSI from Android Device

Thu Oct 10, 2013 11:50 pm

EDIT: I guess people don't seem to understand what I mean. Basically, I can't get Android devices to be constantly connected to the Raspberry Pi continuously. The devices are paired and trusted, but won't connect

I can run an App called "Bluetooth File Transfer" and it can allow one Pi to be connected to the Android device at one time. I'm looking for a way that can connect 4 or 5 Pi's simultaneously.

----------------------------------------------------------------------------------------------------

I am wondering if there is a simple method to maintain the Bluetooth data / file transfer "port / gateway" open continuously so the RSSI value can be obtained between a Raspberry Pi and an Android device.

A bit of a background...
I have a team project taking place for my Engineering study, and we are attempting to create a triangulation / tracking system with the use of multiple Raspberry Pi's through the RSSI values of a user device (i.e. smartphone, laptop, tablet). We've decided to use WiFi and/or Bluetooth, but after extensive testing, we believe Bluetooth is the more suitable technology - as the power requirement is much lower compared to WiFi, and our system is being designed to function in a household environment.

Example, we have a RPi located on each of the four corners of a home, constantly obtaining the RSSI of one user device. The four values are then compared to a table of pre-set values to determine where the individual is, within the perimeter of the home.
Say...the RSSI values are -7, -15, -20, -30. According to the table, the person is in the kitchen.
0, -10, - 25, -25. The person is in the bedroom.

We are using the latest version of Debian Wheezy available as of now, and the wireless USB Bluetooth dongle that we are using is the IOGear GBU521 Bluetooth 4.0 (Broadcom BCM20702A0).

Our testing shows pairing the RPi with Apple devices, and continuously obtaining the RSSI value until the device is out of range (or disconnect) is very successful.

How we did it:
1) install bluetooth package

Code: Select all

sudo apt-get install --no-install-recommends bluetooth
2) Enable Bluetooth and device discovering on Apple / Android Device
3) Obtain BT MAC address

Code: Select all

hcitool scan
4) Connect / pair with Apple / Android Device

Code: Select all

sudo rfcomm connect 0 [MAC Address] 10>/dev/null &
5)
a) continuously obtain RSSI value via

Code: Select all

hcitool rssi [MAC Address]
b) watch the RSSI value every 0.5 or 0.25 second

Code: Select all

watch -n 0.25 hcitool rssi [MAC Address]
c) Write a simple script so it writes to a file every 0.25 seconds so we can examine the values later

Code: Select all

#!/bin/bash
echo "testing rssi /n"> logs1
while (true)
do
hcitool rssi [MAC Address]>> logs1
date +%S
date +%S>> logs1
sleep 0.25
done
NOW, on the Android devices we were having some difficulties. "hcitool scan is able to detect the Android device, but it fails to connect when using "rfcomm" (at least that's what is said on the RPi). Oddly enough, it says they are paired on the Android device. Due to this, we were unable to obtain the RSSI value. We were stuck on this for a few weeks.

After a bit more research, we tried another approach by using Bluez and blueman.
Installed Bluez and blueman...and any other useful packages...and connect

Code: Select all

sudo apt-get install bluetooth bluez-utils blueman
sudo apt-get install bluetooth bluez-utils bluez-compat
sudo bluez-simple-agent hci0 [MAC Address]
sudo bluez-test-device list
sudo bluez-test-device trusted [MAC Address] yes
sudo bluez-test-device trusted [MAC Address] (to ensure the device is trusted)
sudo bluez-test-input connect [MAC Address]
We have also changed/added a line of code to /etc/network/interfaces (but I don't think it is needed for our type of application)

Code: Select all

iface bnep0 inet dhcp

Code: Select all

sudo bluez-test-input connect 00:00:00:00:0B:9D
gives us an error saying
Traceback (most recent call last):
File " /usr/bin/bluez-test-input", line 40, in <module>
input.Connect()
File " /usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70 in _call_
return self._proxy_method(*args, **keyworsds)
File " usr/lib/python2.7/dist-package/dbus/proxies.py" , line 145, in _call_
**keywords)
File " usr/lib/python2.7/dist-package/dbus/connection.py" , line 651, in call_
blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method
"Connect" with signature " " on interface "org.bluez.Input" doesn't exist
A fellow student of ours suggested that the RPi and the Android device are actually paired (as it indicates this on the Android device), but the "port / gate" between the two are not "open" until there is data being transferred between the two. So, we bit the bullet and tried to see if that was the cause of the issue. Sure enough, we sent a file from the Android to RPi via bluetooth, and we were able to get the RSSI value while the file was being transferred by using

Code: Select all

hcitool rssi [MAC Address]
As soon as the fire transfer is complete, the "port / gate" will close, and a "Disconnected" message will appear when when we try to run hcitool rssi. The two are still paired (according to the Android).

We've discovered that either the RPi or the Android device can be the initiator for the file transfer. Furthermore, RSSI can be obtained via "hcitool rssi" even if the Android device DOES NOT accept the file transfer. To elaborate, it can be sitting there, waiting for the Android device to Accept the transfer and the RSSI can still be obtained. Once the response request times-out, the "port" is again closed.

So the question:
What is a simple (doesn't necessary need to be efficient) way to keep the port open so the RSSI value can be retrieved continuously until the Android device is out or range (or until disconnected)?
Is there a way to continuously ping the Android device or send a small data file (i.e a few bytes or KB) so the "port" is kept open?

** Apple products don't run into the above problem (for some reason) as it seems that the "port" is always open - even if there is no data transfer. This is odd as we assumed Apple devices have more security procedures (less open) than Android devices.
Last edited by delante_v on Thu Oct 17, 2013 8:55 pm, edited 3 times in total.

Mark90
Posts: 2
Joined: Fri Oct 11, 2013 8:09 am

Re: Constantly obtain RSSI from Android Device

Fri Oct 11, 2013 8:13 am

Tried this? hcitool didn't work here either but this worked at the first instant. Make sure that bluez and python-bluez are installed. https://code.google.com/r/allamericansl ... 84f01267c8

Mark90
Posts: 2
Joined: Fri Oct 11, 2013 8:09 am

Re: Constantly obtain RSSI from Android Device

Fri Oct 11, 2013 9:16 am

Seems like my post didn't get through.. let's try again.

Have you tried this? https://code.google.com/r/allamericansl ... 84f01267c8

hcitool didn't work for me either but this worked at the first attempt.

delante_v
Posts: 4
Joined: Fri Oct 04, 2013 6:36 pm
Location: British Columbia, Canada

Re: Constantly obtain RSSI from Android Device

Fri Oct 11, 2013 8:13 pm

Mark90 wrote:Seems like my post didn't get through.. let's try again.

Have you tried this? https://code.google.com/r/allamericansl ... 84f01267c8

hcitool didn't work for me either but this worked at the first attempt.
Thank you Mark90! I will definitely give this a try.
Your help is greatly appreciated.

Cheers,
Victor

delante_v
Posts: 4
Joined: Fri Oct 04, 2013 6:36 pm
Location: British Columbia, Canada

Re: Constantly obtain RSSI from Android Device

Thu Oct 17, 2013 3:17 am

I guess people don't seem to understand what I mean. Basically, I can't get Android devices to be constantly connected to the Raspberry Pi continuously. The devices are paired and trusted, but won't connect

I can run an App called "Bluetooth File Transfer" and it can allow one Pi to be connected to the Android device at one time. I'm looking for a way that can connect 4 or 5 Pi's simultaneously.

I've tinkered with the hciconfig settings (SLAVE, MASTER, disable authentication, changed device class), and that couldn't solve my problem.

So far, Apple devices and even an very old phone (2005 / 2006 era) were able constantly be connected to the Pi via Bluetooth.

critak
Posts: 6
Joined: Wed Feb 26, 2014 8:27 am

Re: Constantly obtain RSSI from Android Device

Wed Mar 26, 2014 11:56 am

Hey delante_v!
It's been a time since your last post and i'm wondering how you ended up with this problem?
because i have a related problem. =)

Would be cool if you could post your final approach.

kidkangaroo
Posts: 2
Joined: Mon Mar 03, 2014 2:53 pm

Re: Constantly obtain RSSI from Android Device

Wed May 21, 2014 3:04 pm

Trying to so something simlar - any luck? I see there are quite a few other people stuck at a similar spot trying to get a Bluez/Pi to connect to an Android.

CharminXtra
Posts: 1
Joined: Tue Aug 05, 2014 4:21 am

Re: Constantly obtain RSSI from Android Device

Tue Aug 05, 2014 4:24 am

If anyone's still interested, I got valid rssi data while doing an l2ping of the android.

ayush.agarwal93
Posts: 3
Joined: Fri Jul 03, 2015 3:43 pm
Location: India
Contact: Website

Re: Constantly obtain RSSI from Android Device

Mon Aug 03, 2015 5:19 pm

CharminXtra wrote:If anyone's still interested, I got valid rssi data while doing an l2ping of the android.
yes i am still looking for a solution to this, i also tried l2ping it sends 0 bytes and doesn't show any rssi value and ends up with an error "connection terminated by peer"
The early bird may catch the warm but the second mouse gets the cheese.

TheGoldyMan
Posts: 4
Joined: Wed Oct 01, 2014 12:44 am

Re: Constantly obtain RSSI from Android Device

Sat Oct 17, 2015 6:03 pm

I can run an App called "Bluetooth File Transfer" and it can allow one Pi to be connected to the Android device at one time. I'm looking for a way that can connect 4 or 5 Pi's simultaneously.
I'm having the exact same problem with you, only that I only want my Android to connect to one RPI. As I understood, you were able to do that by download "Bluetooth File Transfer" on Android.

Could you please elaborate more on that? What did you do after installing the app? Does it drain battery significantly?

Thanks

bisun
Posts: 16
Joined: Fri Nov 20, 2015 2:10 pm

Re: Constantly obtain RSSI from Android Device

Tue Dec 01, 2015 9:21 am

Hello!
I've just a question about how to get the RSSI value. I'm using a raspberry with wheezy and an edimax dongle. I want to get the RSSI from an access point by wifi and I've tried the command line
Hcitool RSSI [MAC ADDRESS] but it doesn't work ...
Maybe this command line only works for Bluetooth
Could you help me please ?

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

Re: Constantly obtain RSSI from Android Device

Tue Dec 01, 2015 2:47 pm

bisun wrote: Hcitool RSSI [MAC ADDRESS] but it doesn't work ...
Maybe this command line only works for Bluetooth
Yes, 'hcitool' is only for the Bluetooth adapter.

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

Re: Constantly obtain RSSI from Android Device

Wed Apr 20, 2016 7:18 pm

Hi, I'm trying to do something similar, I am trying to know the RSSI from An Android device (Constantly ) for the same use, to know how (aprox) is someone.

I try with bluetoothtcl , and when you do a scan (scan on) you obtain ALL the RSSI from ALL the devices wich can caught the BLE RPi (I use the RPI 3 ;) . And as long as I can consider, I think they appear when they are moved in a peiod of time. For example if you dont move any BLE device, they only appear one time, if they are continiously in movement they apper in a period of 10 15 sseconds I dont know.

This is the format of a scan result

[MAC] + [ID] + [RSSI]


But its realy strange, when you are paired and connected to a device, I am not able to get the rssi, only appear [MAC] + [ID]

I hope we coluld help together.

Ohood
Posts: 7
Joined: Sat Mar 10, 2018 12:44 pm

Re: Constantly obtain RSSI from Android Device

Sun Mar 11, 2018 2:32 pm

Pepinho wrote:
Wed Apr 20, 2016 7:18 pm
Hi, I'm trying to do something similar, I am trying to know the RSSI from An Android device (Constantly ) for the same use, to know how (aprox) is someone.

I try with bluetoothtcl , and when you do a scan (scan on) you obtain ALL the RSSI from ALL the devices wich can caught the BLE RPi (I use the RPI 3 ;) . And as long as I can consider, I think they appear when they are moved in a peiod of time. For example if you dont move any BLE device, they only appear one time, if they are continiously in movement they apper in a period of 10 15 sseconds I dont know.

This is the format of a scan result

[MAC] + [ID] + [RSSI]


But its realy strange, when you are paired and connected to a device, I am not able to get the rssi, only appear [MAC] + [ID]

I hope we coluld help together.


please which scan has been give you this resulte

PTFmac
Posts: 1
Joined: Thu Apr 04, 2019 8:53 pm

Re: Constantly obtain RSSI from Android Device

Thu Apr 04, 2019 8:57 pm

Do you have any more info on this?
CharminXtra wrote:
Tue Aug 05, 2014 4:24 am
If anyone's still interested, I got valid rssi data while doing an l2ping of the android.

Return to “Automation, sensing and robotics”