Java Code Examples for com.polidea.rxandroidble2.internal.RxBleLog#i()

The following examples show how to use com.polidea.rxandroidble2.internal.RxBleLog#i() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackgroundScannerImpl.java    From RxAndroidBle with Apache License 2.0 6 votes vote down vote up
@RequiresApi(26 /* Build.VERSION_CODES.O */)
@Override
public void scanBleDeviceInBackground(@NonNull PendingIntent callbackIntent, ScanSettings scanSettings, ScanFilter... scanFilters) {
    if (Build.VERSION.SDK_INT < 26 /* Build.VERSION_CODES.O */) {
        RxBleLog.w("PendingIntent based scanning is available for Android O and higher only.");
        return;
    }
    if (!rxBleAdapterWrapper.isBluetoothEnabled()) {
        RxBleLog.w("PendingIntent based scanning is available only when Bluetooth is ON.");
        throw new BleScanException(BleScanException.BLUETOOTH_DISABLED);
    }

    RxBleLog.i("Requesting pending intent based scan.");
    final List<android.bluetooth.le.ScanFilter> nativeScanFilters = scanObjectsConverter.toNativeFilters(scanFilters);
    final android.bluetooth.le.ScanSettings nativeScanSettings = scanObjectsConverter.toNativeSettings(scanSettings);
    final int scanStartResult = rxBleAdapterWrapper.startLeScan(nativeScanFilters, nativeScanSettings, callbackIntent);

    if (scanStartResult != NO_ERROR) {
        final BleScanException bleScanException = new BleScanException(scanStartResult);
        RxBleLog.w(bleScanException, "Failed to start scan"); // TODO?
        throw bleScanException;
    }
}
 
Example 2
Source File: ScanOperation.java    From RxAndroidBle with Apache License 2.0 6 votes vote down vote up
@Override
final protected void protectedRun(final ObservableEmitter<SCAN_RESULT_TYPE> emitter, QueueReleaseInterface queueReleaseInterface) {

    final SCAN_CALLBACK_TYPE scanCallback = createScanCallback(emitter);

    try {
        emitter.setCancellable(new Cancellable() {
            @Override
            public void cancel() {
                RxBleLog.i("Scan operation is requested to stop.");
                stopScan(rxBleAdapterWrapper, scanCallback);
            }
        });
        RxBleLog.i("Scan operation is requested to start.");
        boolean startLeScanStatus = startScan(rxBleAdapterWrapper, scanCallback);

        if (!startLeScanStatus) {
            emitter.tryOnError(new BleScanException(BleScanException.BLUETOOTH_CANNOT_START));
        }
    } catch (Throwable throwable) {
        RxBleLog.w(throwable, "Error while calling the start scan function");
        emitter.tryOnError(new BleScanException(BleScanException.BLUETOOTH_CANNOT_START, throwable));
    } finally {
        queueReleaseInterface.release();
    }
}
 
Example 3
Source File: BackgroundScannerImpl.java    From RxAndroidBle with Apache License 2.0 5 votes vote down vote up
@RequiresApi(26 /* Build.VERSION_CODES.O */)
@Override
public void stopBackgroundBleScan(@NonNull PendingIntent callbackIntent) {
    if (Build.VERSION.SDK_INT < 26 /* Build.VERSION_CODES.O */) {
        RxBleLog.w("PendingIntent based scanning is available for Android O and higher only.");
        return;
    }
    if (!rxBleAdapterWrapper.isBluetoothEnabled()) {
        RxBleLog.w("PendingIntent based scanning is available only when Bluetooth is ON.");
        return;
    }

    RxBleLog.i("Stopping pending intent based scan.");
    rxBleAdapterWrapper.stopLeScan(callbackIntent);
}
 
Example 4
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 5 votes vote down vote up
public static void logCallback(String callbackName, BluetoothGatt gatt, int status, BluetoothGattCharacteristic characteristic,
                               boolean valueMatters) {
    if (!RxBleLog.isAtLeast(LogConstants.INFO)) {
        return;
    }
    AttributeLogWrapper value = new AttributeLogWrapper(characteristic.getUuid(), characteristic.getValue(), valueMatters);
    RxBleLog.i(commonMacMessage(gatt) + commonCallbackMessage() + commonStatusMessage() + commonValueMessage(),
            callbackName, status, value);
}
 
Example 5
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 5 votes vote down vote up
public static void logCallback(String callbackName, BluetoothGatt gatt, BluetoothGattCharacteristic characteristic,
                               boolean valueMatters) {
    if (!RxBleLog.isAtLeast(LogConstants.INFO)) {
        return;
    }
    AttributeLogWrapper value = new AttributeLogWrapper(characteristic.getUuid(), characteristic.getValue(), valueMatters);
    RxBleLog.i(commonMacMessage(gatt) + commonCallbackMessage() + commonValueMessage(), callbackName, value);
}
 
Example 6
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 5 votes vote down vote up
public static void logCallback(String callbackName, BluetoothGatt gatt, int status, BluetoothGattDescriptor descriptor,
                               boolean valueMatters) {
    if (!RxBleLog.isAtLeast(LogConstants.INFO)) {
        return;
    }
    AttributeLogWrapper value = new AttributeLogWrapper(descriptor.getUuid(), descriptor.getValue(), valueMatters);
    RxBleLog.i(commonMacMessage(gatt) + commonCallbackMessage() + commonStatusMessage() + commonValueMessage(),
            callbackName, status, value);
}
 
Example 7
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 5 votes vote down vote up
public static void logCallback(String callbackName, BluetoothGatt gatt, int status, int value) {
    if (!RxBleLog.isAtLeast(LogConstants.INFO)) {
        return;
    }
    RxBleLog.i(commonMacMessage(gatt) + commonCallbackMessage() + commonStatusMessage() + commonValueMessage(),
            callbackName, status, value);
}
 
Example 8
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 5 votes vote down vote up
public static void logConnectionUpdateCallback(String callbackName, BluetoothGatt gatt,
                                               int status, int interval, int latency, int timeout) {
    if (!RxBleLog.isAtLeast(LogConstants.INFO)) {
        return;
    }
    String customValueMessage = ", interval=%d (%.2f ms), latency=%d, timeout=%d (%.0f ms)";
    RxBleLog.i(commonMacMessage(gatt) + commonCallbackMessage() + commonStatusMessage() + customValueMessage,
            callbackName, status, interval, interval * 1.25f, latency, timeout, timeout * 10f);
}
 
Example 9
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
public static void logOperationRunning(Operation operation) {
    RxBleLog.i("RUNNING  %s", operation);
}
 
Example 10
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
public static void logCallback(String callbackName, BluetoothGatt gatt, int status) {
    if (!RxBleLog.isAtLeast(LogConstants.INFO)) {
        return;
    }
    RxBleLog.i(commonMacMessage(gatt) + commonCallbackMessage() + commonStatusMessage(), callbackName, status);
}