Reputation: 2863
I have implement for connecting to multiple BLE device
by using multiple BluetoothGatt parameter
in Android
.
I use mBluetoothGatt.readRemoteRssi();
to read the RSSI , and receive the RSSI value via BroadcastReceiver
like the following code:
private final BroadcastReceiver mGattreceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
final String action = intent.getAction();
if(BluetoothLeService.EXTRA_RSSI.equalsIgnoreCase(action)){
int rssi = intent.getIntExtra(BluetoothLeService.EXTRA_RSSI, 0);
Log.i(TAG, "mGattreceiver BroadcastReceiver---rssi = " + rssi);
}
}
};
I can get the RSSI via above code , and I also see the log like the following
11-07 17:09:29.595: D/BluetoothGatt(16612): onReadRemoteRssi() - Device=20:73:20:00:6C:C5 rssi=-56 status=0
But if there has multiple BLE device
, I will get multiple RSSI
value but didn't has BLE address
in BroadcastReceiver
How to get the address of BLE device
which I am reading for RSSI ?
Can I get the address
in BroadcastReceiver
?
Thanks in advance.
Upvotes: 3
Views: 1532
Reputation: 427
BluetoothDevice
has a method called getAddress()
which returns the MAC address of the device.
If you don't have it handy, you can get an instance of BluetoothDevice
using BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Upvotes: 2