我把mBluetoothGatt.readRemoteRssi(); 进入 mGattCallback。
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status,
int newState) {
// TODO Auto-generated method stub
String intentAction;
if(newState == BluetoothProfile.STATE_CONNECTED) {
intentAction = ACTION_GATT_CONNECTED;
mConnectionState = STATE_CONNECTED;
mBluetoothGatt.readRemoteRssi();
.
.
.
并将onReadRemoteRssi放在BluetoothGattCallback 函数中
.
.
.
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
}
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
final Intent rssiIntent = new Intent(BluetoothLeService.this, DeviceControl.class);
rssiIntent.putExtra(DeviceControl.RSSI, rssi);
}
};//BluetoothGattCallback End
它会调用readRemoteRssi()和onReadRemoteRssi(),但是我不知道为什么rssi是0...
日志看起来像:
D/BluetoothGatt( 3684): readRssi() - device: 90:59:AF:0B:8A:AB
D/BtGatt.GattService( 2463): readRemoteRssi() - address=90:59:AF:0B:8A:AB
.
.
.
D/BtGatt.GattService( 2463): onReadRemoteRssi() - clientIf=4 address=90:59:AF:0B:8A:AB, rssi=0, status=0
D/BluetoothGatt( 3684): onReadRemoteRssi() - Device=90:59:AF:0B:8A:AB rssi=0 status=0
我确定我的 BLE 设备是正常的。但我不知道为什么rssi值是o??
有人可以教我吗??
谢谢!!