Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb3d3952b0 | ||
|
|
3662422c1c |
+37
-37
@@ -234,51 +234,51 @@ void loop() {
|
|||||||
weightSend = 0;
|
weightSend = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastWeight = weight;
|
lastWeight = weight;
|
||||||
|
|
||||||
// Wenn ein Tag erkannt wurde und das Gewicht stabil ist (4+ seconds), an FilaMan senden
|
// Wenn ein Tag erkannt wurde und das Gewicht stabil ist (4+ seconds), an FilaMan senden
|
||||||
if (!scanRequestActive && weightCounterToApi > 3 && weightSend == 0 && nfcReaderState == NFC_READ_SUCCESS && tagProcessed == false)
|
if (!scanRequestActive && weightCounterToApi > 3 && weightSend == 0 && nfcReaderState == NFC_READ_SUCCESS && tagProcessed == false)
|
||||||
{
|
{
|
||||||
tagProcessed = true;
|
tagProcessed = true;
|
||||||
|
|
||||||
// Check if it's a Bambu tag - if so, send only UUID without spoolId
|
// Check if it's a Bambu tag - if so, send only UUID without spoolId
|
||||||
if (isBambuTag) {
|
if (isBambuTag) {
|
||||||
sendWeightAsync(0, activeTagUuid, weight);
|
sendWeightAsync(0, activeTagUuid, weight);
|
||||||
Serial.println("Bambu weight queued for FilaMan (UUID only)");
|
Serial.println("Bambu weight queued for FilaMan (UUID only)");
|
||||||
} else {
|
} else {
|
||||||
// Normal NTAG: send spoolId + UUID
|
// Normal NTAG: send spoolId + UUID
|
||||||
int sId = activeSpoolId.toInt();
|
int sId = activeSpoolId.toInt();
|
||||||
sendWeightAsync(sId, activeTagUuid, weight);
|
sendWeightAsync(sId, activeTagUuid, weight);
|
||||||
Serial.println("Weight queued for FilaMan");
|
Serial.println("Weight queued for FilaMan");
|
||||||
}
|
}
|
||||||
weightSend = 1;
|
|
||||||
|
|
||||||
// Feedback to user
|
|
||||||
oledShowProgressBar(3, 4, tr(STR_SPOOL_TAG), tr(STR_SENDING));
|
|
||||||
oledSetPriority(DISPLAY_PRIORITY_ACTION, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle successful tag write
|
|
||||||
if (!scanRequestActive && nfcReaderState == NFC_WRITE_SUCCESS && tagProcessed == false)
|
|
||||||
{
|
|
||||||
tagProcessed = true;
|
|
||||||
|
|
||||||
// Only send weight if a valid spoolId exists (spool tag, not location tag)
|
|
||||||
if (activeSpoolId.length() > 0 && activeSpoolId != "0") {
|
|
||||||
int sId = activeSpoolId.toInt();
|
|
||||||
sendWeightAsync(sId, activeTagUuid, weight);
|
|
||||||
weightSend = 1;
|
weightSend = 1;
|
||||||
Serial.println("Weight queued for FilaMan after spool tag write");
|
|
||||||
|
|
||||||
// Feedback to user
|
// Feedback to user
|
||||||
oledShowProgressBar(3, 4, tr(STR_TAG_WRITTEN), tr(STR_SENDING));
|
oledShowProgressBar(3, 4, tr(STR_SPOOL_TAG), tr(STR_SENDING));
|
||||||
oledSetPriority(DISPLAY_PRIORITY_ACTION, 2000);
|
oledSetPriority(DISPLAY_PRIORITY_ACTION, 2000);
|
||||||
} else {
|
}
|
||||||
// Location tag written - no weight to send
|
|
||||||
Serial.println("Location tag written successfully - no weight send needed");
|
// Handle successful tag write
|
||||||
|
if (!scanRequestActive && nfcReaderState == NFC_WRITE_SUCCESS && tagProcessed == false)
|
||||||
|
{
|
||||||
|
tagProcessed = true;
|
||||||
|
|
||||||
|
// Only send weight if a valid spoolId exists (spool tag, not location tag)
|
||||||
|
if (activeSpoolId.length() > 0 && activeSpoolId != "0") {
|
||||||
|
int sId = activeSpoolId.toInt();
|
||||||
|
sendWeightAsync(sId, activeTagUuid, weight);
|
||||||
|
weightSend = 1;
|
||||||
|
Serial.println("Weight queued for FilaMan after spool tag write");
|
||||||
|
|
||||||
|
// Feedback to user
|
||||||
|
oledShowProgressBar(3, 4, tr(STR_TAG_WRITTEN), tr(STR_SENDING));
|
||||||
|
oledSetPriority(DISPLAY_PRIORITY_ACTION, 2000);
|
||||||
|
} else {
|
||||||
|
// Location tag written - no weight to send
|
||||||
|
Serial.println("Location tag written successfully - no weight send needed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user