我通过在 BLE device
中使用多个 BluetoothGatt parameter
来实现连接到多个 Android
我使用 mBluetoothGatt.readRemoteRssi();
来阅读 RSSI ,并通过BroadcastReceiver
接收RSSI值,如下所示:
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);
}
}
};
我可以通过上面的代码获得 RSSI ,我也看到如下日志
11-07 17:09:29.595: D/BluetoothGatt(16612): onReadRemoteRssi() - Device=20:73:20:00:6C:C5 rssi=-56 status=0
但如果有多个 BLE device
,我会得到多个 RSSI
值,但没有 {{1} BLE address
如何获取 BroadcastReceiver
我正在阅读的 RSSI ?
我可以在 address of BLE device
中获得 address
吗?
提前致谢。
答案 0 :(得分:1)
BluetoothDevice
有一个名为getAddress()
的方法,它返回设备的MAC地址。
如果您没有方便,可以使用BluetoothDevice
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
的实例