diff --git a/arduino/LoraNFC/sketch_may24a/sketch_may24a.ino b/arduino/LoraNFC/sketch_may24a/sketch_may24a.ino new file mode 100644 index 0000000..3990794 --- /dev/null +++ b/arduino/LoraNFC/sketch_may24a/sketch_may24a.ino @@ -0,0 +1,102 @@ +#include +#include +#include "boards.h" +#include +#include +#include + +PN532_I2C pn532_i2c(Wire); +NfcAdapter nfc = NfcAdapter(pn532_i2c); +String tagId = "None"; +String cleanString = ""; + + +void setup() +{ + Serial.begin(9600); + Serial.println("System initialized"); + nfc.begin(); + + initLoRa(); +} + +void loop() +{ + readNFC(); + if (!cleanString.isEmpty()) { + sendLoRaData(cleanString); + } +} + +void initLoRa() +{ + Serial.println("Initializing LoRa..."); + LoRa.setPins(RADIO_CS_PIN, RADIO_RST_PIN, RADIO_DI0_PIN); + if (!LoRa.begin(LoRa_frequency)) + { + Serial.println("Starting LoRa failed!"); + while (1); + } + Serial.println("LoRa initialized successfully!"); +} + +void sendLoRaData(String data) +{ + String message = "node3 " + data; // Concatenate "node3 " with the value of cleanString + + LoRa.beginPacket(); + LoRa.print(message); + LoRa.endPacket(); +} + +void readNFC() +{ + if (nfc.tagPresent()) + { + NfcTag tag = nfc.read(); + tagId = tag.getUidString(); + Serial.print("Tag ID: "); + Serial.println(tagId); + + if (tag.hasNdefMessage()) + { + NdefMessage message = tag.getNdefMessage(); + int recordCount = message.getRecordCount(); + Serial.print("Number of NDEF records: "); + Serial.println(recordCount); + + for (int i = 0; i < recordCount; i++) + { + NdefRecord record = message.getRecord(i); + int payloadLength = record.getPayloadLength(); + byte payload[payloadLength]; + record.getPayload(payload); + + String payloadAsString = ""; + for (int c = 0; c < payloadLength; c++) + { + payloadAsString += (char)payload[c]; + } + + if (payloadLength > 0) { + cleanString = payloadAsString; + cleanString.remove(0, 3); + Serial.print("Payload: "); + Serial.println(cleanString); + } + + String uid = record.getId(); + if (uid != "") + { + Serial.print("Record ID: "); + Serial.println(uid); + } + } + } + else + { + Serial.println("No NDEF message found on the tag."); + } + delay(2000); + } +} diff --git a/public/index.html b/public/index.html index d0fd253..aed183a 100644 --- a/public/index.html +++ b/public/index.html @@ -22,7 +22,12 @@ if (node === 'node3' && value === '15') { // Change the background color to red document.body.style.backgroundColor = 'red'; - } else { + } + if (node === 'node4' && value === '20') { + // Change the background color to red + document.body.style.backgroundColor = 'blue'; + } + else { // Restore the default background color document.body.style.backgroundColor = 'white'; } @@ -46,7 +51,7 @@




-

OBJECTIVE:
Enter S/ash Gallery to step into the game and unlock gateway 1. Tap the different markers on the map in order to navigate and receive objectives. When set to the right digit, the modules in the locations will reveal a port number. Enter it above to collect dream logs. Follow the blue markers on the pavement to make your way through the landmarks.

+

OBJECTIVE:
RUN