I'm right now focusing on Android, but I believe the answers to these questions apply to any operating system, they just will use different functions to get the data.
Once I've established a BLE connection, I can BluetoothGatt.readRemoteRssi() to "Read the RSSI for a connected remote device."
First question: am I understanding this function correctly, it is returning to me the strength of the signal (transmitted from the remote BLE device) that my Android device is receiving, right? I think it's the function name that's throwing me off, shouldn't the name just be readRssi()? readRemoteRssi() makes me think there's a companion function readLocalRssi() somewhere.
Second question: assuming I am understanding the function correctly, is there anything built into Bluetooth that lets me ask "what is the remote BLE device seeing for RSSI?" In other words, of the signal that the Android device is transmitting, how much of that is reaching the remote BLE device?
ADDED LATER
Based on the answer I got, apparently I'm not explaining myself very well. Let me try again.
The remote BLE device is transmitting with a certain power, and those radio waves head out in all directions, and some of those waves are received by my mobile device. My mobile device measures how strong those waves are, and that's reported as RSSI. RSSI stands for "Received Signal Strength Indicator" and since it's the local mobile device that's doing the receiving, it seems strange to name the function "remote". Of course RSSI measures something coming from a remote transmitter - otherwise it wouldn't be very useful.
Similarly, the mobile device is transmitting with a certain power, and those radio waves head out in all directions, and some of those radio waves are received by the remote BLE device. That remote BLE device measures the strength of those waves, and that would be his RSSI. My second question is asking whether there's anything in the Bluetooth standard (a predefined characteristic, for example, like "Battery Level") that lets me mobile device query the remote BLE device and ask "Hey dude, how much signal you getting?"
am I understanding this function correctly, it is returning to me the strength of the signal
(transmitted from the remote BLE device) that my Android device is receiving, right?
Actually rssi is calculated by ble chip based on the advertising packets that are received from the remote device. We don't directly get the rssi value from remote device.
I think it's the function name that's throwing me off, shouldn't the name just be readRssi()?
No. We are actually reading remote device's rssi.
readRemoteRssi() makes me think there's a companion function readLocalRssi() somewhere.
No there is no such method as rssi is determined at the other end to which the current device is connected to.
assuming I am understanding the function correctly, is there anything built into Bluetooth that lets me ask "what is the remote BLE device seeing for RSSI?" In other words, of the signal that the Android device is transmitting, how much of that is reaching the remote BLE device?
It is rssi. It is calculated based on how many advertising packets received against total packets.
Note: some of my answers are my guess based on my experience.
Related
I have a BLE device (self made) that I pair with my app (iOS+Android).
I want to notify the user when the bluetooth signal is weak or better - when the device is about to disconnect.
Searching the web resulted with RSSI being the only value that is related to signal, yet I was unable to find a RSSI threshold that hints possible disconnection.
Is there a way to know?
Thanks a lot,
Giora.
The ability to connect to a BLE device with weak RSSI varies a lot depending on the phone you're using to connect to your device.
With some smartphones, especially those running on Android 8+, you might be able to stay connected to a BLE device advertising with a weak RSSI, whereas with some other smartphone, you're might have issue staying connected to a device with a strong RSSI.
It also depends on the quality of the BLE chip on your peripheral.
To answer your question, I would say you need to run some calibration tests, establishing the average RSSI at which your center or peripheral throws a disconnection, and start from there.
You'll need to calculate this average across several types of phones, including Android and iOS's, or, even better, set a threshold per OS.
I have been doing a ton of research on this project I want to do, probably read every SO post (bluejacking, RFCOMM, beacons, etc...) and my head is spinning.
I want to create a system at home, using Arduino (with bluetooth le) that will scan bluetooth and detect when my phone or any of my family members phones are in proximity. Whether this is a MAC scanner or simply getting the friendly name. I would also like to get the RSSI. I dont need to do accurate distance measurement but I would like to know approximately how close they are. Does anybody have any suggestions for this approach? I know I can create an app on the phone and have it become a beacon and this may be an option but I am concerned with Android, it would have to be Marshmallow 5.0 at a minimum. I would like support to be a little lower than that, like JB or KK. So, it seems like there should be a simple scan, just looking for the MAC or name. That is all I really need.
That said, the main question I have is, can you scan for and see bluetooth devices in range if they are already paired to something? Like a Bluetooth headset? I understand bluetooth is point to point but does it allow multiple connections or at least broadcast the mac or name when paired?
This question, along with any general suggestions will help me out tremendously!
Thanks!
Bluetooth Discovery from the Listener involves Listening for Bluetooth Inquiry packets(RX) and inquiry response (TX).if done continuously this will deplete the battery. Hence most devices (including Mobile Phones and Headsets) has a policy of when to be discover-able and connectable. Headsets in particular are discoverable only when they are instructed and connectable until one device is connected to it ( There are probably exceptions where the headset has the capability to be connected to multiple phones at the same time). Most Mobile Phones are discoverable only when they are in settings screen ( Android,IOS and Windows Phones), but unlike the headset case they are connectable.
so one option with the MobilePhone is to see if it is possible to connect to them after pairing once ( for example by trying a service search on the remote device and see if it returns the service attributes, this internally makes a connection and indirectly ensures the presence of the device).
if you are specific about a mobile phone which is already paired then you might need to establish a higherlayer connection ( such as SPP) with Authentication and encryption. This would force a two way check between devices to see whether they are already paired. other less secure option is to rely on the Phone (Android and IOS phones doesn't generally Allow a higher layer connection without encryption/pairing) and try to establish an SPP connection to the phone.
Another option is to use Bluetooth-LowEnergy. But Note that security in BT was superior to BLE till BTv4.1 and same on BTv4.2.
I am making an app to alarm the users if their phone is being stolen. I will use an Android phone and an arduino Bluetooth device to be the point of reference ..
My problem is.. is it possible that to set a specific range to the android Bluetooth to trigger the alarm of the phone??
Because my plan is if distance between the arduino and the Android phone reaches 3 meters both the device will alarm..
Pls. I need your help..
One of the most obvious ways you can do this keep the socket connection open until it disconnects. Bluetooth range is approximately 32feet (10m) for most devices upon which the device will be disconnected. Upon disconnection the user can be notified (on the connection being lost/ bike stolen?).
Android's low energy bluetooth might be a solution if you want to conserve battery life, otherwise the normal version is fine.
If you want to get really fancy you can use geocoding(using longitude and latitude of both where your phone is and where the bike is) if the distance exceeds a certain distance( more realistically a couple of 100 meters) a notification can be sent to the phone about a possible bike theft situation.
you can use BLE GATT server and send heart bit to client when heart bit not deliver client is not in Bluetooth range . you cant find distance between two Bluetooth device
i have been reading about proximity security devices through bluetooth, but i am wondering how it works in reality. As far as i have been reading, there are two techniques:
constant scanning from a master. The central device scans the target device every x minutes. When the target is into range, it gives back MAC bluetooth address and RSSI. The negative side is that being constantly into discoverable mode drains the battery, so does the master device that has to be constantly scanning for devices.
Paired and connected. As some product details: "Your laptop locks itself down when you step a certain distance away, and opens again once you're in range". It means that after paring and connected processes, the master can have information when the slave device is out of range, or get inside range again. In bluetooth 4, is going to be even as a profile.
Regarding to the second option, which feature is this? how it works? i mean, maybe you can code a sequence number counter that counts everytime the slave sends a packet through RFCOMM every x milisecs (android or ios), but what i dont understand is how a slave can connect to master again in a transparent way, when normally two bluetooth devices disconnect when they are out of range each other (so you cant send information again from the same bluetooth socket RFCOMM connection).
How proximity devices works in reality? how can you code it?
Bluetooth 4.0 (BT Low Energy) is a whole other animal than traditional Bluetooth. It is designed from the ground up to be good at things like the Proximity profile you describe. Basically a computer and a fob create a connection to periodically communicate at a slow interval, say once every 5 seconds. When you go out of range the connection drops due to a timeout and the PC knows the fob is gone. The PC side isn't power constrained, so it can constantly or periodically scan for the fob when connections are dropped. The fob can advertise its presence using infrequent advertisement packets, which costs only a small amount of power.
Note that there is no RFCOMM in BT LE. Android and other BT stacks currently lack BT LE support because it is too new. Only a few devices exist which actually use BT LE, so getting much real info is hard right now. In a few years this will be much bigger. The new iPhone 4S and new macbooks have the 4.0 BT chips, so you can expect more usage soon.
I have a question about bluetooth RSSI functionality on the Android (either 2.0 or 2.1):
It's easy enough to get the RSSI value when a bluetooth connection is created, but how can you repeatedly get the RSSI value of a connection that is already active? It's really important to be able to do this, because this lets you determine if bluetooth devices are close to each other or far away, but I can't find any appropriate function calls in the Android API.
Could someone who understands Android RSSI please help me with this problem?
Thanks!
Alex
At the HCI level, there is a command to read a Bluetooth link RSSI from the Bluetooth chipset (Read_RSSI_Command). However its implementation can vary from Bluetooth chipset to Bluetooth chipset. And the value returned is not always useful, for example if there are no packets transmitted in the last few minutes, the Bluetooth chipset has no way to know the current RSSI.
So we don't expose this in any Android Java API at this time.
Nick Pelly
Android Bluetooth Team