DeviceStateLister pop after Bluetooth turn off

  • After implemented the changes of V3, we found a issue with the DeviceStateListener.
    Then turn off the Bluetooth and after some seconds on, the Smartphone connect automatically to our device. But SweetBlue don't recognize that its actually connected, instead we get a NATIVE_CONNECTION_FAILED error and also stop reconnection although we set our own DeviceReconnectFilter with ConnectionFailPlease.retry(). So I have to open the App and click our reconnect button, after that its recognizes the connection. I know that the Smartphone is successfully connected to our device, because we get a flash callback from it.
    Add to that the DeviceStateListener don't listen on any state, but if I turn Bluetooth off, on, off and on, the DeviceStateListener works... in V2 we have no struggle with this.

  • There definitely seems to be some weirdness going on when turning BLE off/on. Thanks for the report.

    I'm not quite sure what you're asking about the DeviceStateListener though. Did you see this page? Specifically the part about state handling. Essentially, by default not all states are pumped through the listener anymore. If you want to change this, then you can do so by setting the BleManagerConfig.defaultDeviceStates options (it's an array of BleDeviceStates you want to be pumped through the listener when it changes).

  • Yeah we read the changes, added the new states and rename the old, also we added to our config the BleManagerConfig.defaultDeviceStates = BleDeviceState.VALUES() option. Normally this works and we see how the Listener enters the different states. But if we turn Bluetooth off and on, the DeviceStateListener enters no state. Only then we restart the App or turn Bluetooth again off and on. It's seems like the DeviceStateListener is not active or pop automatically although we don't call the new popListener_State() method.

  • I believe this to be fixed for the next version. A state wasn't getting set properly when BLE got turned off for each device, which caused very weird things to happen.

  • I'm having the same problems on v3.0.2, where as I connect, turn Bluetooth off and on again, it'll automatically reconnect (at least that's what the sensor says),but a NATIVE_CONNECTION_FAILED is given.