My first attempt at using RxAndroidBle. Scanning for a single instance of a specific kind of device:
static boolean scanForDevice() {
asScanSubscription = asBleClient
.scanBleDevices( asServiceId ) // returns Observable<RxBleScanResult>
.first()
.map( rxBleScanResult -> rxBleScanResult.getBleDevice() ) // returns Observable of the one device
.subscribe( bleDevice -> asBleDevice = bleDevice, // save in a variable
throwable -> { throw new BleScanException( 0 ); },
( ) -> { throw new BleServiceNotFoundException( asServiceId ); } // didn't find it
);
return true;
}
My problem is in the "throwable" code for the subscribe call. I would like to be able to throw a BleScanException, but I don't know where to get the correct integer parameter describing the reason for the error. How can I find this out?
In general, where can I get details about the specific Throwable that is passed to a subscriber on errors?
Would appreciate any additional comments about this approach.