Hello, I'm using nrf52832, SDK 15 e softdevice 6.0.
Smartphone with issue has Android 9 or 10 and Bluetooth 5. Instead, all works fine with smartphone with Bluetooth 4.2
Smartphone used:
Samsung Galaxy S10+
Xiaomi Redmi Note 7
Huawei P30
Xiaomi mi 8
After the first scan, we store the device address of the selected device for connection. We perform the connection and all works fine. If we close the app and reconnect to device, all works fine.
But, if we reboot the smartphone and try to connect to address stored, the connection FAILS. Ever!
The only way to unlock from this, is to turn off and on the smartphone Bluetooth.
We found a workaround that works: perform scan before the connection and never use stored address.
This is the method used for connection:
mBluetoothGatt = myDevice.connectGatt(context, false, mGattCallback, BluetoothDevice.TRANSPORT_LE);
This is the Log after reboot: the connection fails
2020-04-03 13:13:58.500 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:13:58.501 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:13:58.501 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: could not find callback wrapper
2020-04-03 13:13:58.501 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:13:58.503 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: connect() - device: D9:B4:0A:DA:C8:9F, auto: false
2020-04-03 13:13:58.503 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: isSecureModeEnabled
2020-04-03 13:13:58.503 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: registerApp()
2020-04-03 13:13:58.503 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: registerApp() - UUID=16f3dcb6-ba5a-44bf-ad7b-c0da5beeb14c
2020-04-03 13:13:58.505 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: onClientRegistered() - status=0 clientIf=12
2020-04-03 13:14:03.513 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=12 device=D9:B4:0A:DA:C8:9F
2020-04-03 13:14:03.518 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: isSecureModeEnabled
2020-04-03 13:14:31.554 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:14:31.555 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:14:31.556 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: could not find callback wrapper
2020-04-03 13:14:31.556 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: cancelOpen() - device: D9:B4:0A:DA:C8:9F
2020-04-03 13:14:31.568 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: close()
2020-04-03 13:14:31.573 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: unregisterApp() - mClientIf=12
2020-04-03 13:15:08.042 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: onBluetoothStateChange: up=false
2020-04-03 13:15:08.042 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: Bluetooth is turned off, stop adv
2020-04-03 13:15:08.042 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: There are no active google scan apps, stop scan
2020-04-03 13:15:08.042 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: stopAllScan standalone boolean value is = false
2020-04-03 13:15:08.042 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: Exiting stopping all callback scans
2020-04-03 13:15:08.066 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: ondisableBLE
2020-04-03 13:15:08.066 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: There are no active google scan apps, stop scan
2020-04-03 13:15:08.066 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: stopAllScan standalone boolean value is = false
2020-04-03 13:15:08.066 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: Exiting stopping all callback scans
2020-04-03 13:15:08.227 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: onBluetoothStateChange: up=true
2020-04-03 13:15:08.227 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: onBluetoothStateChange: Bluetooth is on
2020-04-03 13:15:08.390 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:15:08.391 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:15:08.391 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: could not find callback wrapper
2020-04-03 13:15:08.392 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:15:08.393 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:15:08.393 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: could not find callback wrapper
This is the log after Bluetooth restarting: the connection works fine
2020-04-03 13:16:21.462 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:16:21.464 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:16:21.464 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: could not find callback wrapper
2020-04-03 13:16:21.465 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:16:21.467 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: connect() - device: D9:B4:0A:DA:C8:9F, auto: false
2020-04-03 13:16:21.467 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: isSecureModeEnabled
2020-04-03 13:16:21.467 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: registerApp()
2020-04-03 13:16:21.467 27399-27399/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: registerApp() - UUID=96ae62dc-4728-4bd0-8f54-e6e67542c1d8
2020-04-03 13:16:21.469 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: onClientRegistered() - status=0 clientIf=12
2020-04-03 13:16:22.425 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=12 device=D9:B4:0A:DA:C8:9F
2020-04-03 13:16:22.436 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: discoverServices() - device: D9:B4:0A:DA:C8:9F
2020-04-03 13:16:22.975 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: onConnectionUpdated() - Device=D9:B4:0A:DA:C8:9F interval=6 latency=0 timeout=500 status=0
2020-04-03 13:16:23.244 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: onSearchComplete() = Device=D9:B4:0A:DA:C8:9F Status=0
2020-04-03 13:16:23.351 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: setCharacteristicNotification() - uuid: 7d32c0f0-bef5-11e3-b1b6-0800200c9a66 enable: true
2020-04-03 13:16:23.456 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: onConnectionUpdated() - Device=D9:B4:0A:DA:C8:9F interval=28 latency=0 timeout=500 status=0
2020-04-03 13:16:23.615 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:16:23.616 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothAdapter: STATE_ON
2020-04-03 13:16:23.616 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothLeScanner: could not find callback wrapper
2020-04-03 13:16:27.673 27399-27420/com.spirometry.spirobanksmartsdksample D/BluetoothGatt: onConnectionUpdated() - Device=D9:B4:0A:DA:C8:9F interval=12 latency=0 timeout=400 status=0