cryptnox-sdk-arduino 1.0.0
Arduino library for Cryptnox Hardware Wallet
Loading...
Searching...
No Matches
Connect.ino
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: LGPL-3.0-or-later
3 * Copyright (c) 2026 Cryptnox SA
4 */
5
27#include <CryptnoxWallet.h>
28#include <SPI.h>
29
31#define PN532_SS_PIN (10U)
32
35
38
41
44
47
56void setup() {
57 serialAdapter.begin(115200);
58 delay(1000); /* Arduino R4: wait for Serial */
59 SPI.begin();
60
61 if (!wallet.begin()) {
62 serialAdapter.println(F("PN532 init failed"));
63 while (1);
64 }
65
66 /* Concrete proof the PN532 is up: prints IC chip, firmware version
67 * and supported NFC features (MIFARE / ISO-DEP / FeliCa). */
68 nfc.printFirmwareVersion();
69}
70
88void loop() {
89 CW_SecureSession session;
90
91 if (wallet.connect(session)) {
92 serialAdapter.println(F("Card connected, secure channel established"));
93
94 CW_CardInfo info;
95 if (wallet.getCardInfo(session, &info)) {
96 serialAdapter.print(F("Owner name : "));
97 serialAdapter.println(info.name);
98 serialAdapter.print(F("Owner email: "));
99 serialAdapter.println(info.email);
100 } else {
101 serialAdapter.println(F("getCardInfo failed (channel error or parse error)"));
102 }
103 } else {
104 serialAdapter.println(F("Card not detected or secure channel failed"));
105 }
106
107 wallet.disconnect(session);
108 delay(1000);
109}
void setup()
Arduino setup function.
CryptnoxWallet wallet(nfc, serialAdapter, cryptoProvider, platform)
PN532Adapter nfc(serialAdapter, PN532_SS, &SPI)
ArduinoLoggerAdapter serialAdapter
ArduinoPlatform platform
ArduinoCryptoProvider cryptoProvider
void loop()
Arduino main loop.
#define PN532_SS_PIN
SPI slave-select (CS) pin connected to the PN532 module.
Definition Connect.ino:31
CW_CryptoProvider implementation for the Arduino UNO R4 (RA4M1).
CW_Logger implementation wrapping Arduino's HardwareSerial.
CW_Platform implementation using Arduino's blocking delay().
High-level interface for interacting with a Cryptnox Hardware Wallet over NFC.
CW_NfcTransport implementation over the Adafruit_PN532 driver.
#define F(string_literal)
Subset of the Cryptnox card info returned by APDU 0x80FA0000.
char name[CW_CARD_NAME_MAX_LEN+1U]
char email[CW_CARD_EMAIL_MAX_LEN+1U]
Holds cryptographic session state for reentrant secure channel operations.
Definition CW_Defs.h:168