Reputation: 33
I'm tryig the library for the first time on kotlin, because of that I read that in order to scan first I need to implement it with
implementation "com.polidea.rxandroidble2:rxandroidble:1.10.0"
, create an RxBleClient and set the scan parameters, but it seems to be a problem with the method scanBleDevices().
I tried the code that appears on the description of the repository and the code from the kotlin example.
With the code from the description, there is only an error on scanBleDevices
rxBleClient = RxBleClient.create(this)
val scanSubscription = rxBleClient.scanBleDevices(
new ScanSettings.Builder()
// .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY) // change if needed
// .setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES) // change if needed
.build()
// add filters if needed
)
.subscribe(
{
// Process scan result here.
},
{
// Handle an error here.
}
);
// When done, just dispose.
scanSubscription.dispose();
With the code from the kotlin examples, there is also an error with the Observable that shows No type arguments expected for class Observable
private fun scanBleDevices(): Observable<ScanResult> {
val scanSettings = ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
.build()
val scanFilter = ScanFilter.Builder()
//.setDeviceAddress("B4:99:4C:34:DC:8B")
// add custom filters if needed
.build()
return rxBleClient.scanBleDevices(scanSettings, scanFilter)
}
The problem occurs with the method scanBleDevices() that prompts an alert requesting scanSettings and scanFilter which they have been used it correctly:
None of the following functions can be called with the arguments supplied.
scanBleDevices(ScanSettings!, vararg ScanFilter!) defined in com.polidea.rxandroidble2.RxBleClient
scanBleDevices(vararg UUID!) defined in com.polidea.rxandroidble2.RxBleClient
Upvotes: 0
Views: 657
Reputation: 3222
If compiler complains about ScanSettings
and ScanFilter
then check the package of those classes if you import them from com.polidea.rxandroidble2
or from android.bluetooth.le
(or similar)
The library accepts in this API only ScanSettings
and ScanFilter
classes from com.polidea.rxandroidble2
package.
Upvotes: 3