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

The following examples show how to use com.polidea.rxandroidble2.internal.RxBleLog#isAtLeast() . 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: LegacyScanOperation.java    From RxAndroidBle with Apache License 2.0 6 votes vote down vote up
@Override
BluetoothAdapter.LeScanCallback createScanCallback(final ObservableEmitter<RxBleInternalScanResultLegacy> emitter) {
    return new BluetoothAdapter.LeScanCallback() {
        @Override
        public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
            if (filterUuids != null && RxBleLog.isAtLeast(LogConstants.DEBUG)) {
                RxBleLog.d("%s, name=%s, rssi=%d, data=%s",
                        LoggerUtil.commonMacMessage(device.getAddress()),
                        device.getName(),
                        rssi,
                        LoggerUtil.bytesToHex(scanRecord)
                );
            }
            if (filterUuids == null || uuidUtil.extractUUIDs(scanRecord).containsAll(filterUuids)) {
                emitter.onNext(new RxBleInternalScanResultLegacy(device, rssi, scanRecord));
            }
        }
    };
}
 
Example 2
Source File: ScanOperationApi18.java    From RxAndroidBle with Apache License 2.0 6 votes vote down vote up
@Override
BluetoothAdapter.LeScanCallback createScanCallback(final ObservableEmitter<RxBleInternalScanResult> emitter) {
    return new BluetoothAdapter.LeScanCallback() {
        @Override
        public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
            if (!scanFilterMatcher.isEmpty() && RxBleLog.isAtLeast(LogConstants.DEBUG) && RxBleLog.getShouldLogScannedPeripherals()) {
                RxBleLog.d("%s, name=%s, rssi=%d, data=%s",
                        LoggerUtil.commonMacMessage(device.getAddress()),
                        device.getName(),
                        rssi,
                        LoggerUtil.bytesToHex(scanRecord)
                );
            }
            final RxBleInternalScanResult internalScanResult = scanResultCreator.create(device, rssi, scanRecord);
            if (scanFilterMatcher.matches(internalScanResult)) {
                emitter.onNext(internalScanResult);
            }
        }
    };
}
 
Example 3
Source File: CharacteristicLongWriteOperation.java    From RxAndroidBle with Apache License 2.0 5 votes vote down vote up
void writeData(byte[] bytesBatch, IntSupplier batchIndexGetter) {
    if (RxBleLog.isAtLeast(LogConstants.DEBUG)) {
        RxBleLog.d("Writing batch #%04d: %s", batchIndexGetter.get(), LoggerUtil.bytesToHex(bytesBatch));
    }
    bluetoothGattCharacteristic.setValue(bytesBatch);
    final boolean success = bluetoothGatt.writeCharacteristic(bluetoothGattCharacteristic);
    if (!success) {
        throw new BleGattCannotStartException(bluetoothGatt, BleGattOperationType.CHARACTERISTIC_LONG_WRITE);
    }
}
 
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 logOperationStarted(Operation operation) {
    if (RxBleLog.isAtLeast(LogConstants.DEBUG)) {
        RxBleLog.d("STARTED  %s(%d)", operation.getClass().getSimpleName(), System.identityHashCode(operation));
    }
}
 
Example 10
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
public static void logOperationRemoved(Operation operation) {
    if (RxBleLog.isAtLeast(LogConstants.DEBUG)) {
        RxBleLog.d("REMOVED  %s(%d)", operation.getClass().getSimpleName(), System.identityHashCode(operation));
    }
}
 
Example 11
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
public static void logOperationQueued(Operation operation) {
    if (RxBleLog.isAtLeast(LogConstants.DEBUG)) {
        RxBleLog.d("QUEUED   %s(%d)", operation.getClass().getSimpleName(), System.identityHashCode(operation));
    }
}
 
Example 12
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
public static void logOperationFinished(Operation operation, long startTime, long endTime) {
    if (RxBleLog.isAtLeast(LogConstants.DEBUG)) {
        RxBleLog.d("FINISHED %s(%d) in %d ms", operation.getClass().getSimpleName(),
                System.identityHashCode(operation), (endTime - startTime));
    }
}
 
Example 13
Source File: LoggerUtil.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
public static void logOperationSkippedBecauseDisposedWhenAboutToRun(Operation operation) {
    if (RxBleLog.isAtLeast(LogConstants.VERBOSE)) {
        RxBleLog.v("SKIPPED  %s(%d) just before running — is disposed", operation.getClass().getSimpleName(),
                System.identityHashCode(operation));
    }
}
 
Example 14
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);
}
 
Example 15
Source File: LoggerUtilBluetoothServices.java    From RxAndroidBle with Apache License 2.0 4 votes vote down vote up
public void log(RxBleDeviceServices rxBleDeviceServices, BluetoothDevice device) {
    if (RxBleLog.isAtLeast(LogConstants.VERBOSE)) {
        RxBleLog.v("Preparing services description");
        RxBleLog.v(prepareServicesDescription(rxBleDeviceServices, device));
    }
}