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

Android pairing pop-up appears twice

I would like to establish bonding between my device and an android phone.

My device is acting as both a central and peripheral.  It functions in peripheral role in relation to the phone.  The mobile app is developed only for Android for now.

Application firmware is developed against SDK 16.

I am using peer_manager.  I call pm_init and pm_sec_params_set with

memset( &sec_param, 0, sizeof( ble_gap_sec_params_t ) );

// Security parameters to be used for all security procedures.
sec_param.bond = 1;
sec_param.mitm = 0;
sec_param.lesc = 1;
sec_param.keypress = 0;
sec_param.io_caps = BLE_GAP_IO_CAPS_NONE;
sec_param.oob = 0;
sec_param.min_key_size = 7;
sec_param.max_key_size = 16;
sec_param.kdist_own.enc = 1;
sec_param.kdist_own.id = 1;
sec_param.kdist_peer.enc = 1;
sec_param.kdist_peer.id = 1;

In the ble event handler for BLE_GAP_EVT_CONNECTED, I call

ble_gap_evt_t const *p_gap_evt = &pEvt->evt.gap_evt;

 pm_conn_secure( p_gap_evt->conn_handle, false );

( I have also tested using pm_handler_secure_on_connection with PM_HANDLER_SEC_DELAY_MS set to 75 and 500 mS )

I am NOTcalling pm_conn_sec_prams_reply at all.

I am calling pm_conn_sec_config_reply with allow_repairing = false

The problem I'm encountering is that the pairing pop-up is appearing twice to the user.  Is there a way to change the connection sequence so this pop-up only occurs 1 time?

Parents
  • Hi

    First off, can we try to narrow this issue down to either the Android app or the nRF application? Do you see these two pop-ups if you use the nRFConnect app for Android or the default Bluetooth Settings on your Android phone? If not, this would point to the issue being on the Android side, but if you see it on the nRFConnect app as well, it should be due to something the nRF is doing.

    Please also upload the log on the Android side when using the nRFConnect app so we can get some more details. I can't see anything wrong with the pm_handler_secure_on_connection log at least.

    Best regards,

    Simon

  • I have been testing with android nRFConnect and the pairing pop-up does show up 2x.. the same as in our custom app.

    Here is the log from android nRFConnect.

    nRF Connect, 2021-03-24
    Cala597f (ED:F7:F5:AE:59:7F)
    I 08:29:28.677 [Server] Server started
    V 08:29:28.682 Battery Service (0x180F)
    - Battery Level [N R] (0x2A19)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8914000-b3de-1e8c-f647-5d1eafad4e89)
    - Battery Level [N R] (0x2A19)
       Client Characteristic Configuration (0x2902)
    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)
    Unknown Service (a8910000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R W] (a8910001-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R W] (a8910002-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N R W] (a8910002-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [R W] (a8910002-b3de-1e8c-f647-5d1eafad4e89)
    - Battery Power State [N R W] (0x2A1A)
       Client Characteristic Configuration (0x2902)
    V 08:29:28.896 Connecting to ED:F7:F5:AE:59:7F...
    D 08:29:28.896 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D 08:29:28.978 [Server callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 08:29:28.978 [Server] Device with address ED:F7:F5:AE:59:7F connected
    I 08:29:28.978 [Server] MTU changed to 247
    D 08:29:29.013 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 08:29:29.013 Connected to ED:F7:F5:AE:59:7F
    D 08:29:29.013 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    V 08:29:29.017 Discovering services...
    D 08:29:29.017 gatt.discoverServices()
    D 08:29:29.080 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D 08:29:29.093 [Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_CONSENT (3)
    I 08:29:29.659 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D 08:29:30.363 [Callback] Services discovered with status: 0
    I 08:29:30.364 Services discovered
    V 08:29:30.385 Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    - Central Address Resolution [R] (0x2AA6)
    Generic Attribute (0x1801)
    Secure DFU Service (0xFE59)
    - DFU Packet [WNR] (8ec90002-f315-4f60-9fb8-838830daea50)
    - DFU Control Point [N W] (8ec90001-f315-4f60-9fb8-838830daea50)
       Client Characteristic Configuration (0x2902)
    Battery Service (0x180F)
    - Battery Level [N R] (0x2A19)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8911000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N R] (a8911001-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8912000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912001-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912002-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912003-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912004-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912005-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912006-b3de-1e8c-f647-5d1eafad4e89)
    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)
    Unknown Service (a8910000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N R W] (a8910001-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a8910002-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R] (a8910004-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R] (a8910005-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [R W] (a8910006-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8910003-b3de-1e8c-f647-5d1eafad4e89)
    - Battery Power State [N R] (0x2A1A)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a8910007-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a8910008-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a8910009-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a891000a-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8913000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N R W] (a8913001-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N] (a8913002-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [R] (a8913003-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R W] (a8913004-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N] (a8913005-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8914000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N] (a8914001-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    I 08:29:30.463 Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms)
    D 08:29:32.504 [Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_CONSENT (3)
    D 08:29:35.257 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDED (12)
    I 08:29:35.257 Device bonded
    It seems the bonding is being re-started when the connection parameters update.
Reply
  • I have been testing with android nRFConnect and the pairing pop-up does show up 2x.. the same as in our custom app.

    Here is the log from android nRFConnect.

    nRF Connect, 2021-03-24
    Cala597f (ED:F7:F5:AE:59:7F)
    I 08:29:28.677 [Server] Server started
    V 08:29:28.682 Battery Service (0x180F)
    - Battery Level [N R] (0x2A19)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8914000-b3de-1e8c-f647-5d1eafad4e89)
    - Battery Level [N R] (0x2A19)
       Client Characteristic Configuration (0x2902)
    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)
    Unknown Service (a8910000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R W] (a8910001-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R W] (a8910002-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N R W] (a8910002-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [R W] (a8910002-b3de-1e8c-f647-5d1eafad4e89)
    - Battery Power State [N R W] (0x2A1A)
       Client Characteristic Configuration (0x2902)
    V 08:29:28.896 Connecting to ED:F7:F5:AE:59:7F...
    D 08:29:28.896 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D 08:29:28.978 [Server callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 08:29:28.978 [Server] Device with address ED:F7:F5:AE:59:7F connected
    I 08:29:28.978 [Server] MTU changed to 247
    D 08:29:29.013 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 08:29:29.013 Connected to ED:F7:F5:AE:59:7F
    D 08:29:29.013 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    V 08:29:29.017 Discovering services...
    D 08:29:29.017 gatt.discoverServices()
    D 08:29:29.080 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D 08:29:29.093 [Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_CONSENT (3)
    I 08:29:29.659 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D 08:29:30.363 [Callback] Services discovered with status: 0
    I 08:29:30.364 Services discovered
    V 08:29:30.385 Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    - Central Address Resolution [R] (0x2AA6)
    Generic Attribute (0x1801)
    Secure DFU Service (0xFE59)
    - DFU Packet [WNR] (8ec90002-f315-4f60-9fb8-838830daea50)
    - DFU Control Point [N W] (8ec90001-f315-4f60-9fb8-838830daea50)
       Client Characteristic Configuration (0x2902)
    Battery Service (0x180F)
    - Battery Level [N R] (0x2A19)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8911000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N R] (a8911001-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8912000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912001-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912002-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912003-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912004-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912005-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8912006-b3de-1e8c-f647-5d1eafad4e89)
    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)
    Unknown Service (a8910000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N R W] (a8910001-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a8910002-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R] (a8910004-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R] (a8910005-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [R W] (a8910006-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R] (a8910003-b3de-1e8c-f647-5d1eafad4e89)
    - Battery Power State [N R] (0x2A1A)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a8910007-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a8910008-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a8910009-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N R W] (a891000a-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8913000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N R W] (a8913001-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [N] (a8913002-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    - Unknown Characteristic [R] (a8913003-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [R W] (a8913004-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N] (a8913005-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    Unknown Service (a8914000-b3de-1e8c-f647-5d1eafad4e89)
    - Unknown Characteristic [N] (a8914001-b3de-1e8c-f647-5d1eafad4e89)
       Client Characteristic Configuration (0x2902)
    I 08:29:30.463 Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms)
    D 08:29:32.504 [Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_CONSENT (3)
    D 08:29:35.257 [Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDED (12)
    I 08:29:35.257 Device bonded
    It seems the bonding is being re-started when the connection parameters update.
Children
  • Also, when I pair directly with Android "Pair New Device" in bluetooth settings.  I only get the pairing pop-up 1 time.

    These are device logs generated while pairing from Android Bluetooth settings:

    [00:00:10.922,000] <info> app: phone connected. conn_handle: 0x1
    [00:00:10.998,000] <info> app: PM security params requested
    [00:00:11.000,000] <info> app: PM security params requested
    [00:00:11.000,000] <info> app: phone security param request
    [00:00:11.044,000] <info> app: ATT mtu_central=247 mtu_peripheral=247
    [00:00:11.179,000] <info> app: ATT mtu_central=247 mtu_peripheral=247
    [00:00:11.179,000] <info> app: phone Data len: tx_octets=251 rx_octets=27 tx_uS=2120 rx_uS=328
    [00:00:11.560,000] <info> nrf_ble_lesc: Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: 1
    [00:00:11.719,000] <info> app: phone Conn intvl: min=6 max=6
    [00:00:12.541,000] <info> app: phone Conn intvl: min=36 max=36
    [00:00:13.070,000] <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 1, procedure: Bonding
    [00:00:13.071,000] <info> app: PM secured connection
    [00:00:13.074,000] <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Bonding data, action: Update
    [00:00:13.076,000] <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update
    [00:00:13.080,000] <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Local database, action: Update
    [00:00:14.059,000] <info> app: Current Time Service not found on server.

    Its interesting the "PM security params requested"  comes twice but extremely close together in time.  This message is produced when PM_EVT_CONN_SEC_PARAMS_REQ is sent.

Related