Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TNEP: Poller Device + new record types #559

Open
markus-becker-tridonic-com opened this issue Apr 22, 2020 · 17 comments
Open

Support TNEP: Poller Device + new record types #559

markus-becker-tridonic-com opened this issue Apr 22, 2020 · 17 comments

Comments

@markus-becker-tridonic-com

From https://nfc-forum.org/product/nfc-forum-tag-ndef-exchange-protocol-tnep-candidate-specification-1-0/:

The TNEP 1.0 Technical Specification supports the bi-directional exchange of NDEF messages based on the communication protocol used by the NFC Forum Tag devices of Type 2, 3, 4 and 5. The new TNEP protocol offers a simple protocol for NFC IoT devices to exchange data between an NFC enabled phone and the IoT Device. For example, this protocol can be used to configure and read smart meter devices, to control the thermostatic radiator valve or to configure the lightning device in your smart home.

Would be nice to support this with web-nfc and/or a library on top of web-nfc.

Devices based on Nordic chips implement TNEP tag-wise:
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/nfc/tnep/tnep.html

@kenchris
Copy link
Contributor

Is this a replacement for SNEP which is being deprecated in Android?

NFC Simple Exchange Protocol

The SNEP is a simple protocol for doing peer-to-peer (P2P) NDEF transfers. It is not supported by CoreNFC (iOS) and it is being deprecated on Android (where is branded Android Beam) due to security issues).

@markus-becker-tridonic-com
Copy link
Author

markus-becker-tridonic-com commented Apr 22, 2020

@zolkis
Copy link
Contributor

zolkis commented Apr 22, 2020

@kenchris
Copy link
Contributor

https://www.businesswire.com/news/home/20190612005060/en/NFC-Forum-Enhances-Connectivity-IoT-Devices-New

I guess we need some native (Android etc) support before we can consider supporting this?

@zolkis
Copy link
Contributor

zolkis commented Apr 22, 2020

We have not exposed SNEP directly, so I wonder do we have to expose TNEP directly, or can it be encapsulated? What TNEP specific interactions or options need to be exposed to web pages?

And yes, a prerequisite is Android support for this.

@markus-becker-tridonic-com
Copy link
Author

markus-becker-tridonic-com commented Apr 22, 2020

https://www.businesswire.com/news/home/20190612005060/en/NFC-Forum-Enhances-Connectivity-IoT-Devices-New

I guess we need some native (Android etc) support before we can consider supporting this?

Isn't it layered on top of NDEF without the need of P2P? According to the stack it seems below NDEF.

The Nordic library https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/subsys/nfc/tnep/tag.c seems to be layered on top of NDEF.

@kenchris
Copy link
Contributor

kenchris commented Apr 22, 2020

From my quick look at this, this looks like an official HCE (host card emulation) API, so it will probably need something like that. I think it is great with an official HCE API but it requires Android moving to this new API or us to emulate it ontop of what is already there.

This probably requires a lot of research

Update: One part of it TNEP Tag Device act similar to a NDEF version of HCE, where as TNEP Polling Device is more similar to how an active device (say Android phone) works today.

There are a few extra records that we will need to support.

@kenchris
Copy link
Contributor

kenchris commented Apr 22, 2020

New records to support: https://nfc-forum.org/our-work/specification-releases/specifications/nfc-forum-assigned-numbers-register/

image

@beaufortfrancois
Copy link
Collaborator

What is the platform support of those records?

@kenchris
Copy link
Contributor

kenchris commented Apr 22, 2020

I don't think you need any platform support for those as long as you can write well-known records, like smart poster without native support - can we do that?

This here basically shows what they contain in the payload:

image

You can create these record on Android:

image

Just choose Well known and manually construct the payload

@kenchris
Copy link
Contributor

As far as I understand - only Tag Type 2, 3, 4, 5 have been updated to support TNEP:

image

I assume this means that any TNEP Polling Device can only read these tag types (not non-standard like Mifare, or NFC Forum Type 1) and Android HCE (which emulates Type 4)

@kenchris
Copy link
Contributor

kenchris commented Apr 22, 2020

From reading source code:

#define NFC_TNEP_VERSION 0x10
enum nfc_tnep_comm_mode {
	/** Single response communication mode */
	NFC_TNEP_COMM_MODE_SINGLE_RESPONSE,
	/** Service specific communication mode */
	NFC_TNEP_COMM_MODE_SERVICE_SPECYFIC = 0xFE
};
/** Maximum Service Waiting Time. */
#define NFC_TNEP_TAG_MAX_WAIT_TIME 63
/** Maximum Waiting Time extension. */
#define NFC_TNEP_TAG_MAX_N_WAIT_TIME 15
enum nfc_tnep_status_value {
	/** Success */
	NFC_TNEP_STATUS_SUCCESS,
	/** TNEP protocol error */
	NFC_TNEP_STATUS_PROTOCOL_ERROR,
	/** First service error code. */
	NFC_TNEP_STATUS_SERVICE_ERROR_BEGIN = 0x80,
	/** Last service error code. */
	NFC_TNEP_STATUS_SERVICE_ERROR_END = 0xFE,
};

Service Parameters Record "Tp" payload

byte: version (0x10)
byte: uri length in bytes
uri length bytes: uri
byte: communication_mode (0x01 single response, 0xFE service specific)
byte: min_time (0...63 - converted to time units using protocol specified formula)
byte: max_time_ext (0...15 repetitions)
2 bytes (Big Endian): max_size in bytes

TNEP status "Te" payload

byte: status (0x01 success, 0x02 protocol error, 0x80...0xFE service specific errors)

Service Select "Ts" payload

byte: uri length in bytes
uri length bytes: uri

@kenchris
Copy link
Contributor

It also seems like we could implement the TNEP Tag Device API on top of Android HCE (Host Card Emulation, Type 4 Tag emulation + ISO-DEP / APDU). We considered this already as a replacement for SNEP (NDEF push).

It is exactly how it is accomplished on the Nordic devices, if you check the Tag Device demo:

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.2.0%2Fgroup__nfc__t4t__lib.html

@kenchris kenchris changed the title Support TNEP Support TNEP: Poller Device + new record types Apr 22, 2020
@kenchris
Copy link
Contributor

Split the Tag Device part out into #563

@markus-becker-tridonic-com
Copy link
Author

Would it be possible to test TNEP with WebNFC right now using external type records or would one have to wait until Tp, Te and Ts have been added to the specification and implementation?

@kenchris
Copy link
Contributor

@markus-becker-tridonic-com you would have to wait until that is added yes.

@kenchris
Copy link
Contributor

Did some exploration here: #567

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants