Search in sources :

Example 1 with BleCloseOperation

use of com.afunx.ble.blelitelib.operation.BleCloseOperation in project BleLiteLib4android by afunx.

the class BleGattClientProxyImpl method __close.

private void __close() {
    if (!mIsClosed) {
        mIsClosed = true;
        BleLiteLog.i(TAG, "__close() closing");
        // unregister
        unregister(BleOperation.BLE_CONNECT);
        unregister(BleOperation.BLE_DISCOVER_SERVICE);
        unregister(BleOperation.BLE_REQUEST_MTU);
        unregister(BleOperation.BLE_READ_CHARACTERISTIC);
        unregister(BleOperation.BLE_WRITE_CHARACTERISTIC);
        // create operation
        final BluetoothGatt bluetoothGatt = getBluetoothGatt();
        if (bluetoothGatt == null) {
            BleLiteLog.i(TAG, "__close() bluetoothGatt is null");
        }
        BleCloseOperation closeOperation = BleCloseOperation.createInstance(bluetoothGatt);
        // execute operation
        closeOperation.doRunnableSelfAsync(false);
        BleLiteLog.i(TAG, "__close() closed");
    } else {
        BleLiteLog.i(TAG, "__close() it is closed already");
    }
}
Also used : BluetoothGatt(android.bluetooth.BluetoothGatt) BleCloseOperation(com.afunx.ble.blelitelib.operation.BleCloseOperation)

Aggregations

BluetoothGatt (android.bluetooth.BluetoothGatt)1 BleCloseOperation (com.afunx.ble.blelitelib.operation.BleCloseOperation)1