/** * @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] */ NfcRetval ret_val; err_code = NRF_LOG_INIT(); APP_ERROR_CHECK(err_code); /* Configure LED-pins as outputs */ LEDS_CONFIGURE(BSP_LED_0_MASK); LEDS_OFF(BSP_LED_0_MASK); /* Set up NFC */ ret_val = nfcSetup(nfc_callback, NULL); if (ret_val != NFC_RETVAL_OK) { APP_ERROR_CHECK((uint32_t) ret_val); } /** @snippet [NFC Launch App usage_2] */ /* Provide information about available buffer size to encoding function. */ len = sizeof(ndef_msg_buf); /* Encode launchapp message into buffer */ err_code = nfc_launchapp_msg_encode(android_package_name, sizeof(android_package_name), windows_application_id, sizeof(windows_application_id), ndef_msg_buf, &len); APP_ERROR_CHECK(err_code); /** @snippet [NFC Launch App usage_2] */ /* Set created message as the NFC payload */ ret_val = nfcSetPayload((char *) ndef_msg_buf, len); if (ret_val != NFC_RETVAL_OK) { APP_ERROR_CHECK((uint32_t) ret_val); } /* Start sensing NFC field */ ret_val = nfcStartEmulation(); if (ret_val != NFC_RETVAL_OK) { APP_ERROR_CHECK((uint32_t) ret_val); } while (1) { } }
/** * @brief Function for application main entry. */ int main(void) { NfcRetval ret_val; uint32_t len = sizeof(ndef_msg_buf); uint32_t err_code; err_code = NRF_LOG_INIT(); APP_ERROR_CHECK(err_code); /* Configure LED-pins as outputs */ LEDS_CONFIGURE(BSP_LED_0_MASK); LEDS_OFF(BSP_LED_0_MASK); /* Set up NFC */ ret_val = nfcSetup(nfc_callback, NULL); APP_ERROR_CHECK(ret_val); /* Encode welcome message */ welcome_msg_encode(ndef_msg_buf, &len); /* Set created message as the NFC payload */ ret_val = nfcSetPayload( (char*)ndef_msg_buf, len); APP_ERROR_CHECK(ret_val); /* Start sensing NFC field */ ret_val = nfcStartEmulation(); APP_ERROR_CHECK(ret_val); while(1) { if (!NFC_NEED_MCU_RUN_STATE()) { __WFE(); } } }