Compare commits
No commits in common. "bec2c9133117b45a24befb14ad16d37ad64562f0" and "492bf6cdb80a29bc6fcf20499135382ee1e4fc57" have entirely different histories.
bec2c91331
...
492bf6cdb8
@ -640,6 +640,8 @@ function writeNfcTag() {
|
|||||||
|
|
||||||
// Erstelle das NFC-Datenpaket mit korrekten Datentypen
|
// Erstelle das NFC-Datenpaket mit korrekten Datentypen
|
||||||
const nfcData = {
|
const nfcData = {
|
||||||
|
version: "2.0",
|
||||||
|
protocol: "openspool",
|
||||||
color_hex: selectedSpool.filament.color_hex || "FFFFFF",
|
color_hex: selectedSpool.filament.color_hex || "FFFFFF",
|
||||||
type: selectedSpool.filament.material,
|
type: selectedSpool.filament.material,
|
||||||
min_temp: minTemp,
|
min_temp: minTemp,
|
||||||
|
@ -97,15 +97,13 @@ function populateVendorDropdown(data, selectedSmId = null) {
|
|||||||
? (weightInKg / 1000).toFixed(2) + " t"
|
? (weightInKg / 1000).toFixed(2) + " t"
|
||||||
: weightInKg.toFixed(2) + " kg";
|
: weightInKg.toFixed(2) + " kg";
|
||||||
|
|
||||||
// Dropdown mit gefilterten Herstellern befüllen - alphabetisch sortiert
|
// Dropdown mit gefilterten Herstellern befüllen
|
||||||
Object.entries(filteredVendors)
|
Object.entries(filteredVendors).forEach(([id, name]) => {
|
||||||
.sort(([, nameA], [, nameB]) => nameA.localeCompare(nameB)) // Sort vendors alphabetically by name
|
const option = document.createElement("option");
|
||||||
.forEach(([id, name]) => {
|
option.value = id;
|
||||||
const option = document.createElement("option");
|
option.textContent = name;
|
||||||
option.value = id;
|
vendorSelect.appendChild(option);
|
||||||
option.textContent = name;
|
});
|
||||||
vendorSelect.appendChild(option);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById("totalSpools").textContent = totalSpools;
|
document.getElementById("totalSpools").textContent = totalSpools;
|
||||||
document.getElementById("spoolsWithoutTag").textContent = spoolsWithoutTag;
|
document.getElementById("spoolsWithoutTag").textContent = spoolsWithoutTag;
|
||||||
|
77
src/nfc.cpp
77
src/nfc.cpp
@ -44,6 +44,8 @@ void payloadToJson(uint8_t *data) {
|
|||||||
DeserializationError error = deserializeJson(doc, jsonString);
|
DeserializationError error = deserializeJson(doc, jsonString);
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
const char* version = doc["version"];
|
||||||
|
const char* protocol = doc["protocol"];
|
||||||
const char* color_hex = doc["color_hex"];
|
const char* color_hex = doc["color_hex"];
|
||||||
const char* type = doc["type"];
|
const char* type = doc["type"];
|
||||||
int min_temp = doc["min_temp"];
|
int min_temp = doc["min_temp"];
|
||||||
@ -53,6 +55,8 @@ void payloadToJson(uint8_t *data) {
|
|||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println("-----------------");
|
Serial.println("-----------------");
|
||||||
Serial.println("JSON-Parsed Data:");
|
Serial.println("JSON-Parsed Data:");
|
||||||
|
Serial.println(version);
|
||||||
|
Serial.println(protocol);
|
||||||
Serial.println(color_hex);
|
Serial.println(color_hex);
|
||||||
Serial.println(type);
|
Serial.println(type);
|
||||||
Serial.println(min_temp);
|
Serial.println(min_temp);
|
||||||
@ -89,16 +93,8 @@ bool formatNdefTag() {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t readTagSize()
|
|
||||||
{
|
|
||||||
uint8_t buffer[4];
|
|
||||||
memset(buffer, 0, 4);
|
|
||||||
nfc.ntag2xx_ReadPage(3, buffer);
|
|
||||||
return buffer[2]*8;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t ntag2xx_WriteNDEF(const char *payload) {
|
uint8_t ntag2xx_WriteNDEF(const char *payload) {
|
||||||
uint16_t tagSize = readTagSize();
|
uint8_t tagSize = 240; // 144 bytes is maximum for NTAG213
|
||||||
Serial.print("Tag Size: ");Serial.println(tagSize);
|
Serial.print("Tag Size: ");Serial.println(tagSize);
|
||||||
|
|
||||||
uint8_t pageBuffer[4] = {0, 0, 0, 0};
|
uint8_t pageBuffer[4] = {0, 0, 0, 0};
|
||||||
@ -140,8 +136,6 @@ uint8_t ntag2xx_WriteNDEF(const char *payload) {
|
|||||||
if (combinedData == NULL)
|
if (combinedData == NULL)
|
||||||
{
|
{
|
||||||
Serial.println("Fehler: Nicht genug Speicher vorhanden.");
|
Serial.println("Fehler: Nicht genug Speicher vorhanden.");
|
||||||
oledShowMessage("Tag too small");
|
|
||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,51 +369,46 @@ void scanRfidTask(void * parameter) {
|
|||||||
|
|
||||||
if (uidLength == 7)
|
if (uidLength == 7)
|
||||||
{
|
{
|
||||||
uint16_t tagSize = readTagSize();
|
uint8_t data[256];
|
||||||
if(tagSize > 0)
|
|
||||||
{
|
|
||||||
// Create a buffer depending on the size of the tag
|
|
||||||
uint8_t* data = (uint8_t*)malloc(tagSize);
|
|
||||||
memset(data, 0, tagSize);
|
|
||||||
|
|
||||||
// We probably have an NTAG2xx card (though it could be Ultralight as well)
|
// We probably have an NTAG2xx card (though it could be Ultralight as well)
|
||||||
Serial.println("Seems to be an NTAG2xx tag (7 byte UID)");
|
Serial.println("Seems to be an NTAG2xx tag (7 byte UID)");
|
||||||
|
|
||||||
uint8_t numPages = readTagSize()/4;
|
for (uint8_t i = 0; i < 45; i++) {
|
||||||
for (uint8_t i = 4; i < 4+numPages; i++) {
|
/*
|
||||||
if (!nfc.ntag2xx_ReadPage(i, data+(i-4) * 4))
|
if (i < uidLength) {
|
||||||
{
|
uidString += String(uid[i], HEX);
|
||||||
break; // Stop if reading fails
|
if (i < uidLength - 1) {
|
||||||
|
uidString += ":"; // Optional: Trennzeichen hinzufügen
|
||||||
}
|
}
|
||||||
// Check for NDEF message end
|
|
||||||
if (data[(i - 4) * 4] == 0xFE)
|
|
||||||
{
|
|
||||||
break; // End of NDEF message
|
|
||||||
}
|
|
||||||
|
|
||||||
yield();
|
|
||||||
esp_task_wdt_reset();
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(1));
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (!decodeNdefAndReturnJson(data))
|
if (!nfc.mifareclassic_ReadDataBlock(i, data + (i - 4) * 4))
|
||||||
{
|
{
|
||||||
oledShowMessage("NFC-Tag unknown");
|
break; // Stop if reading fails
|
||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
|
||||||
hasReadRfidTag = 2;
|
|
||||||
}
|
}
|
||||||
else
|
// Check for NDEF message end
|
||||||
|
if (data[(i - 4) * 4] == 0xFE)
|
||||||
{
|
{
|
||||||
hasReadRfidTag = 1;
|
break; // End of NDEF message
|
||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
yield();
|
||||||
|
esp_task_wdt_reset();
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!decodeNdefAndReturnJson(data))
|
||||||
{
|
{
|
||||||
oledShowMessage("NFC-Tag read error");
|
oledShowMessage("NFC-Tag unknown");
|
||||||
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
hasReadRfidTag = 2;
|
hasReadRfidTag = 2;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hasReadRfidTag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user