0
votes

I have problem about RSSI. I have reviewed resources from internet. But all of codes not working or I don't know way of the this. Just I want to receive the signal strength of the device that I connect via Bluetooth. Also, Am I need to use any a permission? Can you explain all of details about this? My codes as follows.

    private final BroadcastReceiver receiver = new BroadcastReceiver(){
    @Override
    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();
        if(BluetoothDevice.ACTION_FOUND.equals(action)) {
            int  rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
            Toast.makeText(BtControl.this,"  RSSI: " + rssi + "dBm", Toast.LENGTH_SHORT).show();
        }
    }
};

registerReceiver(receiver, new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
1

1 Answers

0
votes

you should register for ACTION_FOUND action. Change your registerreciever code to below.

registerReceiver(receiver, new IntentFilter(BluetoothDevice.ACTION_FOUND));

Also make sure you declare BLUETOOTH_ADMIN permission in the manifest file.