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

Integrating nfc_callback() for ...EVENT_FIELD_ON / OFF in to wake_on_nfc example

Environment:

Nordic SDK 15.2.0

Eval kit nRF52840-DK / PCA10056

SES debugger on Windows 10

I was trying to integrate nfc_callback() for ...EVENT_FIELD_ON  / OFF from nfc_launchapp_record example in to wake_on_nfc example.

But ...EVENT_FIELD_ON  / OFF events are not recognized in the new wake_on_nfc -> nfc_callback().

Any quick hints / solutions Please !?

Thanks !

  • Dear customer, 

    Due to limited staff during the holiday period, we unfortunately can't handle your case before we get back to the normal staff by the first week of January 2019. We are sorry indeed for the delay. We wish you a great holiday and a Happy New Year 2019. 

    Best Regards, 

    Nordic Tech Support Team  

  • Hi,

    Can you post your code/project showing how you integrated this? 

    Best regards,
    Jørgen

  • Hi Jorgen

    Here is the code *added* to wake_on_nfc_pca10056 example

    static void nfc_callback(void * p_context, nfc_t2t_event_t event, const uint8_t * p_data, size_t data_length)
    {
        (void)p_context;
    
        switch (event)
        {
            case NFC_T2T_EVENT_FIELD_ON:
                nrf_delay_ms(2000UL);
                bsp_board_led_on(BSP_BOARD_LED_2);
                NRF_LOG_DEBUG("NFC_T2T_EVENT_FIELD_ON \n");
                break;
    
            case NFC_T2T_EVENT_FIELD_OFF:
                NRF_LOG_DEBUG("NFC_T2T_EVENT_FIELD_OFF \n");
                break;
    
            default:
                break;
        }
    }

    static void utils_setup(void)
    {
        ret_code_t err_code;
    
    ...
    ...
    ...
    
        // Schedule a timeout event every 500 miliseconds
        err_code = app_timer_start(m_tick_timer, APP_TICK_EVENT_INTERVAL, NULL);
        APP_ERROR_CHECK(err_code);
    
        /* Set up NFC */
        err_code = nfc_t2t_setup(nfc_callback, NULL);
        APP_ERROR_CHECK(err_code);
    
        NRF_LOG_INFO("NFC Tag example started.");
    
    }
    

    int main(void)
    {
    
    ...
    ...
    
    
        /* Start sensing NFC field */
        err_code = nfc_t2t_emulation_start();
        APP_ERROR_CHECK(err_code);
    
        while (true)
        {
    ...
    ...
    ...
        }
    }
    

    I am sorry if you think it is simple question, but I am new to Nordic.

    Thanks

    -Pramod

  • Did you not set any payload before calling nfc_t2t_emulation_start? I tried the code changes that you proposed, but I get an error (NRF_ERROR_INVALID_STATE) when calling nfc_t2t_emulation_start() without first calling nfc_t2t_payload_set(). If I include that part from the launch_app example, I'm able to detect the field.

  • Thanks !

    It is working with adding nfc_t2t_payload_set().

    But nfc_t2t_payload_set() is for NDEF message payload ! Here in this example .. I am not using any NDEF message, but only nfc field detection.

    I don't understand why need to set aside m_ndef_msg_buf[]  !??

Related