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 !

Parents
  • 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

Reply
  • 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

Children
No Data
Related