@Test (expected = NullPointerException.class) public void scanForPeripheralsWithServicesTestNullTest() { application.grantPermissions(Manifest.permission.ACCESS_COARSE_LOCATION); central.scanForPeripheralsWithServices(null); }
public void scanForPeripheralsWithServices(@NotNull final UUID[] serviceUUIDs) { Objects.requireNonNull(serviceUUIDs, "no service UUIDs supplied"); if (serviceUUIDs.length == 0) { throw new IllegalArgumentException("at least one service UUID must be supplied"); } List<ScanFilter> filters = new ArrayList<>(); for (UUID serviceUUID : serviceUUIDs) { ScanFilter filter = new ScanFilter.Builder() .setServiceUuid(new ParcelUuid(serviceUUID)) .build(); filters.add(filter); } startScan(filters, scanSettings, defaultScanCallback); }
BluetoothCentral { public void scanForPeripheralsWithServices(@NotNull final UUID[] serviceUUIDs) { Objects.requireNonNull(serviceUUIDs, "no service UUIDs supplied"); if (serviceUUIDs.length == 0) { throw new IllegalArgumentException("at least one service UUID must be supplied"); } List<ScanFilter> filters = new ArrayList<>(); for (UUID serviceUUID : serviceUUIDs) { ScanFilter filter = new ScanFilter.Builder() .setServiceUuid(new ParcelUuid(serviceUUID)) .build(); filters.add(filter); } startScan(filters, scanSettings, defaultScanCallback); } }
BluetoothCentral { public void scanForPeripheralsWithServices(@NotNull final UUID[] serviceUUIDs) { Objects.requireNonNull(serviceUUIDs, "no service UUIDs supplied"); if (serviceUUIDs.length == 0) { throw new IllegalArgumentException("at least one service UUID must be supplied"); } List<ScanFilter> filters = new ArrayList<>(); for (UUID serviceUUID : serviceUUIDs) { ScanFilter filter = new ScanFilter.Builder() .setServiceUuid(new ParcelUuid(serviceUUID)) .build(); filters.add(filter); } startScan(filters, scanSettings, defaultScanCallback); } BluetoothCentral(@NotNull Context context, @NotNull BluetoothCentralCallback bluetoothCentralCallback, @NotNull Handler handler); }
BluetoothCentral { public void scanForPeripheralsWithServices(@NotNull final UUID[] serviceUUIDs) { Objects.requireNonNull(serviceUUIDs, "no service UUIDs supplied"); if (serviceUUIDs.length == 0) { throw new IllegalArgumentException("at least one service UUID must be supplied"); } List<ScanFilter> filters = new ArrayList<>(); for (UUID serviceUUID : serviceUUIDs) { ScanFilter filter = new ScanFilter.Builder() .setServiceUuid(new ParcelUuid(serviceUUID)) .build(); filters.add(filter); } startScan(filters, scanSettings, defaultScanCallback); } BluetoothCentral(@NotNull Context context, @NotNull BluetoothCentralCallback bluetoothCentralCallback, @NotNull Handler handler); void close(); boolean setScanMode(int scanMode); void scanForPeripheralsWithServices(@NotNull final UUID[] serviceUUIDs); void scanForPeripheralsWithNames(@NotNull final String[] peripheralNames); void scanForPeripheralsWithAddresses(@NotNull final String[] peripheralAddresses); void scanForPeripheralsUsingFilters(@NotNull List<ScanFilter> filters); void scanForPeripherals(); void stopScan(); boolean isScanning(); void connectPeripheral(@NotNull BluetoothPeripheral peripheral, @NotNull BluetoothPeripheralCallback peripheralCallback); void autoConnectPeripheral(@NotNull BluetoothPeripheral peripheral, @NotNull BluetoothPeripheralCallback peripheralCallback); void cancelConnection(@NotNull final BluetoothPeripheral peripheral); void autoConnectPeripheralsBatch(@NotNull Map<BluetoothPeripheral, BluetoothPeripheralCallback> batch); @NotNull BluetoothPeripheral getPeripheral(@NotNull String peripheralAddress); @NotNull List<BluetoothPeripheral> getConnectedPeripherals(); boolean isBluetoothEnabled(); boolean setPinCodeForPeripheral(@NotNull String peripheralAddress, @NotNull String pin); boolean removeBond(@NotNull String peripheralAddress); void startPairingPopupHack(); }
BluetoothCentral { public void scanForPeripheralsWithServices(@NotNull final UUID[] serviceUUIDs) { Objects.requireNonNull(serviceUUIDs, "no service UUIDs supplied"); if (serviceUUIDs.length == 0) { throw new IllegalArgumentException("at least one service UUID must be supplied"); } List<ScanFilter> filters = new ArrayList<>(); for (UUID serviceUUID : serviceUUIDs) { ScanFilter filter = new ScanFilter.Builder() .setServiceUuid(new ParcelUuid(serviceUUID)) .build(); filters.add(filter); } startScan(filters, scanSettings, defaultScanCallback); } BluetoothCentral(@NotNull Context context, @NotNull BluetoothCentralCallback bluetoothCentralCallback, @NotNull Handler handler); void close(); boolean setScanMode(int scanMode); void scanForPeripheralsWithServices(@NotNull final UUID[] serviceUUIDs); void scanForPeripheralsWithNames(@NotNull final String[] peripheralNames); void scanForPeripheralsWithAddresses(@NotNull final String[] peripheralAddresses); void scanForPeripheralsUsingFilters(@NotNull List<ScanFilter> filters); void scanForPeripherals(); void stopScan(); boolean isScanning(); void connectPeripheral(@NotNull BluetoothPeripheral peripheral, @NotNull BluetoothPeripheralCallback peripheralCallback); void autoConnectPeripheral(@NotNull BluetoothPeripheral peripheral, @NotNull BluetoothPeripheralCallback peripheralCallback); void cancelConnection(@NotNull final BluetoothPeripheral peripheral); void autoConnectPeripheralsBatch(@NotNull Map<BluetoothPeripheral, BluetoothPeripheralCallback> batch); @NotNull BluetoothPeripheral getPeripheral(@NotNull String peripheralAddress); @NotNull List<BluetoothPeripheral> getConnectedPeripherals(); boolean isBluetoothEnabled(); boolean setPinCodeForPeripheral(@NotNull String peripheralAddress, @NotNull String pin); boolean removeBond(@NotNull String peripheralAddress); void startPairingPopupHack(); static final int SCAN_FAILED_ALREADY_STARTED; static final int SCAN_FAILED_APPLICATION_REGISTRATION_FAILED; static final int SCAN_FAILED_INTERNAL_ERROR; static final int SCAN_FAILED_FEATURE_UNSUPPORTED; static final int SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES; static final int SCAN_FAILED_SCANNING_TOO_FREQUENTLY; }