How to run into function tnep_svc_one_selected()?

As the title, in the project "ncs\v3.2.1\nrf\samples\nfc\tnep_tag", how to runt into  function tnep_svc_one_selected()?

I use the NFC tools, Send the hex data, want to select the servive, what hex data must be send? Is there a complete example or debugging method?

Parents
  • Hi

    I'm sorry, but I don't understand what you mean here I'm afraid. Are you using a phone, Android or similar running an NFC debugger app of sorts or a dedicated NFC debugger device? I think the NFC TNEP polling device. 

    Is the issue here that you are not able to switch back to the svc_one service with a button press? If so, I think that is because the sample only lets you switch from 1 to 2 and not back with the same button press, so you need to change this in the source code.

    Or is the issue that you aren't able to change/poll the service from the phone? If so, I think you should look at how the TNEP poller sample does this and implement something like that on the NFC tools on your end.

    Best regards,

    Simon

  • It's like this: I plan to use TNEP for data exchange. What I imagine is being able to use tool software, like NFC TOOL, similar to a serial port debugging assistant, to send and receive hexadecimal data for manual debugging.

  • Hello,

    Sorry for the late reply. Simon is currently out of office, so I will look into your ticket. 

    So the question is "how to run the tnep_svc_one_selected()"? 

    Do you see tnep_svc_two_selected() being called?

    Currently, the button_pressed() callback is being used to set the svc_two_rec, and enabling it using nfc_ndef_msg_record_add() and nfc_tnep_tag_tx_msg_app_data(). So if you see the record being switched to svc_two_rec, then this is working. Try adding something like this:

    static void button_pressed(uint32_t button_state, uint32_t has_changed)
    {
    	int err;
    	uint32_t button = button_state & has_changed;
    	const char svc_two_msg[] = "Service e  = 2.71828182845904523536";
    
    	if (button & DK_BTN1_MSK) {
    		NFC_TNEP_TAG_APP_MSG_DEF(app_msg, 1);
    		NFC_NDEF_TEXT_RECORD_DESC_DEF(svc_two_rec, UTF_8, en_code,
    					      sizeof(en_code), svc_two_msg,
    					      strlen(svc_two_msg));
    
    		err = nfc_ndef_msg_record_add(&NFC_NDEF_MSG(app_msg),
    					      &NFC_NDEF_TEXT_RECORD_DESC(svc_two_rec));
    
    		err = nfc_tnep_tag_tx_msg_app_data(&NFC_NDEF_MSG(app_msg),
    						   NFC_TNEP_STATUS_SUCCESS);
    		if (err == -EACCES) {
    			printk("Service is not in selected state. App data cannot be set\n");
    		} else {
    			printk("Service app data set err: %d\n", err);
    		}
    	}
    	else if (button & DK_BTN2_MSK) {
    	    NFC_TNEP_TAG_APP_MSG_DEF(app_msg, 1);
    		NFC_NDEF_TEXT_RECORD_DESC_DEF(svc_one_rec, UTF_8, en_code,
    					      sizeof(en_code), svc_one_msg,
    					      strlen(svc_one_msg));
    
    		err = nfc_ndef_msg_record_add(&NFC_NDEF_MSG(app_msg),
    					      &NFC_NDEF_TEXT_RECORD_DESC(svc_one_rec));
    
    		err = nfc_tnep_tag_tx_msg_app_data(&NFC_NDEF_MSG(app_msg),
    						   NFC_TNEP_STATUS_SUCCESS);
    		if (err == -EACCES) {
    			printk("Service is not in selected state. App data cannot be set\n");
    		} else {
    			printk("Service app data set err: %d\n", err);
    		}
    	}
    }

    Best regards,

    Edvin

  • What I'm thinking now is if there is a simple way to implement TNEP interaction, allowing data transmission and reception to be as easy as using a serial port. Right now, I'm using the NFC TOOL mobile app for debugging. This app supports NFCA and ISODEP and does not allow manual command sending. When the code executes tnep_svc_one_selected(), there is no tnep_svc_two_selected() in the code because I only used one service. You don't need two sets of services for data transmission and reception, right? The demo program is meant to demonstrate service switching, correct? I just need to implement TNEP data transmission and reception.

  • Is there a bug in t4t? I send 00D600000411223344, program jump to case

    NFC_T4T_EVENT_NDEF_UPDATED,

    the lenth is 4386 ,the  hex 1122 ,dec is 4386. the lenth is not 4?

    the lenth in callback, is 4386

        err = nfc_t4t_setup(nfc_callback, NULL);
        if (err) {
            LOG_ERR("NFC T4T setup err: %d", err);
            return;
        }
    static void nfc_callback(void *context, nfc_t4t_event_t event,
                 const uint8_t *data, size_t data_length, uint32_t flags)

Reply
  • Is there a bug in t4t? I send 00D600000411223344, program jump to case

    NFC_T4T_EVENT_NDEF_UPDATED,

    the lenth is 4386 ,the  hex 1122 ,dec is 4386. the lenth is not 4?

    the lenth in callback, is 4386

        err = nfc_t4t_setup(nfc_callback, NULL);
        if (err) {
            LOG_ERR("NFC T4T setup err: %d", err);
            return;
        }
    static void nfc_callback(void *context, nfc_t4t_event_t event,
                 const uint8_t *data, size_t data_length, uint32_t flags)

Children
Related