Connect BLE via NFC

Hi,all

     I need to connect BLE via NFC,but I do not know which example should i use to start。and i am a new field of NFC ,is there some document about NFC?thank you a lot !!

nRF5_SDK_17.1.0_ddde560

Parents Reply
  • thank you for you nice answer, i used this sample: nRF5_SDK_17.1.0_ddde560\examples\ble_peripheral\experimental\ble_app_hrs_nfc_pairing\pca10040.

    Q1: it seems can bond between nrf52832 and smart phone ,but if i turn off the board,and turn on the board again ,it can not atuo conneted to the smart phone,is some config should i do? or the APP on smart phone should config something?

    Q2:is there any function to test the antenna performance,output some value ,like RSSI? Aim to optimize the antenna  for a better sensing distance

    thank you a lot!!

Children
  • ycp said:
    Q1: it seems can bond between nrf52832 and smart phone ,but if i turn off the board,and turn on the board again ,it can not atuo conneted to the smart phone,is some config should i do? or the APP on smart phone should config something?

    If you have your own android app, then you have the autoConnect parameter in connectGatt() you can set to true

    ycp said:
    Q2:is there any function to test the antenna performance,output some value ,like RSSI? Aim to optimize the antenna  for a better sensing distance

    It's already tuned on the DK. For custom nRF52 boards, see this white paper for NFC antenna tuning. https://infocenter.nordicsemi.com/topic/nwp_026/WP/nwp_026/nWP_026_intro.html

  • Thank you,it is vary useful !,

    I have Q3:if the board boned with a phone ,next time this phone put on the board again ,will it pair again? i wish it can  just connect ,do not pair ,what i should do?

    i read the code below,it seems will generate new Authentication OOB Key again.thank you a lot!

    /**
     * @brief Function for handling NFC events.
     *
     * @details Starts advertising and generates new OOB keys on the NFC_T2T_EVENT_FIELD_ON event.
     *
     * @param[in] p_context    Context for callback execution, not used in this callback implementation.
     * @param[in] event        Event generated by hal NFC lib.
     * @param[in] p_data       Received/transmitted data or NULL, not used in this callback implementation.
     * @param[in] data_length  Size of the received/transmitted packet, not used in this callback implementation.
     */
    static void nfc_callback(void            * p_context,
                             nfc_t2t_event_t   event,
                             uint8_t const   * p_data,
                             size_t            data_length)
    {
        UNUSED_PARAMETER(p_context);
        UNUSED_PARAMETER(p_data);
        UNUSED_PARAMETER(data_length);
    
        ret_code_t         err_code = NRF_SUCCESS;
        nfc_pairing_mode_t pairing_mode;
    
        switch (event)
        {
            case NFC_T2T_EVENT_FIELD_ON:
                NRF_LOG_DEBUG("NFC_EVENT_FIELD_ON");
    
                pairing_mode = nfc_ble_pair_mode_get();
    
                if ((pairing_mode == NFC_PAIRING_MODE_OOB) ||
                    (pairing_mode == NFC_PAIRING_MODE_GENERIC_OOB))
                {
                    // Generate Authentication OOB Key and update NDEF message content.
                    uint8_t length = random_vector_generate(m_oob_auth_key.tk, BLE_GAP_SEC_KEY_LEN);
                    random_vector_log(length);
                    err_code = nfc_tk_group_modifier_update(&m_oob_auth_key);
                    APP_ERROR_CHECK(err_code);
                }
    
                // Start advertising when NFC field is sensed and there is a place for another connection.
                if (m_connections < NRF_SDH_BLE_PERIPHERAL_LINK_COUNT)
                {
                    err_code = ble_advertising_start(m_p_advertising, BLE_ADV_MODE_FAST);
                    if (err_code != NRF_ERROR_INVALID_STATE)
                    {
                        APP_ERROR_CHECK(err_code);
                    }
                }
    
                break;
    
            case NFC_T2T_EVENT_FIELD_OFF:
                NRF_LOG_DEBUG("NFC_EVENT_FIELD_OFF");
                break;
    
            default:
                break;
        }
    }
    

  • Q4:can I use S332 softdevice to run NFC ? Because the project  need ANT+ feature too!

  • Hi!

    ycp said:
    I have Q3:if the board boned with a phone ,next time this phone put on the board again ,will it pair again? i wish it can  just connect ,do not pair ,what i should do?

    You only need to bond once. If you turn off the board, and on again, and connect with the phone, you don't need to pair/bond again.

    ycp said:
    can I use S332 softdevice to run NFC ?

    Yes, that should work.

Related