Compare commits
5 Commits
492bf6cdb8
...
bec2c91331
Author | SHA1 | Date | |
---|---|---|---|
bec2c91331 | |||
c6e727de06 | |||
3253e7d407 | |||
bce2ad2ed8 | |||
|
0eff29ef4a |
@ -640,8 +640,6 @@ 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,8 +97,10 @@ 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
|
// Dropdown mit gefilterten Herstellern befüllen - alphabetisch sortiert
|
||||||
Object.entries(filteredVendors).forEach(([id, name]) => {
|
Object.entries(filteredVendors)
|
||||||
|
.sort(([, nameA], [, nameB]) => nameA.localeCompare(nameB)) // Sort vendors alphabetically by name
|
||||||
|
.forEach(([id, name]) => {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.value = id;
|
option.value = id;
|
||||||
option.textContent = name;
|
option.textContent = name;
|
||||||
|
43
src/nfc.cpp
43
src/nfc.cpp
@ -44,8 +44,6 @@ 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"];
|
||||||
@ -55,8 +53,6 @@ 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);
|
||||||
@ -93,8 +89,16 @@ 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) {
|
||||||
uint8_t tagSize = 240; // 144 bytes is maximum for NTAG213
|
uint16_t tagSize = readTagSize();
|
||||||
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};
|
||||||
@ -136,6 +140,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,21 +375,19 @@ void scanRfidTask(void * parameter) {
|
|||||||
|
|
||||||
if (uidLength == 7)
|
if (uidLength == 7)
|
||||||
{
|
{
|
||||||
uint8_t data[256];
|
uint16_t tagSize = readTagSize();
|
||||||
|
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)");
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 45; i++) {
|
uint8_t numPages = readTagSize()/4;
|
||||||
/*
|
for (uint8_t i = 4; i < 4+numPages; i++) {
|
||||||
if (i < uidLength) {
|
if (!nfc.ntag2xx_ReadPage(i, data+(i-4) * 4))
|
||||||
uidString += String(uid[i], HEX);
|
|
||||||
if (i < uidLength - 1) {
|
|
||||||
uidString += ":"; // Optional: Trennzeichen hinzufügen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (!nfc.mifareclassic_ReadDataBlock(i, data + (i - 4) * 4))
|
|
||||||
{
|
{
|
||||||
break; // Stop if reading fails
|
break; // Stop if reading fails
|
||||||
}
|
}
|
||||||
@ -409,6 +413,13 @@ void scanRfidTask(void * parameter) {
|
|||||||
hasReadRfidTag = 1;
|
hasReadRfidTag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oledShowMessage("NFC-Tag read error");
|
||||||
|
hasReadRfidTag = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user