我無法弄清楚如何獲得'onReadRemoteRssi'回調工作。Android藍牙低功耗readRemoteRssi
我的代碼是非常簡單的:
final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter();
BluetoothGatt gatt;
mBluetoothAdapter.startLeScan(new LeScanCallback() {
@Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] record) {
gatt = device.connectGatt(getApplicationContext(), false, new BluetoothGattCallback() {
@Override
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
super.onReadRemoteRssi(gatt, rssi, status);
Log.d(TAG, "rssi is : " + rssi);
}
});
}
});
gatt.readRemoteRssi(); //returns true
回調永遠不會被調用。 有沒有人有任何想法?
謝謝!
你解決這個問題? – phcaze