This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Android, bluetooth & rssi

Other Parts Discussed in Thread: CC2541

Hi,

I am developing an application for android (using API Level 18) where I need to know how far is my cc2541 keyfob.

I only get the rssi value if I call the method startLeScan(). That is, I have to connect and disconnect repeatedly to know rssi value constantly . Is there any way to automate this work? Is there any way to get the rssi value without having to connect and disconnect repeatedly?

Another question, there are other options to know the distance which is the chip? I can use the proximity profile and get tx power value, but I think this value is not used to know the distance, I'm wrong?

last observation,  in the sample application for iPhone to test cc2541 keyfob, there is a chart that is constantly updated rssi value. So I guess if you can get rssi value in iOS, should also be possible in Android.

Sorry for my English and sorry for  all these questions, I am just new to all this and confused. If anybody has any idea, please share.

Thanks in advance.

Best Regards,

Rafa.
  • Rafa,

    You can use the proximity profile to get the RSSI information. However to find the actual distance of the chip would be a much more complicated effort. While all you get is the signal strength, it cannot be used to accurately give distance. You can at best do a range of distances and even then that would be accurate.

    The problem here, the range of the antenna varies with the design of the board, type of plastics, environment the board will be placed in. So it is very difficult to give an accurate location with a single antenna.

    I know there is effort in Bluetooth SIG to get locationing. But that is a complex system with multiple antennas and algorithms to find exact loaction of a device.

  • Hi Chatto!

    Thank you very much for answering so fast.


    Great, for me is enough with a range of distances, for example:
    Awsome signal strength ~ very close
    Good signal strength ~ close
    Bad signal strength ~ away

    I still have a question, how I can get the RSSI value? I know how to get the RSSI value through the method calling "onLeScan()", but I think it is bad practice to close the connection and re-create the connection every time I want to know the value, especially if you want to do many times in a short time. Is there any way to know the RSSI value constantly? Or always have to close the connection to the chip in order to get the value of RSSI?
    I think I heard in Google I/O conferences ("Best Practices for Bluetooth Development") that it isn't a good practice scanning continuously because it spent a lot of battery. Is there any way to get the RSSI value without closing the connection? Is there any way to get the RSSI value without use "onLeScan()" method?

    The last question, as I have to use the Proximity Profile for information about the approximate distance? I can use the Link Loss Service, the Immediate Alert Service and the Tx Power Service, but if I understand correctly, this does not help me to get the RSSI value. Or the Tx Power is related to the distance?

    Thank you very much.

    Regards,


    Rafa.

  • Rafa,

    You can use the BluetoothGatt object to get the RSSI of a connected device. More information here: http://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#readRemoteRssi()

  • Anyway to do the same on ios?

  • You're right, I did it like this:

    @Override
    public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status){

    DeviceControlActivity.setRssi(addRssiValue(rssi)); //my code

    }

    readRemoteRssi (): "Read the RSSI for a connected remote device"

    ... "The onReadRemoteRssi(BluetoothGatt, int, int) callback will be invoked when the RSSI value has been read."


  • Hi Chatto, thank you very much for your information, is very useful and I realize you're right, it is very difficult to know the distance using a single antenna. I finished my application and distance measurements are not very accurate.

  • Hi Rafa

    I am new to BLE and Android, I reference the sample of BluetoothLeGatt in Android API18,and I can scan ,connect and discover the Services in my android APP.

    But I don't know how to use proximity profile to get the RSSI or alert on link loss in android 4.3 API 18??

    or does it has any sample can reference ??


    I have use readRemoteRssi and onReadRemoteRssi, but I don't why the value of RSSI is 0 here. This is my log at readRemoteRssi and onReadRemoteRssi.

    D/BluetoothGatt( 3684): readRssi() - device: 90:59:AF:0B:8A:AB
    D/BtGatt.GattService( 2463): readRemoteRssi() - address=90:59:AF:0B:8A:AB   

      

    D/BtGatt.GattService( 2463): onReadRemoteRssi() - clientIf=4 address=90:59:AF:0B:8A:AB, rssi=0, status=0 
    D/BluetoothGatt( 3684): onReadRemoteRssi() - Device=90:59:AF:0B:8A:AB rssi=0 status=0

    Thanks

    I am pressing need know how to do...

  • Rdfa

    Me too.....