【发布时间】:2013-11-17 01:47:15
【问题描述】:
我想在连接 gatt 后继续读取 rssi。代码如下:
final BluetoothDevice device = mBluetoothAdapter
.getRemoteDevice(address);
if (device == null) {
Log.w(TAG, "Device not found. Unable to connect.");
return false;
}
mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
Log.d(TAG, "Trying to create a new connection.");
boolean readRssiFlag = mBluetoothGatt.readRemoteRssi();
Log.i(TAG,"readRssiFlag: "+readRssiFlag);
mGattCallback 是这样的:
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
....
@Override
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
Log.i(TAG,"rssi = " + rssi);
}
...
};
并且 onReadRemoteRssi 不起作用。 请告诉我如何修改代码,或其他读取rssi的解决方案!
感谢您的建议!
【问题讨论】:
标签: android bluetooth-lowenergy rssi gatt