ClientIf in Bluetooth Bluetooth Class

Android BluetoothGatt.classhas a mClientIfprivate field. Most log messages related to BLE events contain this value. For example:

onClientRegistered () - status = 0 clientIf = 17

What is a field mClientIf? What does the integer value of this field say?

+4
source share
2 answers

It's hard to say with absolute certainty, but looking at how it is used in the rest of the class, I would say that this is a unique identifier assigned by a layer called IBluetoothGatt.

0
source

mClientfis scannerIdfrom a bluetooth scanner,

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);
}
...
0

Source: https://habr.com/ru/post/1619046/


All Articles