| 422 | } |
| 423 | |
| 424 | void processXferComplete(struct espXferComplete* xfc, bool local) { |
| 425 | if (config.runStatus == RUNSTATUS_STOP) { |
| 426 | return; |
| 427 | } |
| 428 | char buffer[64]; |
| 429 | sprintf(buffer, "%02X%02X%02X%02X%02X%02X%02X%02X reports xfer complete\r\n\0", xfc->src[7], xfc->src[6], xfc->src[5], xfc->src[4], xfc->src[3], xfc->src[2], xfc->src[1], xfc->src[0]); |
| 430 | wsLog((String)buffer); |
| 431 | |
| 432 | if (local) { |
| 433 | Serial.printf("<XFC %02X%02X%02X%02X%02X%02X%02X%02X\r\n", xfc->src[7], xfc->src[6], xfc->src[5], xfc->src[4], xfc->src[3], xfc->src[2], xfc->src[1], xfc->src[0]); |
| 434 | } else { |
| 435 | Serial.printf("<REMOTE XFC %02X%02X%02X%02X%02X%02X%02X%02X\r\n", xfc->src[7], xfc->src[6], xfc->src[5], xfc->src[4], xfc->src[3], xfc->src[2], xfc->src[1], xfc->src[0]); |
| 436 | } |
| 437 | |
| 438 | time_t now; |
| 439 | time(&now); |
| 440 | |
| 441 | char dst_path[64]; |
| 442 | sprintf(dst_path, "/current/%02X%02X%02X%02X%02X%02X%02X%02X.raw\0", xfc->src[7], xfc->src[6], xfc->src[5], xfc->src[4], xfc->src[3], xfc->src[2], xfc->src[1], xfc->src[0]); |
| 443 | |
| 444 | uint8_t md5bytes[16]; |
| 445 | PendingItem* queueItem = getQueueItem(xfc->src); |
| 446 | if (queueItem != nullptr) { |
| 447 | if (contentFS->exists(dst_path) && contentFS->exists(queueItem->filename)) { |
| 448 | contentFS->remove(dst_path); |
| 449 | } |
| 450 | if (contentFS->exists(queueItem->filename)) { |
| 451 | uint8_t dataType = queueItem->pendingdata.availdatainfo.dataType; |
| 452 | if (config.preview && dataType != DATATYPE_FW_UPDATE && dataType != DATATYPE_NOUPDATE) { |
| 453 | contentFS->rename(queueItem->filename, String(dst_path)); |
| 454 | } |
| 455 | else { |
| 456 | if (queueItem->pendingdata.availdatainfo.dataType != DATATYPE_FW_UPDATE) contentFS->remove(queueItem->filename); |
| 457 | } |
| 458 | } |
| 459 | memcpy(md5bytes, &queueItem->pendingdata.availdatainfo.dataVer, sizeof(uint64_t)); |
| 460 | memset(md5bytes + sizeof(uint64_t), 0, 16 - sizeof(uint64_t)); |
| 461 | dequeueItem(xfc->src); |
| 462 | } |
| 463 | |
| 464 | tagRecord* taginfo = tagRecord::findByMAC(xfc->src); |
| 465 | if (taginfo != nullptr) { |
| 466 | clearPending(taginfo); |
| 467 | memcpy(taginfo->md5, md5bytes, sizeof(md5bytes)); |
| 468 | taginfo->updateCount++; |
| 469 | taginfo->updateLast = now; |
| 470 | taginfo->pendingCount = countQueueItem(xfc->src); |
| 471 | taginfo->wakeupReason = 0; |
| 472 | if (taginfo->contentMode == 12 && local == false) { |
| 473 | if (contentFS->exists(dst_path)) { |
| 474 | contentFS->remove(dst_path); |
| 475 | } |
| 476 | } |
| 477 | if (taginfo->contentMode == 5 || taginfo->contentMode == 17 || taginfo->contentMode == 18) { |
| 478 | popTagInfo(xfc->src); |
| 479 | taginfo = tagRecord::findByMAC(xfc->src); |
| 480 | taginfo->nextupdate = now; |
| 481 | } |
no test coverage detected