static void nfc_init(void) { ret_code_t err_code; uint32_t len = sizeof(m_ndef_msg_buf); /* Set up NFC */ err_code = nfc_t2t_setup(nfc_callback, NULL); APP_ERROR_CHECK(err_code); /* Provide information about available buffer size to encoding function */ /* Encode URI message into buffer */ err_code = nfc_uri_msg_encode(NFC_URI_HTTP_WWW, m_url, sizeof(m_url), m_ndef_msg_buf, &len); APP_ERROR_CHECK(err_code); /* Set created message as the NFC payload */ err_code = nfc_t2t_payload_set(m_ndef_msg_buf, len); APP_ERROR_CHECK(err_code); /* Start sensing NFC field */ err_code = nfc_t2t_emulation_start(); APP_ERROR_CHECK(err_code); }
static void nfc_init(bool erase_bonds) { uint32_t err_code; /* Start NFC */ err_code = nfc_t2t_setup(nfc_callback, NULL); APP_ERROR_CHECK(err_code); /* Check if any bond exists (expect just 1) */ if (pm_peer_count()) { bond_present = true; } /* Set up the NFC tag data */ if (!bond_present || erase_bonds) { nfc_pairing_data_set(); } else { nfc_launchapp_data_set(); } err_code = nfc_t2t_emulation_start(); APP_ERROR_CHECK(err_code); return; }
/** * @brief Function for application main entry. */ int main(void) { /** @snippet [NFC Launch App usage_1] */ uint32_t len; uint32_t err_code; /** @snippet [NFC Launch App usage_1] */ err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); /* Configure LED-pins as outputs */ bsp_board_leds_init(); /* Set up NFC */ err_code = nfc_t2t_setup(nfc_callback, NULL); APP_ERROR_CHECK(err_code); /** @snippet [NFC Launch App usage_2] */ /* Provide information about available buffer size to encoding function. */ len = sizeof(m_ndef_msg_buf); /* Encode launchapp message into buffer */ err_code = nfc_launchapp_msg_encode(m_android_package_name, sizeof(m_android_package_name), m_windows_application_id, sizeof(m_windows_application_id), m_ndef_msg_buf, &len); APP_ERROR_CHECK(err_code); /** @snippet [NFC Launch App usage_2] */ /* Set created message as the NFC payload */ err_code = nfc_t2t_payload_set(m_ndef_msg_buf, len); APP_ERROR_CHECK(err_code); /* Start sensing NFC field */ err_code = nfc_t2t_emulation_start(); APP_ERROR_CHECK(err_code); while (1) { NRF_LOG_FLUSH(); } }