Skip to content

Commit 212ac48

Browse files
author
Donatien Garnier
committed
Introduce NFCNDEFCapable class
1 parent 5cb43e6 commit 212ac48

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

features/nfc/doc/nfc_design.md

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,25 +188,62 @@ virtual void on_lost();
188188

189189
This is called when this endpoint has been lost and the reference to the shared pointer is about to be released by the controller instance.
190190

191+
#### NFC NDEF Capable
192+
193+
This class is inherited by all endpoints that have the capability of handling NDEF data.
194+
195+
User-facing API:
196+
```cpp
197+
bool is_ndef_supported() const;
198+
199+
void set_ndef_message_parser(ndef::MessageParser* parser) const;
200+
void set_ndef_message_builder(ndef::MessageBuilder* builder) const;
201+
```
202+
203+
The user can select which parser/builder (see below) should be used to handle read/write requests.
204+
205+
API used by descendant classes:
206+
```cpp
207+
void set_ndef_support(bool supported);
208+
209+
ndef::MessageParser* ndef_message_parser();
210+
ndef::MessageBuilder* ndef_message_builder();
211+
```
212+
191213
#### NFC Remote Initiator
192214

193-
This class derives from the base `NFCEndpoint` class.
215+
This class derives from the base `NFCEndpoint` and `NFCNDEFCapable` classes.
194216

195217
```cpp
196218
bool is_ndef_supported();
197-
size_t nfc_tag_type();
198219

199220
void set_ndef_message(const NDEFMessage& message);
200221
void clear_ndef_message();
201222
NDEFMessage get_ndef_message();
202223
```
203224
These methods provide access to the NDEF message that we are exposing to the remote initiator.
204225
226+
227+
```cpp
228+
enum nfc_tag_type_t {
229+
nfc_tag_type_1,
230+
nfc_tag_type_2,
231+
nfc_tag_type_3,
232+
nfc_tag_type_4a,
233+
nfc_tag_type_4b,
234+
nfc_tag_type_5
235+
};
236+
```
237+
238+
```cpp
239+
nfc_tag_type_t nfc_tag_type();
240+
```
241+
205242
Additionally the type of NFC tag (1 to 5) which is being emulated can be recovered.
206243

207244
```cpp
208245
bool is_iso7816_supported();
209-
void add_iso7816_application(const ISO7816App& app);
246+
void add_iso7816_application(ISO7816App* app);
210247
```
211248
212249
If supported by the underlying technology (ISO-DEP), a contactless smartcard can be emulated and ISO7816-4 applications can be registered using this API.
@@ -235,18 +272,22 @@ This is the base class for NFC targets that can be of two types:
235272

236273
Apart from the actual transport (Wired or NFC), the usage is very similar which explains why these methods are shared across these devices types.
237274

275+
This class derives from `NFCNDEFCapable`.
276+
238277
```cpp
239-
void write_ndef_message(const NDEFMessage& message)
240-
void erase_ndef_message()
241-
void read_ndef_message()
278+
void write_ndef_message();
279+
void erase_ndef_message();
280+
void read_ndef_message();
242281
```
243282

283+
Calling these functions will trigger the appropriate NDEF parsing/building process if handlers are registered in the `NFCNDEFCapable` instance.
284+
244285
**Delegate**
245286

246287
```cpp
247-
void on_ndef_message_written(nfc_err_t result)
248-
void on_ndef_message_erased(nfc_err_t result)
249-
void on_ndef_message_read(nfc_err_t result, NDEFMessage* message)
288+
void on_ndef_message_erased(nfc_err_t result);
289+
void on_ndef_message_written(nfc_err_t result);
290+
void on_ndef_message_read(nfc_err_t result);
250291
```
251292
252293
#### NFC EEPROM

0 commit comments

Comments
 (0)