You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To support new use cases such as commissioning, BLE pairing and identification/authentication of NFC enabled IoT endpoints, Mbed OS should support the card emulation mode.
10
+
To support new use cases such as commissioning, BLE pairing and identification/authentication of NFC enabled IoT endpoints, Mbed OS should support the card emulation mode.
11
11
12
12
However the architecture should be future-proofed and should also be extendable to support other NFC modes in the future.
These are mapped against NFC Forum-defined protocols.
116
116
117
-
* T1T is based on ISO/IEC 14443A-3 and commonly known as Topaz (Innovision).
117
+
* T1T is based on ISO/IEC 14443A-3 and commonly known as Topaz (Innovision).
118
118
* T2T is based on ISO/IEC 14443A-3 and commonly known as Mifare Ultralight/NTAG (NXP).
119
119
* T3T is based on JIS X6319-4, also known as Felica (Sony).
120
120
* ISO-DEP is based on ISO/IEC 14443-4 and is the common interface for contactless smartcards. The underlying radio protocol can either be ISO/IEC 14443A or ISO/IEC 14443B.
@@ -261,99 +261,190 @@ The `NFCRemoteTarget` class derives from `NFCTarget` and additionally from `NFCE
261
261
262
262
## NDEF API
263
263
264
-
![ndef_diagram]
265
-
266
264
The NDEF API is constructed with these requirements in mind:
267
265
* Minimizing memory allocation/copies
268
266
* NFC Forum compliance
269
267
* Ease of use
268
+
* Extensibility
270
269
271
-
#### NDEF Message
270
+
###Common objects
272
271
273
-
A NDEF Message is made of multiple NDEF Records which is reflected by the API:
272
+
We will provide multiple helpers to make it easy to create/parse common record types:
273
+
* URI
274
+
* Text
275
+
* Smart Poster
276
+
* MIME data
274
277
278
+
For instance, the `URI`'s class API is as follows:
275
279
```cpp
276
-
boolparse(const uint8_t* buffer, size_t sz)
277
-
size_t count()
278
-
NDEFRecord operator[](size_t n)
280
+
uri_prefix_turi_prefix() const
281
+
void set_uri_prefix(uri_prefix_t prefix)
282
+
283
+
bool get_uri(char* uri, size_t max_sz) const
284
+
size_t uri_size() const
285
+
void set_uri(const char* uri)
286
+
287
+
bool get_full_uri(char* uri, size_t max_sz) const
288
+
size_t full_uri_size() const
289
+
void set_full_uri(const char* uri)
279
290
```
280
291
281
-
The message can be mapped with a byte array and individual records are decoded/populated on the fly.
292
+
**Note:** These types can be replaced by user defined ones if parsing and serialization logic is provided.
293
+
294
+
### Parsing
282
295
283
-
#### NDEF Message builder
296
+
#### ndef::MessageParser
284
297
285
-
We're using a builder pattern to encode an NDEF message over a byte array.
298
+
![ndef_message_parser_diagram]
299
+
300
+
Messages incoming from the peer are parsed by a `MessageParser` which produce
301
+
`Record` instances to its client. The parsing operation is event-driven: a
302
+
message parser client registers a delegate inside the message parser. This delegate
303
+
gets notified whenever an interesting event happens during the parsing.
The class `MessageBuilder` is used to map a record into an NDEF message. It
440
+
includes a data buffer that contains the _raw_ message. Client code use the
441
+
functions `append_record` to append a new record into the message being built.
442
+
443
+
![ndef_message_builder_diagram]
444
+
445
+
For convenience, serialization functions for common types are provided as well as
446
+
a specialized `MessageBuilder` named `SimpleMessageBuilder` that exposes them
447
+
in an object oriented fashion.
357
448
358
449
## HAL APIs
359
450
@@ -363,7 +454,7 @@ The one HAL API that will have to be implemented by vendors to make use of the `
363
454
364
455
From the upper layer's point of view, the EEPROM is a byte array that can be read from/written to. Long operations (reads, writes, erasures) must happen asynchronously. Booleans indicate whether a particular operation was succesful. Encoding is handled by the upper layer.
365
456
366
-
Address 0 means the start of the NDEF buffer (not necessarily at address 0 in the EEPROM).
457
+
Address 0 means the start of the NDEF buffer (not necessarily at address 0 in the EEPROM).
367
458
368
459
When a buffer is passed to the backend, the reference remains valid till the corresponding event is called.
The following events must be called to signal completion of long operations:
@@ -415,10 +506,14 @@ GreenTea tests will be provided to partners to ensure compliance with the NFC EE
415
506
* Event Queue
416
507
417
508
There are currently at least four event queues (Plaftorm, BLE, USB, IP) in mbed OS and NFC will also require an event queing mechanism. We should aim at reusing one of these existing queues with the long term goal of unifying these code bases.
0 commit comments