Skip to content

Commit 1074afb

Browse files
author
Donatien Garnier
committed
Update based on few tweaks to the API
1 parent c71b66d commit 1074afb

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

docs/design-documents/nfc/nfc_design.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ The `NFCController` class is the entrypoint into NFC for the user.
160160

161161
When NCI integration is complete (phase 2), this class will be able to drive a `NCIDriver` instance. For now, the one controller we support is the PN512, which implements the `NFCControllerDriver` class. This class is specific to the current MicroNFC release.
162162

163+
```cpp
164+
NFCController(NFCControllerDriver *driver, events::EventQueue *queue, const Span<uint8_t> &ndef_buffer);
165+
```
166+
167+
The user instantiates the `NFCController` class using a driver, an event queue used for asynchronous operations and a scratch buffer used for NDEF processing.
168+
163169
It offers the following methods:
164170
165171
```cpp
@@ -314,8 +320,6 @@ The class is constructed using a scratch buffer which is used to encode and/or d
314320
315321
```cpp
316322
bool is_ndef_supported() const;
317-
318-
void set_ndef_delegate(Delegate* delegate);
319323
```
320324

321325
API used by descendant classes:
@@ -326,18 +330,23 @@ void build_ndef_message(ac_buffer_builder_t& buffer_builder);
326330
ndef_msg_t* ndef_message();
327331
```
328332
333+
API implemented by descendant classes:
334+
```cpp
335+
virtual NFCNDEFCapable::Delegate* ndef_capable_delegate();
336+
```
337+
329338
**Delegate**
330339

331340
The instance receives requests to encode and decode NDEF messages, and the user can choose how to handle them using the relevant builders and parsers.
332341

333342
```cpp
334-
void parse_ndef_message(const uint8_t* buffer, size_t size);
343+
void parse_ndef_message(const Span<const uint8_t> &buffer);
335344
```
336345
337346
The user receives the encoded NDEF message for processing.
338347
339348
```cpp
340-
size_t build_ndef_message(uint8_t* buffer, size_t capacity);
349+
size_t build_ndef_message(const Span<uint8_t> &buffer);
341350
```
342351

343352
The user can encode a NDEF message in the buffer provided and return its size (or 0).
@@ -363,11 +372,11 @@ nfc_tag_type_t nfc_tag_type();
363372

364373
Additionally, the user can recover the type of NFC tag (1 to 5) being emulated. Type 4 is implemented on either one of two technologies; therefore, this enum both includes type 4a and type 4b to identify the underlying technology.
365374

366-
*Note: This is initially out of scope for the initial release*
375+
*Note: ISO7816 is only used internally for the initial release*
367376

368377
```cpp
369378
bool is_iso7816_supported();
370-
void add_iso7816_application(ISO7816App* app);
379+
void add_iso7816_application(nfc_tech_iso7816_app_t *application);
371380
```
372381
373382
If the underlying technology supports it (ISO-DEP), the user can emulate a contactless smartcard and register ISO7816-4 applications using this API.
@@ -409,7 +418,7 @@ The `NFCEEPROM` class derives from `NFCTarget` and shares the same API. The user
409418
410419
#### NFC remote target
411420
412-
*Note: This is initially out of scope for the initial release*
421+
*Note: This is out of scope for the initial release*
413422
414423
The `NFCRemoteTarget` class derives from `NFCTarget` and additionally from `NFCRemoteEndpoint`.
415424
@@ -593,7 +602,7 @@ The `set_size()` command is called to change the size of the NDEF buffer (within
593602
```cpp
594603
void reset();
595604
size_t get_max_size();
596-
void start_session();
605+
void start_session(bool force = true);
597606
void end_session();
598607
void read_bytes(uint32_t address, size_t count);
599608
void write_bytes(uint32_t address, const uint8_t* bytes, size_t count);
418 Bytes
Loading

docs/design-documents/nfc/uml_diagram_endpoints.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
abstract class NFCNDEFCapable {
44
+{abstract} bool is_ndef_supported() const
5-
+void set_ndef_delegate(Delegate* parser)
65

76
#void parse_ndef_message(const ac_buffer_t& buffer)
87
#void build_ndef_message(ac_buffer_builder_t& buffer_builder)
98
#ndef_msg_t* ndef_message()
9+
#{abstract} NFCNDEFCapable::Delegate* ndef_capable_delegate()
1010
}
1111

1212
abstract class NFCNDEFCapable::Delegate {
13-
+{abstract} void parse_ndef_message(const uint8_t* buffer, size_t size)
14-
+{abstract} size_t build_ndef_message(uint8_t* buffer, size_t capacity)
13+
+{abstract} void parse_ndef_message(const Span<const uint8_t> &buffer)
14+
+{abstract} size_t build_ndef_message(const Span<uint8_t> &buffer)
1515
}
1616

1717
abstract class NFCRemoteEndpoint {
@@ -39,6 +39,9 @@ abstract class NFCTarget::Delegate {
3939
+{abstract} void on_ndef_message_read(nfc_err_t result)
4040
}
4141

42+
NFCNDEFCapable <-- NFCTarget
43+
NFCNDEFCapable::Delegate <-- NFCTarget::Delegate
44+
4245
class NFCEEPROM {
4346
+nfc_err_t initialize()
4447
+void set_delegate(NFCEEPROM::Delegate* delegate)
@@ -54,14 +57,14 @@ abstract class NFCEEPROMDriver {
5457

5558
+{abstract} void reset()
5659
+{abstract} size_t get_max_size()
57-
+{abstract} void start_session()
60+
+{abstract} void start_session(bool force = true)
5861
+{abstract} void end_session()
5962
+{abstract} void read_bytes(uint32_t address, size_t count)
6063
+{abstract} void write_bytes(uint32_t address, const uint8_t* bytes, size_t count)
6164
+{abstract} void write_size(size_t count)
6265
+{abstract} void read_size()
6366
+{abstract} void erase_bytes(uint32_t address, size_t size)
64-
#Delegate *delegate()
67+
#NFCEEPROMDriver::Delegate *delegate()
6568
#events::EventQueue *event_queue()
6669
}
6770

@@ -75,7 +78,6 @@ abstract class NFCEEPROMDriver::Delegate {
7578
+{abstract} void on_bytes_erased(size_t count)
7679
}
7780

78-
NFCNDEFCapable <-- NFCTarget
7981
NFCTarget <-- NFCEEPROM
8082
NFCTarget::Delegate <-- NFCEEPROM::Delegate
8183
NFCEEPROM o-- NFCEEPROM::Delegate
@@ -84,10 +86,10 @@ NFCEEPROMDriver o-- NFCEEPROMDriver::Delegate
8486
NFCEEPROMDriver::Delegate <-- NFCEEPROM
8587

8688
class NFCRemoteInitiator {
87-
+void set_remote_initiator_delegate(NFCRemoteInitiator::Delegate* delegate)
89+
+void set_delegate(NFCRemoteInitiator::Delegate* delegate)
8890

8991
+{abstract}bool is_iso7816_supported() const
90-
+{abstract}void add_iso7816_application(ISO7816App* app)
92+
+{abstract}void add_iso7816_application(nfc_tech_iso7816_app_t *application)
9193

9294
+{abstract} nfc_tag_type_t nfc_tag_type()
9395
+{abstract} bool is_ndef_supported()

0 commit comments

Comments
 (0)