#include "ST25DVSensor.h"
#define SerialPort Serial
#if defined(ARDUINO_B_L4S5I_IOT01A)
// Pin definitions for board B-L4S5I_IOT01A
#define GPO_PIN PE4
#define LPD_PIN PE2
#define SDA_PIN PB11
#define SCL_PIN PB10
#define WireNFC MyWire
TwoWire MyWire(SDA_PIN, SCL_PIN);
ST25DV st25dv(12, -1, &MyWire);
#else
#define DEV_I2C Wire
ST25DV st25dv(12, -1, &DEV_I2C);
#endif
void clearNFCMemory() {
//ok so one issue was that the buffer was not being cleared before writing new data to the tag.
st25dv.writeURI("", "", ""); // Write empty data to clear the memory
}
char *a[]= {
"C.pdf",
"P.pdf",
"B.pdf",
"L.pdf",
"A.pdf"
};
/*
There is of course a solution that beats this, by loading a single actual webpage that handles getting random docs.
just let the arduino monitor N reads and Energy. Would save a bunch of over head.
*/
void setup() {
// SerialPort.begin(115200);
st25dv.begin();
clearNFCMemory(); //
delay(1000);
}
void loop() {
String urlBase = "10.1.0.250/";
for (int i = 0; i < 5; i++) {
String completeURL = urlBase + a[i]; // Combine base and filename
char uriBuffer[128];
completeURL.toCharArray(uriBuffer, sizeof(uriBuffer));
st25dv.writeURI(String(uriBuffer),"", ""); // Write the URI
delay(10000); // 10-sec delay
clearNFCMemory();
}
}