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

Connecting with nfc_ble_pair_lib

I am using the ble_app_hrs_nfc_pairing example (sdk 14.0.0) on my NRF52840 with the s140 soft device. I am able to bond with my phone (Android 8.0.0 Oreo) by tapping the sensor, and BLE_GAP_EVT_CONNECTED and BLE_GAP_EVT_CONN_SEC_UPDATE handlers are called on the device. However nRF Connect on the phone says bonded, not connected. I am thus unable to manipulate services from the app. Because the nfc library causes advertising to halt after the bonding, I am unable to manually connect. My only work around has been to reset the device to get advertising started again and then connect from the phone.

Is this a problem with the library or my phone?

  • @rdecker: Are you sure it's the nfc library caused the advertising to stop ? I can see from the code that when BLE_GAP_EVT_DISCONNECTED occurs, we will call ble_advertising_start(). That what I also experience when testing with my phone. The device advertised after bonded.

  • Testing the example with SDK14.1.0, it does infact work correctly. However I am unable to get it to work in my personal project even after matching all relevant lines and config options.

    Using NFC_PAIRING_MODE_LESC_... gives me a "app: Authorization failed with code: 139!". Switching to NFC_PAIRING_MODE_... (no lesc) bonds but then creates the above problem where the board believes the connection is established but the phone does not.

    Any guidance would be appreciated. Perhaps I should make a new question for the authentication issue when using LESC modes in my code.

  • Have you also update the NFC library ?

    Code 139 = 0x8B = BLE_GAP_SEC_STATUS_DHKEY_FAILURE

    Could be something wrong with the OOB data to generate the key

    Which phone did you use to test with ? I also experience some issues with Samsung S8 (not same error code though), when the Nexus phones worked fine.

    "the board believes the connection is established but the phone does not" This will result the board disconnect because of timeout , after that can you connect and bond ?

  • So after copying over the examples main.c and sdk_config.h into my project and still having issues I figured out that the problem was in my build system (I'm using cmake and gcc). After a diffing I found that I compiled uECC.c but the example did not. For some reason including uECC.c created the DHKEY_FAILURE. Removing it from the sources list has fixed my issue. Just to be sure I added it back in and the DH failures returned.

    Interestingly enough I remember setting up micro-ecc to fix a unresolved symbol error in the past. Perhaps it was required in 14.0.0 but is now unnecessary and in fact detrimental to 14.1.0. Very strange.

    Hopefully if someone else stumbles upon this they won't spend the hours I did on it.

  • I'm not sure why you need to include uecc.c file. As I can see in our example (both SDK v14 and v14.1) we only include the .lib file instead of the uecc.c source file. Note that there is a change in NFC BLE Pairing Library in SDK v14.1 that you need to modify if you porting your application from v14.0 to v14.1. Look at the Changes section.

Related