是否可以连续扫描连接的蓝牙设备,询问其RSSI?
我实现了:
private BluetoothMessageReceivedListener bluetoothMessageReceivedListener = new BluetoothMessageReceivedListener() {
@Override
public void onBluetoothMessageReceived(final String message) {
BluetoothManager bluetoothManager = new BluetoothManager();
BluetoothManager bluetoothManager = new BluetoothManager();
BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter();
BluetoothGatt gatt;
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(deviceAddress);
BluetoothGatt bluetoothGatt = getBluetoothGatt(device);
if (bluetoothGatt == null) {
return false;
}
boolean rdRemoteRssi = bluetoothGatt.readRemoteRssi();
Log.d(FTAG, "BluetoothGatt readRemoteRssi : " + rdRemoteRssi);
return true;
}
};
失败,因为bluetoothmanager
在android.bluetooth.bluetoothmanager
中未公开。什么是解决方案?