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

How to use ble_nfc_pairing_reference example for secondary connection of already bonded device?

Hi all,

So, I have nRF5_SDK_15.0.0_a53641a, PCA10040, Keil. I have built already this project succesfully.

The first NFC touch and further bonding with my HTC phone was successful. But all secondary touch accompanied by popup window at phone "Yes or No" to connect with my device. And I saw in "nRF Connect" logs that bonding was deleted each time just before this popup window rise.

This issue you can consider as a continuation of the following question https://devzone.nordicsemi.com/f/nordic-q-a/41362/authorization-nfc-ble-pairing-issues .

The answerer of this topic suggested (in the last answer) "You will have to modify the firmware to not do pairing when there is an already paired device". I tryed do that many times with something at events callbacks, but result was negative, because I don't know how to do that exactly. Now I know how to do a repairing with allow_repairing option, but I don't want the deletion of bond before that repairing. In my opinion it is not good. How to do that right? 
Maybe there is some example with exactly what I need? Please, help me.

Best regards.

  • Hi,

    The example in the SDK is a NFC pairing example and it does not provide any API/functionality for connecting/disconnecting BLE peripherals. My suggestion would be to use a button, etc. to put the device into pairing mode. Once the device is paired, you can disable the NFC pairing functionality until the button is pushed again, for instance to pair another device. The NFC tag can then be used to start advertising whenever a NFC field is detected, etc. The phone OSes normally does not support BLE devices natively (except HID devices), and you would then need a 3rd party app to initiate the connection to a peripheral. When the devices are bonded, you can configure your app to autoconnect the bonded device once it starts advertising.

    Best regards,
    Jørgen

  • Thanks,

    I understood your answer, but maybe you not .... So, again, you wrote above "Once the device is paired, you can disable the NFC pairing functionality until..."

    My question is simple - how I can disable the NFC pairing functionality when this functionality was already initiated one time earlier? Now I know only one method - reset. Is there another method? Thank you in advance.

    Sorry, maybe my first question was not very detailed.

  • Calling nfc_t2t_emulation_stop() should be sufficient, but this will also shut down NFC tag and you won't get any events if fields are detected. You could face issues with implementing a second IRQ handler for the approach I suggested above. Another solution is to change the payload of the NFC, using function nfc_t2t_payload_set(), for instance to open your application. You would then still get the FIELD_ON/OFF events in nfc_callback in nfc_ble_pair_lib.c, allowing you to start advertising, etc.

Related