Skip to content

Commit

Permalink
Imported new library version
Browse files Browse the repository at this point in the history
  • Loading branch information
Arbi Gunbardhi committed Mar 30, 2023
1 parent 233fbd5 commit 070584c
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 279 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ When the NFC module is started and ready, the message "Sytstem init done!" is di
Next, the tag is written, we wait few seconds, we read the same tag and print it on the monitor window.

You can test this application by connecting it with your smartphone.
On Android, donwload a NFC Tools. Then start the app, check if NFC is activated
On Android, download a NFC Tools. Then start the app, check if NFC is activated
on your smartphone. Put your smartphone near the tag, you can read it. You can
write a tag with this app.

* X_NUCLEO_NFC04A1_SimpleWrite: This application writes a NDEF message, containg a URI record, to the tag.
* X_NUCLEO_NFC04A1_SimpleWrite: This application writes a NDEF message, containing a URI record, to the tag.

When the NFC module is started and ready, the message "System init done!" is displayed on the monitor window.
Next, the tag is written with a URI.

You can test this application by tapping the tag with your smartphone.
On Android, check if NFC is activated on your smartphone.
Put your smartphone near the tag to read it.
The prefered Internet Browser is automatically opened with the provided URI.
The preferred Internet Browser is automatically opened with the provided URI.

# Dependencies

Expand Down
49 changes: 26 additions & 23 deletions examples/X_NUCLEO_NFC04A1_HelloWorld/X_NUCLEO_NFC04A1_HelloWorld.ino
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
******************************************************************************
@file X_NUCLEO_NFC04A1_HelloWorld.ino
@file X_NUCLEO_NFC07A1_HelloWorld.ino
@author STMicroelectronics
@version V1.0.0
@date 22 November 2017
@brief Arduino test application for the STMicrolectronics
X-NUCLEO-NFC04A1. NFC tag based on ST25DV device.
X-NUCLEO-NFC07A1. NFC tag based on ST25DV device.
This application makes use of C++ classes obtained from the C
components' drivers.
******************************************************************************
Expand Down Expand Up @@ -53,68 +53,71 @@
all LED's blink.
You can also use your smartphone to read/write a tag.
On Android, donwload a NFC Tools. Then start the app, check if NFC is activated
On Android, download a NFC Tools. Then start the app, check if NFC is activated
on your smartphone. Put your smartphone near the tag, you can read it. You can
write a tag with this app.
******************************************************************************
*/

#include "x_nucleo_nfc04.h"
#include "x_nucleo_nfc07.h"

#define DEV_I2C Wire
X_Nucleo_NFC07 Nfc(12, -1, &DEV_I2C);

void setup() {
const char uri_write_message[] = "st.com/st25"; // Uri message to write in the tag
const char uri_write_protocol[] = URI_ID_0x01_STRING; // Uri protocol to write in the tag
String uri_write = String(uri_write_protocol) + String(uri_write_message);
String uri_read;

if (X_Nucleo_Nfc04.begin()) {
if (Nfc.begin()) {
while (1) {
X_Nucleo_Nfc04.ledOn(GREEN_LED);
Nfc.ledOn(GREEN_LED);
delay(100);
X_Nucleo_Nfc04.ledOff(GREEN_LED);
Nfc.ledOff(GREEN_LED);
delay(100);
}
}
X_Nucleo_Nfc04.ledOn(GREEN_LED);
Nfc.ledOn(GREEN_LED);

if (X_Nucleo_Nfc04.writeURI(uri_write_protocol, uri_write_message, "")) {
if (Nfc.writeURI(uri_write_protocol, uri_write_message, "")) {
while (1) {
X_Nucleo_Nfc04.ledOn(BLUE_LED);
Nfc.ledOn(BLUE_LED);
delay(100);
X_Nucleo_Nfc04.ledOff(BLUE_LED);
Nfc.ledOff(BLUE_LED);
delay(100);
}
}

X_Nucleo_Nfc04.ledOn(BLUE_LED);
Nfc.ledOn(BLUE_LED);

delay(100);

if (X_Nucleo_Nfc04.readURI(&uri_read)) {
if (Nfc.readURI(&uri_read)) {
while (1) {
X_Nucleo_Nfc04.ledOn(YELLOW_LED);
Nfc.ledOn(YELLOW_LED);
delay(100);
X_Nucleo_Nfc04.ledOff(YELLOW_LED);
Nfc.ledOff(YELLOW_LED);
delay(100);
}
}

X_Nucleo_Nfc04.ledOn(YELLOW_LED);
Nfc.ledOn(YELLOW_LED);

if (strcmp(uri_read.c_str(), uri_write.c_str()) != 0) {
while (1) {
X_Nucleo_Nfc04.ledOn(GREEN_LED);
X_Nucleo_Nfc04.ledOn(BLUE_LED);
X_Nucleo_Nfc04.ledOn(YELLOW_LED);
Nfc.ledOn(GREEN_LED);
Nfc.ledOn(BLUE_LED);
Nfc.ledOn(YELLOW_LED);
delay(100);
X_Nucleo_Nfc04.ledOff(GREEN_LED);
X_Nucleo_Nfc04.ledOff(BLUE_LED);
X_Nucleo_Nfc04.ledOff(YELLOW_LED);
Nfc.ledOff(GREEN_LED);
Nfc.ledOff(BLUE_LED);
Nfc.ledOff(YELLOW_LED);
delay(100);
}
}
}

void loop() {
//empty loop
}
}
20 changes: 11 additions & 9 deletions examples/X_NUCLEO_NFC04A1_SimpleWrite/X_NUCLEO_NFC04A1_SimpleWrite.ino
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
******************************************************************************
@file X_NUCLEO_NFC04A1_SimpleWrite.ino
@file X_NUCLEO_NFC07A1_SimpleWrite.ino
@author STMicroelectronics
@version V1.0.0
@date 22 November 2017
@brief Arduino test application for the STMicrolectronics
X-NUCLEO-NFC04A1. NFC tag based on ST25DV device.
X-NUCLEO-NFC07A1. NFC tag based on ST25DV device.
This application makes use of C++ classes obtained from the C
components' drivers.
******************************************************************************
Expand Down Expand Up @@ -53,13 +53,15 @@
You can use your smartphone to read the tag.
On Android, check if NFC is activated on your smartphone.
Put your smartphone near the tag to natively read it.
The prefered Internet Browser is automatically opened with the provided URI.
The preferred Internet Browser is automatically opened with the provided URI.
******************************************************************************
*/

#include "x_nucleo_nfc04.h"
#include "x_nucleo_nfc07.h"

#define SerialPort Serial
#define DEV_I2C Wire
X_Nucleo_NFC07 Nfc(12, -1, &DEV_I2C);

void setup() {
const char uri_write_message[] = "st.com/st25"; // Uri message to write in the tag
Expand All @@ -69,23 +71,23 @@ void setup() {
// Initialize serial for output.
SerialPort.begin(115200);

if (X_Nucleo_Nfc04.begin() == 0) {
if (Nfc.begin() == 0) {
SerialPort.println("System Init done!");
X_Nucleo_Nfc04.ledOn(GREEN_LED);
Nfc.ledOn(GREEN_LED);
} else {
SerialPort.println("System Init failed!");
while (1);
}

if (X_Nucleo_Nfc04.writeURI(uri_write_protocol, uri_write_message, "")) {
if (Nfc.writeURI(uri_write_protocol, uri_write_message, "")) {
SerialPort.println("Write failed!");
while (1);
}

X_Nucleo_Nfc04.ledOn(BLUE_LED);
Nfc.ledOn(BLUE_LED);

}

void loop() {
//empty loop
}
}
128 changes: 0 additions & 128 deletions src/BSP/x_nucleo_nfc04a1.cpp

This file was deleted.

Loading

0 comments on commit 070584c

Please sign in to comment.