I need to scan ble
advertising permanently while i am not connected to my device to find it and know when connect to it (specific product). This scan is realized in foreground service to match 8.0 prerequisite.
To preserve a few battery, i want scan periodically (while respect the Android 7 limit of start amount/time). I see 2 differents implementations :
- Start the scan each X seconds and be able to stop it after Y seconds, the wait time will be X-Y.
Scan Wait Scan Wait
|--------------|------|--------------|------|---
|---------X-------->|---------X-------->|---
|------Y-----> |-----Y-----> |---
- Start the scan for X seconds, wait for Y seconds, start the scan for X seconds etc..
Scan Wait Scan Wait
|--------------|------|--------------|------|---
|------X---->|--Y->|------X---->|--Y->|---
I want to do it with Rx style and not with the simple timer (i am not an RX expert). I don't know what solution is better/easier to be developed.
This must be transparent to the client and must keep the original RxAndroidBle
working, subscribe = start the process and unsubscribe = stop the process.
I suppose I have to use Obersable.interval
but i don't see how to manage this
Any snippet/ example?