Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling Bluetooth causes BLUETOOTH_NOT_ENABLED to be emitted from observeStateChanges #555

Closed
ncapdevi opened this issue Mar 20, 2019 · 0 comments
Labels
bug Bug that is caused by the library
Milestone

Comments

@ncapdevi
Copy link

If any of the above points seems to match your use case — consider using Google or creating a question on www.stackoverflow.com with
a tag rxandroidble where it will be easier to access by other people with similar questions. Issues that are not bugs or feature requests
will be closed.

Summary

If initial state of RxClient is bluetooth not enabled, and you enable bluetooth via the system intent, you will first receive another BLUETOOTH_NOT_ENABLED followed by a READY STATUS

Library version

1.8.2

Preconditions

Bluetooth disabled on the device

Steps to reproduce actual result

Have the device bluetooth disabled, start observing the state, and when you the it is disabled, request it to be enabled via the OS intent system, and enable it.

Minimum code snippet reproducing the issue

        rxBleClient.observeStateChanges().startWith(rxBleClient.state).subscribe { state: RxBleClient.State ->
            if(state == RxBleClient.State.BLUETOOTH_NOT_ENABLED){
                startActivityForResult(activity, Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_ENABLE_BT, null)
            }
            
        }

Logs from the application running with setting

Not seeing anything in the log

Actual result

  1. The state is actually being set to on, so the state shouldn't emit
  2. The state didn't change, as it was already BLUETOOTH_NOT_ENABLED so it hasn't changed it shouldn't emit

Expected result

observeStateChanges emits READY state after bluetooth has been enaled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that is caused by the library
Projects
None yet
Development

No branches or pull requests

2 participants