-
Notifications
You must be signed in to change notification settings - Fork 6
feat: OpenSpool tag format support (#93) #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fcb21a8
406ab72
536699c
22afd9b
236190f
6ba1d73
7d3557f
73d8e5b
5f10379
96247a2
dd470bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||||||
| #include "NFCManager.h" | ||||||||||||||||||||||
| #include "ConversionUtils.h" | ||||||||||||||||||||||
| #include "TigerTagParser.h" | ||||||||||||||||||||||
| #include "OpenSpoolParser.h" | ||||||||||||||||||||||
| #ifndef NATIVE_TEST | ||||||||||||||||||||||
| #include "ApplicationManager.h" | ||||||||||||||||||||||
| #include "HardwareNFCConnection.h" | ||||||||||||||||||||||
|
|
@@ -112,6 +113,15 @@ bool NFCManager::getLastOpenTag3DData(opentag3d_t& out) { | |||||||||||||||||||||
| return valid; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| bool NFCManager::getLastOpenSpoolData(OpenSpoolData& out) { | ||||||||||||||||||||||
| if (tagMutex == nullptr) return false; | ||||||||||||||||||||||
| if (xSemaphoreTake(tagMutex, pdMS_TO_TICKS(50)) != pdTRUE) return false; | ||||||||||||||||||||||
| bool valid = lastOpenSpoolValid_; | ||||||||||||||||||||||
| if (valid) out = lastOpenSpool_; | ||||||||||||||||||||||
| xSemaphoreGive(tagMutex); | ||||||||||||||||||||||
| return valid; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| void NFCManager::setGenericTagSpoolInfo(const GenericTagSpoolInfo& info) { | ||||||||||||||||||||||
| if (tagMutex && xSemaphoreTake(tagMutex, pdMS_TO_TICKS(50)) == pdTRUE) { | ||||||||||||||||||||||
| lastGenericTagSpoolInfo_ = info; | ||||||||||||||||||||||
|
|
@@ -310,10 +320,12 @@ void NFCManager::scanLoop() { | |||||||||||||||||||||
| Serial.printf("NFCManager: Bambu Lab tag — UID=%s (encrypted, no data access)\n", scan.uid_hex); | ||||||||||||||||||||||
| sendGenericTagMessage(); | ||||||||||||||||||||||
| } else if (scan.kind == TagKind::GenericUidTag) { | ||||||||||||||||||||||
| // ISO14443A tag — try TigerTag, then OpenTag3D, fall back to UID-only | ||||||||||||||||||||||
| // ISO14443A tag — try TigerTag, then OpenTag3D, then OpenSpool, fall back to UID-only | ||||||||||||||||||||||
| bool isTigerTag = false; | ||||||||||||||||||||||
| bool isOpenTag3D = false; | ||||||||||||||||||||||
| bool isOpenSpool = false; | ||||||||||||||||||||||
| TigerTagData tigerData; | ||||||||||||||||||||||
| OpenSpoolData openSpoolData; | ||||||||||||||||||||||
| opentag3d_t ot3dData; | ||||||||||||||||||||||
| memset(&tigerData, 0, sizeof(tigerData)); | ||||||||||||||||||||||
| memset(&ot3dData, 0, sizeof(ot3dData)); | ||||||||||||||||||||||
|
|
@@ -414,6 +426,51 @@ void NFCManager::scanLoop() { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Check for OpenSpool (application/json + "protocol":"openspool") | ||||||||||||||||||||||
| if (!isOpenTag3D) { | ||||||||||||||||||||||
| const char* jsonMime = "application/json"; | ||||||||||||||||||||||
| size_t jsonMimeLen = strlen(jsonMime); | ||||||||||||||||||||||
| if (typeLen == jsonMimeLen && | ||||||||||||||||||||||
| memcmp(pageData + ndefStart + headerSize, jsonMime, jsonMimeLen) == 0) { | ||||||||||||||||||||||
| uint32_t osPayloadLen = 0; | ||||||||||||||||||||||
| if (sr) { | ||||||||||||||||||||||
| osPayloadLen = pageData[ndefStart + 2]; | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| osPayloadLen = ((uint32_t)pageData[ndefStart + 2] << 24) | | ||||||||||||||||||||||
| ((uint32_t)pageData[ndefStart + 3] << 16) | | ||||||||||||||||||||||
| ((uint32_t)pageData[ndefStart + 4] << 8) | | ||||||||||||||||||||||
| pageData[ndefStart + 5]; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| uint16_t osOffset = ndefStart + headerSize + typeLen; | ||||||||||||||||||||||
| uint8_t osPayload[256] = {0}; | ||||||||||||||||||||||
| uint16_t osBytes = 0; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (osOffset + osPayloadLen <= bytesRead) { | ||||||||||||||||||||||
| osBytes = (uint16_t)osPayloadLen; | ||||||||||||||||||||||
| if (osBytes > sizeof(osPayload)) osBytes = sizeof(osPayload); | ||||||||||||||||||||||
| memcpy(osPayload, pageData + osOffset, osBytes); | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| uint8_t osStartPage = 4 + (osOffset / 4); | ||||||||||||||||||||||
| uint16_t osPagesNeeded = (uint16_t)((osPayloadLen + 3) / 4) + 1; | ||||||||||||||||||||||
| if (osPagesNeeded > 50) osPagesNeeded = 50; | ||||||||||||||||||||||
| uint8_t osExtData[256] = {0}; | ||||||||||||||||||||||
| uint16_t osExtRead = connection_->readISO14443Pages( | ||||||||||||||||||||||
| osStartPage, (uint8_t)osPagesNeeded, osExtData, sizeof(osExtData)); | ||||||||||||||||||||||
| uint16_t osOffInPage = osOffset % 4; | ||||||||||||||||||||||
| if (osExtRead > osOffInPage) { | ||||||||||||||||||||||
| osBytes = osExtRead - osOffInPage; | ||||||||||||||||||||||
| if (osBytes > osPayloadLen) osBytes = (uint16_t)osPayloadLen; | ||||||||||||||||||||||
| if (osBytes > sizeof(osPayload)) osBytes = sizeof(osPayload); | ||||||||||||||||||||||
| memcpy(osPayload, osExtData + osOffInPage, osBytes); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (osBytes > 0 && parseOpenSpool(osPayload, osBytes, openSpoolData)) { | ||||||||||||||||||||||
| isOpenSpool = true; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| break; | ||||||||||||||||||||||
|
|
@@ -449,14 +506,26 @@ void NFCManager::scanLoop() { | |||||||||||||||||||||
| lastOpenTag3D_ = ot3dData; | ||||||||||||||||||||||
| lastOpenTag3DValid_ = true; | ||||||||||||||||||||||
| lastTigerTagValid_ = false; | ||||||||||||||||||||||
| lastOpenSpoolValid_ = false; | ||||||||||||||||||||||
| Serial.printf("NFCManager: OpenTag3D detected — %s %s %.2fmm %ug\n", | ||||||||||||||||||||||
| ot3dData.manufacturer, ot3dData.base_material, | ||||||||||||||||||||||
| opentag3d_diameter_mm(&ot3dData), ot3dData.target_weight_g); | ||||||||||||||||||||||
| } else if (isOpenSpool) { | ||||||||||||||||||||||
| currentSpool.kind = TagKind::OpenSpoolTag; | ||||||||||||||||||||||
| currentSpool.tag_data_valid = false; | ||||||||||||||||||||||
| lastOpenSpool_ = openSpoolData; | ||||||||||||||||||||||
| lastOpenSpoolValid_ = true; | ||||||||||||||||||||||
| lastTigerTagValid_ = false; | ||||||||||||||||||||||
| lastOpenTag3DValid_ = false; | ||||||||||||||||||||||
| Serial.printf("NFCManager: OpenSpool detected — %s %s #%s\n", | ||||||||||||||||||||||
| openSpoolData.brand, openSpoolData.material, | ||||||||||||||||||||||
| openSpoolData.color_hex); | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| currentSpool.kind = TagKind::GenericUidTag; | ||||||||||||||||||||||
| currentSpool.tag_data_valid = false; | ||||||||||||||||||||||
| lastTigerTagValid_ = false; | ||||||||||||||||||||||
| lastOpenTag3DValid_ = false; | ||||||||||||||||||||||
| lastOpenSpoolValid_ = false; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| xSemaphoreGive(tagMutex); | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
|
|
@@ -467,6 +536,8 @@ void NFCManager::scanLoop() { | |||||||||||||||||||||
| sendTigerTagMessage(tigerData); | ||||||||||||||||||||||
| } else if (isOpenTag3D) { | ||||||||||||||||||||||
| sendOpenTag3DMessage(ot3dData); | ||||||||||||||||||||||
| } else if (isOpenSpool) { | ||||||||||||||||||||||
| sendOpenSpoolMessage(currentSpool.spool_id, openSpoolData); | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| sendGenericTagMessage(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
@@ -1093,6 +1164,56 @@ void NFCManager::sendOpenTag3DMessage(const opentag3d_t& ot3d) { | |||||||||||||||||||||
| ApplicationManager::getInstance().sendMessage(msg); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| void NFCManager::sendOpenSpoolMessage(const char* uid, const OpenSpoolData& os) { | ||||||||||||||||||||||
| AppMessage msg; | ||||||||||||||||||||||
| msg.type = AppMessageType::SPOOL_DETECTED; | ||||||||||||||||||||||
| auto& s = msg.payload.spoolDetected; | ||||||||||||||||||||||
| memset(&s, 0, sizeof(s)); | ||||||||||||||||||||||
|
Comment on lines
+1167
to
+1171
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Use member initializer instead of
Proposed fix void NFCManager::sendOpenSpoolMessage(const char* uid, const OpenSpoolData& os) {
AppMessage msg;
msg.type = AppMessageType::SPOOL_DETECTED;
- auto& s = msg.payload.spoolDetected;
- memset(&s, 0, sizeof(s));
+ msg.payload.spoolDetected = {}; // Value-initialize all members
+ auto& s = msg.payload.spoolDetected;📝 Committable suggestion
Suggested change
🧰 Tools🪛 Clang (14.0.6)[note] 1158-1158: the definition seen here (clang) [warning] 1158-1158: method 'sendOpenSpoolMessage' can be made static (readability-convert-member-functions-to-static) [warning] 1158-1158: parameter name 'os' is too short, expected at least 3 characters (readability-identifier-length) [warning] 1161-1161: variable name 's' is too short, expected at least 3 characters (readability-identifier-length) 🪛 Cppcheck (2.20.0)[portability] 1162-1162: Using memset() on struct which contains a floating point number. (memsetClassFloat) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| strncpy(s.spool_id, uid, sizeof(s.spool_id) - 1); | ||||||||||||||||||||||
| strncpy(s.manufacturer, os.brand, sizeof(s.manufacturer) - 1); | ||||||||||||||||||||||
| strncpy(s.material_name, os.material, sizeof(s.material_name) - 1); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Material type lookup | ||||||||||||||||||||||
| s.material_type = 0; | ||||||||||||||||||||||
| if (strcasecmp(os.material, "PLA") == 0) s.material_type = OPT_MATERIAL_TYPE_PLA; | ||||||||||||||||||||||
| else if (strcasecmp(os.material, "PETG") == 0) s.material_type = OPT_MATERIAL_TYPE_PETG; | ||||||||||||||||||||||
| else if (strcasecmp(os.material, "ABS") == 0) s.material_type = OPT_MATERIAL_TYPE_ABS; | ||||||||||||||||||||||
| else if (strcasecmp(os.material, "ASA") == 0) s.material_type = OPT_MATERIAL_TYPE_ASA; | ||||||||||||||||||||||
| else if (strcasecmp(os.material, "TPU") == 0) s.material_type = OPT_MATERIAL_TYPE_TPU; | ||||||||||||||||||||||
| else if (strcasecmp(os.material, "PA") == 0 || strcasecmp(os.material, "Nylon") == 0) s.material_type = OPT_MATERIAL_TYPE_PA6; | ||||||||||||||||||||||
| else if (strcasecmp(os.material, "PC") == 0) s.material_type = OPT_MATERIAL_TYPE_PC; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Comment on lines
+1177
to
+1186
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't silently map unsupported OpenSpool materials to PLA. This branch recognizes far fewer material names than the TigerTag/OpenTag3D paths. Anything outside this list leaves 🤖 Prompt for AI Agents |
||||||||||||||||||||||
| // Parse color hex to RGB | ||||||||||||||||||||||
| if (strlen(os.color_hex) == 6) { | ||||||||||||||||||||||
| unsigned int r, g, b; | ||||||||||||||||||||||
| if (sscanf(os.color_hex, "%02x%02x%02x", &r, &g, &b) == 3) { | ||||||||||||||||||||||
| s.primary_color[0] = (uint8_t)r; | ||||||||||||||||||||||
| s.primary_color[1] = (uint8_t)g; | ||||||||||||||||||||||
| s.primary_color[2] = (uint8_t)b; | ||||||||||||||||||||||
| s.primary_color[3] = 255; | ||||||||||||||||||||||
| s.has_color = true; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| s.min_print_temp = os.min_temp; | ||||||||||||||||||||||
| s.max_print_temp = os.max_temp; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| strncpy(s.tag_format, "OpenSpool", sizeof(s.tag_format) - 1); | ||||||||||||||||||||||
| s.spoolman_id = -1; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Serial.println("--- OpenSpool SpoolDetected payload ---"); | ||||||||||||||||||||||
| Serial.printf(" uid: %s\n", s.spool_id); | ||||||||||||||||||||||
| Serial.printf(" brand: %s\n", s.manufacturer); | ||||||||||||||||||||||
| Serial.printf(" material: %s\n", s.material_name); | ||||||||||||||||||||||
| Serial.printf(" color: #%s\n", os.color_hex); | ||||||||||||||||||||||
| Serial.printf(" nozzle: %d-%d°C\n", s.min_print_temp, s.max_print_temp); | ||||||||||||||||||||||
| Serial.printf(" version: %s\n", os.version); | ||||||||||||||||||||||
| Serial.println("---------------------------------------"); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ApplicationManager::getInstance().sendMessage(msg); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| TagScanResult NFCManager::classifyTag(const uint8_t* uid, uint8_t uid_length) { | ||||||||||||||||||||||
| TagScanResult result; | ||||||||||||||||||||||
| result.present = true; | ||||||||||||||||||||||
|
|
@@ -1651,6 +1772,91 @@ bool NFCManager::executeWrite(const NFCWriteRequest& request) { | |||||||||||||||||||||
| return ok; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Handle WRITE_OPENSPOOL — write NDEF-wrapped JSON payload to NTAG pages | ||||||||||||||||||||||
| if (request.type == NFCWriteType::WRITE_OPENSPOOL) { | ||||||||||||||||||||||
| if (xSemaphoreTake(tagMutex, pdMS_TO_TICKS(100)) != pdTRUE) { | ||||||||||||||||||||||
| Serial.println("NFCManager: WRITE_OPENSPOOL - could not acquire tagMutex"); | ||||||||||||||||||||||
| return false; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| if (request.expected_spool_id[0] != '\0' && | ||||||||||||||||||||||
| strcmp(currentSpool.spool_id, request.expected_spool_id) != 0) { | ||||||||||||||||||||||
| xSemaphoreGive(tagMutex); | ||||||||||||||||||||||
| Serial.println("NFCManager: WRITE_OPENSPOOL rejected - UID mismatch"); | ||||||||||||||||||||||
| return false; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| xSemaphoreGive(tagMutex); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (!rawWritePending_ || rawWriteBufferSize_ == 0) { | ||||||||||||||||||||||
| Serial.println("NFCManager: WRITE_OPENSPOOL - no raw data available"); | ||||||||||||||||||||||
| return false; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const uint8_t* jsonPayload = rawWriteBuffer_; | ||||||||||||||||||||||
| uint16_t payloadLen = (uint16_t)rawWriteBufferSize_; | ||||||||||||||||||||||
| rawWritePending_ = false; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const char* mime = "application/json"; | ||||||||||||||||||||||
| uint8_t mimeLen = (uint8_t)strlen(mime); | ||||||||||||||||||||||
| bool sr = (payloadLen <= 255); | ||||||||||||||||||||||
| uint8_t ndefHeaderSize = 2 + (sr ? 1 : 4); | ||||||||||||||||||||||
| uint16_t ndefRecordLen = ndefHeaderSize + mimeLen + payloadLen; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| bool longTlv = (ndefRecordLen > 254); | ||||||||||||||||||||||
| uint16_t tlvHeaderSize = 1 + (longTlv ? 3 : 1); | ||||||||||||||||||||||
| uint16_t totalSize = tlvHeaderSize + ndefRecordLen + 1; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| uint8_t ndefBuf[256]; | ||||||||||||||||||||||
| if (totalSize > sizeof(ndefBuf)) { | ||||||||||||||||||||||
| Serial.printf("NFCManager: WRITE_OPENSPOOL - NDEF too large (%u bytes)\n", totalSize); | ||||||||||||||||||||||
| return false; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| uint16_t idx = 0; | ||||||||||||||||||||||
| ndefBuf[idx++] = 0x03; | ||||||||||||||||||||||
| if (longTlv) { | ||||||||||||||||||||||
| ndefBuf[idx++] = 0xFF; | ||||||||||||||||||||||
| ndefBuf[idx++] = (uint8_t)(ndefRecordLen >> 8); | ||||||||||||||||||||||
| ndefBuf[idx++] = (uint8_t)(ndefRecordLen & 0xFF); | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| ndefBuf[idx++] = (uint8_t)ndefRecordLen; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| uint8_t ndefFlags = 0xC0 | 0x02; | ||||||||||||||||||||||
| if (sr) ndefFlags |= 0x10; | ||||||||||||||||||||||
| ndefBuf[idx++] = ndefFlags; | ||||||||||||||||||||||
| ndefBuf[idx++] = mimeLen; | ||||||||||||||||||||||
| if (sr) { | ||||||||||||||||||||||
| ndefBuf[idx++] = (uint8_t)payloadLen; | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| ndefBuf[idx++] = (uint8_t)((payloadLen >> 24) & 0xFF); | ||||||||||||||||||||||
| ndefBuf[idx++] = (uint8_t)((payloadLen >> 16) & 0xFF); | ||||||||||||||||||||||
| ndefBuf[idx++] = (uint8_t)((payloadLen >> 8) & 0xFF); | ||||||||||||||||||||||
| ndefBuf[idx++] = (uint8_t)(payloadLen & 0xFF); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| memcpy(ndefBuf + idx, mime, mimeLen); | ||||||||||||||||||||||
| idx += mimeLen; | ||||||||||||||||||||||
| memcpy(ndefBuf + idx, jsonPayload, payloadLen); | ||||||||||||||||||||||
| idx += payloadLen; | ||||||||||||||||||||||
| ndefBuf[idx++] = 0xFE; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| while (idx % 4 != 0) ndefBuf[idx++] = 0x00; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| uint8_t pagesNeeded = (uint8_t)(idx / 4); | ||||||||||||||||||||||
| Serial.printf("NFCManager: WRITE_OPENSPOOL - writing %u bytes (%u pages)\n", idx, pagesNeeded); | ||||||||||||||||||||||
| bool ok = connection_->writeISO14443Pages(4, pagesNeeded, ndefBuf, idx); | ||||||||||||||||||||||
| if (ok) { | ||||||||||||||||||||||
| Serial.printf("NFCManager: WRITE_OPENSPOOL succeeded (%u bytes, %u pages)\n", idx, pagesNeeded); | ||||||||||||||||||||||
| if (xSemaphoreTake(tagMutex, pdMS_TO_TICKS(100)) == pdTRUE) { | ||||||||||||||||||||||
| currentSpool.present = false; | ||||||||||||||||||||||
| xSemaphoreGive(tagMutex); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| Serial.println("NFCManager: WRITE_OPENSPOOL failed"); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| return ok; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Handle WRITE_ATOMIC — build complete CBOR map from sidecar fields, write once | ||||||||||||||||||||||
| if (request.type == NFCWriteType::WRITE_ATOMIC) { | ||||||||||||||||||||||
| if (!atomicWriteFields_.pending) { | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Deep nesting increases cognitive complexity.
The OpenSpool detection logic adds another level of nesting (up to 13 levels per static analysis). Consider extracting the OpenSpool NDEF check into a helper function to match the structure of
tigerTagCheckMagicand improve maintainability.🧰 Tools
🪛 Clang (14.0.6)
[note] 422-422: +10, including nesting penalty of 9, nesting level increased to 10
(clang)
[note] 425-425: +11, including nesting penalty of 10, nesting level increased to 11
(clang)
[note] 428-428: +12, including nesting penalty of 11, nesting level increased to 12
(clang)
[note] 430-430: +1, nesting level increased to 12
(clang)
[note] 440-440: +12, including nesting penalty of 11, nesting level increased to 12
(clang)
[note] 444-444: +1, nesting level increased to 12
(clang)
[note] 452-452: +13, including nesting penalty of 12, nesting level increased to 13
(clang)
[note] 460-460: +12, including nesting penalty of 11, nesting level increased to 12
(clang)
[warning] 424-424: variable 'jsonMimeLen' is not initialized
(cppcoreguidelines-init-variables)
[warning] 427-427: variable 'osPayloadLen' is not initialized
(cppcoreguidelines-init-variables)
[warning] 428-428: if with identical then and else branches
(bugprone-branch-clone)
[note] 430-430: else branch starts here
(clang)
[warning] 436-436: variable 'osOffset' is not initialized
(cppcoreguidelines-init-variables)
[warning] 438-438: variable 'osBytes' is not initialized
(cppcoreguidelines-init-variables)
[warning] 445-445: variable 'osStartPage' is not initialized
(cppcoreguidelines-init-variables)
[warning] 446-446: variable 'osPagesNeeded' is not initialized
(cppcoreguidelines-init-variables)
[warning] 449-449: variable 'osExtRead' is not initialized
(cppcoreguidelines-init-variables)
[warning] 451-451: variable 'osOffInPage' is not initialized
(cppcoreguidelines-init-variables)
🤖 Prompt for AI Agents