From 47e90cf1b1019296ce6811080105d5f0273ea12a Mon Sep 17 00:00:00 2001 From: Alekos Filini Date: Tue, 12 Mar 2024 10:08:30 +0100 Subject: [PATCH] Update SDK readme --- sdk/README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sdk/README.md b/sdk/README.md index c848178..73b6687 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -8,13 +8,9 @@ The SDK is divided into a `CardManager`, which is not exposed to the final user The user only needs to implement the code required to receive and send raw (byte arrays) messages from/to the NFC card. This could be done in many different ways depending on the specific platform: in this repo an example implementation uses libnfc, which should work on all common desktop platforms. -Afterwards, the user will need to spawn a thread* which repeatedly calls `sdk.wait()` in a loop: this method will return an `Option`, which tells the user whether there's a command to send via NFC: The `Transceive` variant means that the user should send the message and expect a reply from the card (which he should then give to the sdk with `sdk.push_incoming(data)`). The `Send` variant means that the user should just send the data via NFC. +Afterwards, the user will need to spawn a task which repeatedly calls `sdk.poll()` in a loop: this method will return an `NfcOut` struct, which is composed of a byte array message and a numeric message id. The message should be sent via NFC and then the reply provided back to the library with `sdk.incoming_data()`. -Calling `wait()` repeatedly will drive the internal state machine and drive the communication with the NFC card, so it's very important to always keep doing that. - -`PortalSdk` exposes methods to send commands to the card, like `get_status()` to get the device status, `generate_mnemonic(num_words)` to make the device generate a new mnemonic, etc. Since the `PortalSdk` structure is thread-safe, these calls could be made from any other thread, while the main loop keeps calling `wait()`. - -\* Note that it's not actually strictly required to spawn a new thread, although it makes the code easier to manage. It's technically possible to interleave calls to `wait()` with calls to all the other methods of `PortalSdk` in the same thread. +`PortalSdk` exposes methods to send commands to the card, like `get_status()` to get the device status, `generate_mnemonic(num_words)` to make the device generate a new mnemonic, etc. Since the `PortalSdk` structure is thread-safe, these calls could be made from any other task or thread, while the main task keeps calling `poll()`. ## CLI @@ -22,4 +18,4 @@ This crate also has a binary target that uses `libnfc` to connect to a supported ``` cargo run --features=libnfc --bin=cli -``` \ No newline at end of file +```