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

how to avoid automatic connection in Android while scanning for devices

Dear all,

I have a project with a nRF51822 based on S110 and SDK10. Almost everything is running fine, but every time I scan for devices, either by calling BluetoothAdapter.startDiscovery() or by doing it manually from Android Bluetooth Settings my Phone connects to the nRF51822.

How can I avoid that? What did I do wrong?

I have tried different values for ble_gap_adv_params_t.type, but I am not able to connect at all if I do not use BLE_GAP_ADV_TYPE_ADV_IND.

Is there an option that I have missed to tell the other peer not to automatically connect, but that allows to connect on demand?

My current peer for testing is a Samsung Galaxy S5 running Android 5.0.2.

The Phone does not automatically connect if I use BluetoothAdapter.startLeScan() (I have not tried BluetoothLeScanner.startScan()), but in Android 6 there is bug and it requires location services to be enabled and that is very hard to explain to the customers. So I would prefer to use BluetoothAdapter.startDiscovery().

UPDATE:

As BluetoothAdapter.startDiscovery() seems to be working fine in Android 6, I will use BluetoothAdapter.startLeScan() on Android 4.x and Android 5.x and BluetoothAdapter.startDiscovery() on Android 6.x and later.

But I still would like to check wether I did something wrong in my nRF51 firmware or if this is a bug in Android 5.x or my Samsung version of Android 5.x?

Related