| 454 | } |
| 455 | |
| 456 | String crc32File(FS &fs, String filepath) { |
| 457 | if (!fs.exists(filepath)) return ""; |
| 458 | String txt = readSmallFile(fs, filepath); |
| 459 | // derived from |
| 460 | // https://techoverflow.net/2022/08/05/how-to-compute-crc32-with-ethernet-polynomial-0x04c11db7-on-esp32-crc-h/ |
| 461 | uint32_t romCRC = |
| 462 | (~esp_rom_crc32_le((uint32_t)~(0xffffffff), (const uint8_t *)txt.c_str(), txt.length())) ^ 0xffffffff; |
| 463 | |
| 464 | char s[18] = {0}; |
| 465 | char crcBytes[4] = {0}; |
| 466 | memcpy(crcBytes, &romCRC, sizeof(uint32_t)); |
| 467 | snprintf(s, sizeof(s), "%02X%02X%02X%02X\n", crcBytes[3], crcBytes[2], crcBytes[1], crcBytes[0]); |
| 468 | return (String(s)); |
| 469 | } |
| 470 | |
| 471 | /*************************************************************************************** |
| 472 | ** Function name: sortList |
no test coverage detected