Compare commits
9 Commits
v1.5.12-be
...
v1.5.12-be
Author | SHA1 | Date | |
---|---|---|---|
d897817020 | |||
686eb22232 | |||
a2816da654 | |||
cc8f1cfd7b | |||
d195f76d5e | |||
6bed3b086c | |||
3dd4b82710 | |||
bc41205f15 | |||
f450d1efdf |
24
CHANGELOG.md
24
CHANGELOG.md
@@ -1,5 +1,29 @@
|
||||
# Changelog
|
||||
|
||||
## [1.5.12-beta4] - 2025-08-29
|
||||
### Added
|
||||
- enhance NDEF decoding to validate structure and extract JSON payload
|
||||
|
||||
### Changed
|
||||
- update platformio.ini for beta version v1.5.12-beta4
|
||||
|
||||
|
||||
## [1.5.12-beta3] - 2025-08-29
|
||||
### Added
|
||||
- add logging for decoded JSON data in NFC processing
|
||||
|
||||
### Changed
|
||||
- update platformio.ini for beta version v1.5.12-beta3
|
||||
|
||||
|
||||
## [1.5.12-beta2] - 2025-08-29
|
||||
### Changed
|
||||
- update platformio.ini for beta version v1.5.12-beta2
|
||||
|
||||
### Fixed
|
||||
- enhance filament creation logic to include dynamic comments based on payload
|
||||
|
||||
|
||||
## [1.5.12-beta1] - 2025-08-28
|
||||
### Added
|
||||
- implement filament and spool creation in Spoolman API
|
||||
|
@@ -9,7 +9,7 @@
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[common]
|
||||
version = "1.5.12-beta1"
|
||||
version = "1.5.12-beta4"
|
||||
to_old_version = "1.5.0"
|
||||
|
||||
##
|
||||
|
12
src/api.cpp
12
src/api.cpp
@@ -752,10 +752,18 @@ uint16_t createFilament(uint16_t vendorId, const JsonDocument& payload) {
|
||||
filamentDoc["weight"] = payload["weight"].as<String>();
|
||||
filamentDoc["spool_weight"] = payload["spool_weight"].as<String>();
|
||||
filamentDoc["article_number"] = payload["artnr"].as<String>();
|
||||
filamentDoc["comment"] = String("automatically generated");
|
||||
filamentDoc["extruder_temp"] = payload["extruder_temp"].is<String>() ? payload["extruder_temp"].as<String>() : "";
|
||||
filamentDoc["bed_temp"] = payload["bed_temp"].is<String>() ? payload["bed_temp"].as<String>() : "";
|
||||
filamentDoc["external_id"] = payload["artnr"].as<String>();
|
||||
|
||||
if (payload["artnr"].is<String>())
|
||||
{
|
||||
filamentDoc["external_id"] = payload["artnr"].as<String>();
|
||||
filamentDoc["comment"] = payload["url"].is<String>() ? payload["url"].as<String>() + payload["artnr"].as<String>() : "automatically generated";
|
||||
}
|
||||
else
|
||||
{
|
||||
filamentDoc["comment"] = payload["url"].is<String>() ? payload["url"].as<String>() : "automatically generated";
|
||||
}
|
||||
|
||||
if (payload["multi_color_hexes"].is<String>()) {
|
||||
filamentDoc["multi_color_hexes"] = payload["multi_color_hexes"].as<String>();
|
||||
|
57
src/nfc.cpp
57
src/nfc.cpp
@@ -206,16 +206,63 @@ uint8_t ntag2xx_WriteNDEF(const char *payload) {
|
||||
bool decodeNdefAndReturnJson(const byte* encodedMessage, String uidString) {
|
||||
oledShowProgressBar(1, octoEnabled?5:4, "Reading", "Decoding data");
|
||||
|
||||
byte typeLength = encodedMessage[3];
|
||||
byte payloadLength = encodedMessage[4];
|
||||
// Check for NDEF TLV (Type-Length-Value) structure
|
||||
if (encodedMessage[0] != 0x03) {
|
||||
Serial.println("Not a valid NDEF message (missing TLV tag 0x03)");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the total NDEF message length from TLV
|
||||
byte ndefMessageLength = encodedMessage[1];
|
||||
|
||||
// Skip TLV header (2 bytes) to get to NDEF record
|
||||
const byte* ndefRecord = &encodedMessage[2];
|
||||
|
||||
// Parse NDEF record header
|
||||
byte recordHeader = ndefRecord[0];
|
||||
byte typeLength = ndefRecord[1];
|
||||
|
||||
// Determine payload length (can be 1 or 4 bytes depending on SR flag)
|
||||
uint32_t payloadLength = 0;
|
||||
byte payloadLengthBytes = 1;
|
||||
|
||||
// Check if Short Record (SR) flag is set
|
||||
if (recordHeader & 0x10) { // SR flag
|
||||
payloadLength = ndefRecord[2];
|
||||
payloadLengthBytes = 1;
|
||||
} else {
|
||||
// Long record format (4 bytes for payload length)
|
||||
payloadLength = (ndefRecord[2] << 24) | (ndefRecord[3] << 16) |
|
||||
(ndefRecord[4] << 8) | ndefRecord[5];
|
||||
payloadLengthBytes = 4;
|
||||
}
|
||||
|
||||
Serial.print("NDEF Record Header: 0x");
|
||||
Serial.println(recordHeader, HEX);
|
||||
Serial.print("Type Length: ");
|
||||
Serial.println(typeLength);
|
||||
Serial.print("Payload Length: ");
|
||||
Serial.println(payloadLength);
|
||||
|
||||
// Calculate offset to payload
|
||||
byte payloadOffset = 2 + payloadLengthBytes + typeLength;
|
||||
|
||||
// Verify we have enough data
|
||||
if (payloadOffset + payloadLength > ndefMessageLength + 2) {
|
||||
Serial.println("Invalid NDEF structure - payload extends beyond message");
|
||||
return false;
|
||||
}
|
||||
|
||||
nfcJsonData = "";
|
||||
|
||||
for (int i = 2; i < payloadLength+2; i++)
|
||||
{
|
||||
nfcJsonData += (char)encodedMessage[3 + typeLength + i];
|
||||
// Extract JSON payload
|
||||
for (uint32_t i = 0; i < payloadLength; i++) {
|
||||
nfcJsonData += (char)ndefRecord[payloadOffset + i];
|
||||
}
|
||||
|
||||
Serial.println("Decoded JSON Data:");
|
||||
Serial.println(nfcJsonData);
|
||||
|
||||
// JSON-Dokument verarbeiten
|
||||
JsonDocument doc;
|
||||
DeserializationError error = deserializeJson(doc, nfcJsonData);
|
||||
|
Reference in New Issue
Block a user