问题描述
Android BluetoothGatt.class
具有 mClientIf
私有字段.与BLE事件有关的大多数日志消息都包含此值.例如:
Android BluetoothGatt.class
has mClientIf
private field. Most of the log messages related to BLE events contain this value. For example:
mClientIf
字段代表什么?该字段的整数值说明什么?
What does the mClientIf
field represent? What does the integer value of this field tell?
推荐答案
mClientf
是来自蓝牙扫描器的 scannerId
,
mClientf
is a scannerId
from Bluetooth scanner,
如果您深入研究BluetoothGatt和BluetoothLeScanner的来源,则可以找到以下内容:
If you dig through the source of BluetoothGatt and BluetoothLeScanner you can find the following:
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 BluetoothGatt类中的clientIf字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!