Pairing works only on some android phones

Hi,

I am modifying the peripheral_uart code to set a fixed pairing method so that I will have to enter a pre-defined passkey in my nrf connect application on my android. It works fine with my android. So I assume my callbacks and workflows are all fine. However, when I try to pair from some other phones, it does not work anymore. I am not even prompted for a passkey in other phone. In some phones, pairing fails with an error message on central (android) side with message 'Couldn't pair with Nordic_UART_Service. Make sure that it's ready to pair' . After this, every attempt to pairing fails without any messages. For some other phones, we do not even see a message. The central says 'Bonding..' and then says 'Not bonded'.

The logs in the peripheral side does not say much either.

I cannot use Just Works or fixed passkey for pairing here. I am using NCS V2.1.0 and nrf52832DK

have anyone faced this kind of problem ? Any help would be appreciated. Thank you

  • Hello,

    From the log you shared I can see that Disconnect reason is 19, which is not an error. This just says that the peer decided to disconnect for some reason. This can be device specific, or may be because of something else (can be some other app) is running in the device.

    Could you also share the Phone details you are trying with? I can check if there is any reported issue about this.

    Kind Regards,

    Abhijith

  • Hi,

    I am using two Samsung phones - one running Android 8 and one running Android 11 (J and M series respectively.)

    I have a UART command to switch between Just Works and fixed passkey mode

    One another observation is as follow.

    Initially it was seen that the Android 8 one could not pair successfully. But Android 11 phone could pair( Note that there were still other Android 11 phones that could not connect. But that is not related to the observation). After a lot of pairing attempts and failures and switching between the Just Works and Fixed passkey methods, somehow in one random particular attempt,  the Android 8 could pair in either Just Works or Fixed passkey method. Which means, somehow the problem was solved on its own. Now I unpair the Android 8 phone and I check the Android 11 phone in which pairing was successful before. But it can no longer pair in either mode. Repeating the same cycles ( i.e pairing attempts failures and switching between different pairing methods using UART commands ), on one random attempt, I could pair with Android 11 phone. But as expected, when we try that on Android 8 ( after disconnecting Android 11), pairing no longer works.

    I hope I was clear about the whole incident. But I have no explanation for this behavior. Does this make any sense ?

    Thank you

  • Hello,

    It's bit hard to pinpoint the issue. Do you have more logs to share? Are you trying with  nRF connect mobile app? If so can you share the log from the App?

    Will be nice if you can share minimal project details which I can test here. Please let me know if I need to make this case private.

    Kind Regards,

    Abhijith

  • Hi,

    sorry for being late to reply. Here is the from the android application side as requested.

    nRF Connect, 2023-01-23
    demo2000 (DD:7A:68:B3:AC:32)
    V	15:39:52.130	Connecting to DD:7A:68:B3:AC:32...
    D	15:39:52.130	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	15:39:52.172	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    I	15:39:52.181	Disconnected
    D	15:39:52.724	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	15:39:52.724	gatt.close()
    D	15:39:52.738	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	15:39:52.738	Connected to DD:7A:68:B3:AC:32
    D	15:39:52.738	wait(200)
    V	15:39:52.940	Connecting to DD:7A:68:B3:AC:32...
    D	15:39:52.940	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	15:39:52.973	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	15:39:52.973	Connected to DD:7A:68:B3:AC:32
    V	15:39:52.981	Discovering services...
    D	15:39:52.981	gatt.discoverServices()
    I	15:39:53.016	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    I	15:39:53.078	PHY updated (TX: LE 2M, RX: LE 2M)
    D	15:39:53.409	[Callback] Services discovered with status: 0
    I	15:39:53.409	Services discovered
    V	15:39:53.423	Device Information (0x180A)
    - Manufacturer Name String [R] (0x2A29)
    - Model Number String [R] (0x2A24)
    - Serial Number String [R] (0x2A25)
    - Hardware Revision String [R] (0x2A27)
    - Firmware Revision String [R] (0x2A26)
    - Software Revision String [R] (0x2A28)
    Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
       Client Characteristic Configuration (0x2902)
    - Client Supported Features [R W] (0x2B29)
    - Database Hash [R] (0x2B2A)
    Generic Access (0x1800)
    - Device Name [R] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    Unknown Service (04d2ba59-e685-4b4e-91fe-4a028a00895f)
    - Unknown Characteristic [N] (04d20003-e685-4b4e-91fe-4a028a00895f)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [W WNR] (04d20002-e685-4b4e-91fe-4a028a00895f)
    SMP Service (8d53dc1d-1db7-4cd3-868b-8a527460aa84)
    - SMP Characteristic [N WNR] (da2e7828-fbce-4e01-ae9e-261174997c48)
       Client Characteristic Configuration (0x2902)
    D	15:39:53.423	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    D	15:39:53.426	gatt.setCharacteristicNotification(04d20003-e685-4b4e-91fe-4a028a00895f, true)
    I	15:39:53.465	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms)
    I	15:39:57.878	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 420ms)
    V	15:40:19.148	Starting pairing...
    D	15:40:19.148	device.createBond()
    D	15:40:19.235	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D	15:40:19.301	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
    I	15:40:19.301	Bonding failed
    D	15:40:22.271	[Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
    I	15:40:22.271	Disconnected
    D	15:40:22.289	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    V	15:40:32.372	Starting pairing...
    D	15:40:32.372	device.createBond()
    D	15:40:32.445	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D	15:40:32.640	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	15:40:32.640	gatt.close()
    D	15:40:32.651	wait(200)
    V	15:40:32.854	Connecting to DD:7A:68:B3:AC:32...
    D	15:40:32.855	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	15:40:32.881	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
    I	15:40:32.881	Bonding failed
    D	15:40:32.894	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	15:40:32.894	Connected to DD:7A:68:B3:AC:32
    V	15:40:32.901	Discovering services...
    D	15:40:32.901	gatt.discoverServices()
    I	15:40:33.161	PHY updated (TX: LE 2M, RX: LE 2M)
    I	15:40:33.475	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D	15:40:33.796	[Callback] Services discovered with status: 0
    I	15:40:33.796	Services discovered
    V	15:40:33.809	Device Information (0x180A)
    - Manufacturer Name String [R] (0x2A29)
    - Model Number String [R] (0x2A24)
    - Serial Number String [R] (0x2A25)
    - Hardware Revision String [R] (0x2A27)
    - Firmware Revision String [R] (0x2A26)
    - Software Revision String [R] (0x2A28)
    Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
       Client Characteristic Configuration (0x2902)
    - Client Supported Features [R W] (0x2B29)
    - Database Hash [R] (0x2B2A)
    Generic Access (0x1800)
    - Device Name [R] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    Unknown Service (04d2ba59-e685-4b4e-91fe-4a028a00895f)
    - Unknown Characteristic [N] (04d20003-e685-4b4e-91fe-4a028a00895f)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [W WNR] (04d20002-e685-4b4e-91fe-4a028a00895f)
    SMP Service (8d53dc1d-1db7-4cd3-868b-8a527460aa84)
    - SMP Characteristic [N WNR] (da2e7828-fbce-4e01-ae9e-261174997c48)
       Client Characteristic Configuration (0x2902)
    D	15:40:33.809	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    D	15:40:33.812	gatt.setCharacteristicNotification(04d20003-e685-4b4e-91fe-4a028a00895f, true)
    I	15:40:33.877	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms)
    I	15:40:37.792	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 420ms)
    V	15:40:52.632	Starting pairing...
    D	15:40:52.632	device.createBond()
    D	15:40:52.714	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D	15:40:52.781	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
    I	15:40:52.781	Bonding failed
    D	15:40:55.753	[Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
    I	15:40:55.753	Disconnected
    D	15:40:55.765	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    V	15:40:59.977	Starting pairing...
    D	15:40:59.977	device.createBond()
    D	15:41:00.061	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D	15:41:00.267	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	15:41:00.267	gatt.close()
    D	15:41:00.280	wait(200)
    V	15:41:00.485	Connecting to DD:7A:68:B3:AC:32...
    D	15:41:00.485	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	15:41:00.509	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
    I	15:41:00.509	Bonding failed
    D	15:41:00.527	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	15:41:00.527	Connected to DD:7A:68:B3:AC:32
    V	15:41:00.533	Discovering services...
    D	15:41:00.533	gatt.discoverServices()
    I	15:41:00.790	PHY updated (TX: LE 2M, RX: LE 2M)
    I	15:41:01.060	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D	15:41:01.382	[Callback] Services discovered with status: 0
    I	15:41:01.382	Services discovered
    V	15:41:01.396	Device Information (0x180A)
    - Manufacturer Name String [R] (0x2A29)
    - Model Number String [R] (0x2A24)
    - Serial Number String [R] (0x2A25)
    - Hardware Revision String [R] (0x2A27)
    - Firmware Revision String [R] (0x2A26)
    - Software Revision String [R] (0x2A28)
    Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
       Client Characteristic Configuration (0x2902)
    - Client Supported Features [R W] (0x2B29)
    - Database Hash [R] (0x2B2A)
    Generic Access (0x1800)
    - Device Name [R] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    Unknown Service (04d2ba59-e685-4b4e-91fe-4a028a00895f)
    - Unknown Characteristic [N] (04d20003-e685-4b4e-91fe-4a028a00895f)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [W WNR] (04d20002-e685-4b4e-91fe-4a028a00895f)
    SMP Service (8d53dc1d-1db7-4cd3-868b-8a527460aa84)
    - SMP Characteristic [N WNR] (da2e7828-fbce-4e01-ae9e-261174997c48)
       Client Characteristic Configuration (0x2902)
    D	15:41:01.396	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    D	15:41:01.399	gatt.setCharacteristicNotification(04d20003-e685-4b4e-91fe-4a028a00895f, true)
    I	15:41:01.464	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms)
    I	15:41:05.424	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 420ms)
    V	15:41:09.147	Starting pairing...
    D	15:41:09.147	device.createBond()
    D	15:41:09.223	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D	15:41:09.293	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
    I	15:41:09.293	Bonding failed
    V	15:41:10.897	Starting pairing...
    D	15:41:10.897	device.createBond()
    D	15:41:11.001	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D	15:41:11.045	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
    I	15:41:11.045	Bonding failed
    D	15:41:14.025	[Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
    I	15:41:14.025	Disconnected
    D	15:41:14.106	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    

    My code is built on the peripheral_uart example with some modifications to switch back and forth between Just Works mode and fixed passkey bonding. Please find attached the zipped code.

    peripheral_uart_switch.zip

    BTN3 on the DK to unpair and BTN4 on the DK to switch to Just Work. BTN2 to switch back to fixed passkey.

    Hope these helps. Please let me know if anything else is needed.

    Thank you

  • Hello,

    Are you working with 5340dk or 52832dk. Could you please confirm this? I will try to reproduce this from my side.

    Kind Regards,

    Abhijith

Related