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

Problem with killing process in Android

Hello !

I've created an app based on the nrf blinky master : it works perfectly on my smartphones. But when I kill the app, and when I relaunch it, it doesn't connect (or it connects, but in 2 minutes at least)

Do you know why, please ? I've been searching for five days, but I couldn't fix the problem.

I wonder that it it due to the GATT, which has to be reinitialized ?

Parents
  • Hi,

    I'm not sure if it's the case, but it may be related to a way how you call device.connectGatt(..., autoConnect, ...). The first call should be with autoConnect = false, as it's much faster. If you want to keep device connected you also connect with false, but then, when device disconnects, call gatt.connect() which will use autoConnect = true. This parameter set to true adds the device to a list in the low level controller, so the CPU doesn't have to be waken up every time an adv packet is received to check if we should, or should not connect. Controller is power optimized, so it may connect after some time. When the app is killed (the gatt.close() was called) the autoConnect should again be set to false so that next connection is quick.

    nRF Blinky wasn't updated for some time now, please check nRF Toolbox app, a specially the BleManager class (link). It makes sure that autoConnect is false on the first call.

    Hope it helped...

    Aleksander

  • Hello, Thanks for your answer. I change "mBluetoothGatt = device.connectGatt(mContext, autoConnect, getGattCallback());" to mBluetoothGatt = device.connectGatt(mContext, false, getGattCallback()); It connects quicker. BUt again, when I kill the app, it doesn't reconnect, until I restart manually the Bluetooth. Do you know what can be the problem ?

    EDIT : in facts, it reconnects, but after 2 minutes !

Reply Children
No Data
Related