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

Does BLE Pairing Using NFC support on nRF52840 (pa10056) ? 

I have followed up this example and compiled successfully but the NFC pairing is not working at all. 

I use my smartphone (Google Pixel 2) to touch the NFC antenna and nothing happened on the screen, even in the terminal. 

After that, I went to check whether the hardware of NFC functions works by running the example of the record txt NFC, which is working well.

Moreover, I read the guideline of example and it says "This example requires the following SoftDevice: S132"

So does that mean this functionality doesn't support S140 (nRF52840)? Or are there any necessary steps that should take up? 

I use Keli with SDK 16.0, CMSIS 4.5.0 and Pack 8.27.1 to compile them.

Thanks in advance.

  • Hi

    I think this example should work on the nRF52840 DK as well, and should not be restricted to the S132 SoftDevice. Do you have more than one DK available so you can test it towards the central example instead of a phone? You can also test it against other phones to see if you're able to make it work that way.

    Keep in mind that this is an experimental example, which means it is not guaranteed to work, as we haven't tested it sufficiently to call it a full-fledged example project. I'll try to get a hold of someone that can test this. I don't have an NFC antenna available at the moment, but I'll try to get a hold of someone that does, and get them to test this.

    Best regards,

    Simon

  • Hi Simon,

    Thanks for your reply, I was able to detect the NFC by Android built-in NFC service.

    I think it may be related to the version of Android. The smartphone I took to experiment was the original version, it didn't upgrade to Android 10 from Android 9, so it works after I upgraded to the newest version via Google system update.

    However, I'm now encountering another issue. At the first time, the NFC pairing was successful and be able to be connected through BLE. But when I want to try to connect in second time after disconnected, the terminal always shows the error -133

    This is the log shown the connection at the first time.

    <info> app_timer: RTC: initialized.
    <debug> nrf_ble_lesc: Initialized nrf_crypto.
    <debug> nrf_ble_lesc: Initialized nrf_ble_lesc.
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> app: NFC Connection Handover BLE peripheral device example started.
    <info> BLE_M: Fast advertising.
    <info> BLE_M: Connected.
    <debug> nrf_ble_gatt: Peer on connection 0x0 requested a data length of 27 bytes.
    <debug> nrf_ble_gatt: Updating data length to 27 on connection 0x0.
    <debug> nrf_ble_gatt: Data length updated to 27 on connection 0x0.
    <debug> nrf_ble_gatt: max_rx_octets: 27
    <debug> nrf_ble_gatt: max_tx_octets: 27
    <debug> nrf_ble_gatt: max_rx_time: 328
    <debug> nrf_ble_gatt: max_tx_time: 2120
    <debug> BLE_M: PHY update request.
    <debug> nrf_ble_lesc: BLE_GAP_EVT_LESC_DHKEY_REQUEST
    <info> nrf_ble_lesc: Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: 0
    <info> BLE_M: BLE_GAP_EVT_CONN_SEC_UPDATE
    <info> BLE_M: Security mode: 4
    <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Bonding
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> BLE_M: BLE_GAP_EVT_AUTH_STATUS
    <info> BLE_M: Authorization succeeded!
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Bonding data, action: Update
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Central address resolution, action: Update

    And this is the failed log shown the connection with the same device again.

    <info> BLE_M: Fast advertising.
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
    <info> BLE_M: Connected.
    <debug> nrf_ble_gatt: Peer on connection 0x0 requested a data length of 27 bytes.
    <debug> nrf_ble_gatt: Updating data length to 27 on connection 0x0.
    <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 133
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> BLE_M: BLE_GAP_EVT_AUTH_STATUS
    <info> BLE_M: Authorization failed with code: 133!
    <debug> nrf_ble_gatt: Data length updated to 27 on connection 0x0.
    <debug> nrf_ble_gatt: max_rx_octets: 27
    <debug> nrf_ble_gatt: max_tx_octets: 27
    <debug> nrf_ble_gatt: max_rx_time: 328
    <debug> nrf_ble_gatt: max_tx_time: 2120
    <debug> BLE_M: PHY update request.
    <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 133
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> BLE_M: BLE_GAP_EVT_AUTH_STATUS
    <info> BLE_M: Authorization failed with code: 133!
    <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 133
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> BLE_M: BLE_GAP_EVT_AUTH_STATUS
    <info> BLE_M: Authorization failed with code: 133!
    <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 133
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> BLE_M: BLE_GAP_EVT_AUTH_STATUS
    <info> BLE_M: Authorization failed with code: 133!
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> BLE_M: Disonnected

    I've gone through previous posts and found out that it may be a problem that the Android would delete bond information in every disconnection, while the nRF board would store the bonding data into flash.

    https://devzone.nordicsemi.com/f/nordic-q-a/56739/ble-nfc-pairing-issue

    And yes, it can be connected again after I erased all flash data and download them back.

    So I would like to know if there are any workaround solutions to avoid such this situation? Like I could read a specific address from flash and check if there is bonding data, I could then write it back or erase this particular bonding data at the address?

    Thanks.

  • Hi

    Glad you got the devices to pair! As for the reconnection issue you're seeing, you can try to delete the bonding information on the nRF side upon disconnection (or upon startup, this is up to you). Please check out the pm_peers_delete() function in peer_manager.c. By default, the example is set to delete peers upon the press of a button on the DK, but you can set it to trigger every time the device disconnects for example instead.

    Best regards,

    Simon

  • Hi Simon,

    Thank you so much !  Adding pm_peers_delete() fixes the issue of reconnection, thank you again!

    And as you said, I just check if this function would be called after pressed the button (default as button 0) and realized that it didn't. I'm not sure it's a bug or other factors.

    Besides, I found out that when I connected to the phone successfully. But after around 10 sec, it will pop up a message shown "Could not connect Nordic_NFC_PAIR_REF" at the end of the screen.

    However, there are no errors or warning messages on the terminal, does that indicate both devices still connected? Am I able to send data via Bluetooth in this situation? Just like to confirm with you before implementations.

    Very appreciated your help Slight smile

Related