This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Android code with autoconnect implemented

Hi, I am planning to enable autoconnect feature in our app, the same way it is done in nrf-connect app. Is there any way to get the code for nrf-connect app or any other app with autoconnect implemented.

Or some documentation where I can find how to do this?

Thanks

Parents Reply
  • You can't call gatt.close() when it disconnects as this will release the gatt object. Also, the first connection should be with autoConnect=false, as it's much faster (active connection). When you get a callback onConnectionStateChange with State disconnected you there call gatt.connect() which (if you check the source code) will use true since then. We recommend using the BleManager class from nRF Toolbox. It handles it and common errors automatically. Source code for nRF Toolbox is on GitHub, for nRF Connect is not public.

Children
No Data
Related