3

Can anyone suggest how to continually read BT4-LE Signal Strength on Android API Level 18+ as to detect relative proximity to BT-LE beacons? I know that LE radio signal strength is returned during scanning (see: http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.LeScanCallback.html), but once scanning is complete and a connection is established is there anyway to get the updated BT-LE signal strength without rescanning?

moxy
  • 93
  • 1
  • 7

3 Answers3

1
if(newState == BluetoothProfile.STATE_CONNECTED) 
{
   TimerTask task = new TimerTask()
   {
      @Override
      public void run()
      {
         mBluetoothGatt.readRemoteRssi();
      }
   };
   Timer rssiTimer = new Timer();
   rssiTimer.schedule(task, 1000, 1000);
}
Hun
  • 3,652
  • 35
  • 72
0

You need to connect before you call readRemoteRssi() to read signal strength. Example code:

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status,
        int newState) {
    // TODO Auto-generated method stub
    String intentAction;
    if(newState == BluetoothProfile.STATE_CONNECTED) {
        intentAction = ACTION_GATT_CONNECTED;
        mConnectionState = STATE_CONNECTED;
        mBluetoothGatt.readRemoteRssi();

      

Samuel C.
  • 101
  • 2