Android BluetoothGatt.class
有 mClientIf
私有(private)字段。大多数与 BLE 事件相关的日志消息都包含此值。例如:
onClientRegistered() - status=0 clientIf=17
mClientIf
字段代表什么?此字段的整数值说明了什么?
最佳答案
mClientf
是蓝牙扫描器的scannerId
,
如果您深入了解 BluetoothGatt 和 BluetoothLeScanner 的源代码,您可以找到以下内容:
mBluetoothGatt.unregisterClient(scannerId);
方法实现在
GattService.java unregisterClient(int clientIf)
BluetoothLeScanner.java
...
/**
* Application interface registered - app is ready to go
*/
@Override
public void onScannerRegistered(int status, int scannerId) {
Log.d(TAG, "onScannerRegistered() - status=" + status +
" scannerId=" + scannerId + " mScannerId=" + mScannerId);
synchronized (this) {
if (status == BluetoothGatt.GATT_SUCCESS) {
try {
if (mScannerId == -1) {
// Registration succeeds after timeout, unregister client.
mBluetoothGatt.unregisterClient(scannerId);
} else {
mScannerId = scannerId;
mBluetoothGatt.startScan(mScannerId, mSettings, mFilters,
mResultStorages,
ActivityThread.currentOpPackageName());
}
} catch (RemoteException e) {
Log.e(TAG, "fail to start le scan: " + e);
mScannerId = -1;
}
} else {
// registration failed
mScannerId = -1;
}
notifyAll();
}
}
...
GattService.java
...
/**
* Unregister the current application and callbacks.
*/
private IBluetoothGatt mService;
.
.
public void unregisterClient(int clientIf) {
GattService service = getService();
if (service == null) return;
service.unregisterClient(clientIf);
}
...
关于android - Android BluetoothGatt 类中的 clientIf 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34158315/