| 63 | } // namespace |
| 64 | |
| 65 | void init() |
| 66 | { |
| 67 | Serial.begin(SERIAL_BAUD_RATE); |
| 68 | Serial.systemDebugOutput(true); |
| 69 | |
| 70 | Storage::Debug::listDevices(Serial); |
| 71 | |
| 72 | listSpiffsPartitions(); |
| 73 | |
| 74 | printPart(F("user0")); |
| 75 | |
| 76 | auto part = Storage::findPartition(F("user1")); |
| 77 | printPart(part); |
| 78 | Serial.println(_F("Writing some stuff to partition...")); |
| 79 | String s = F("Some test stuff to write..."); |
| 80 | part.write(32, s.c_str(), s.length() + 1); |
| 81 | uint8_t buf[32]; |
| 82 | os_get_random(buf, sizeof buf); |
| 83 | part.write(64, buf, sizeof buf); |
| 84 | printPart(part); |
| 85 | |
| 86 | Serial.println(_F("** Reading tests, repeat 3 times to show effect of caching (if any)")); |
| 87 | |
| 88 | Serial.println(_F("** Reading SysMem device (flash)")); |
| 89 | part = Storage::sysMem.editablePartitions().add(F("fs_app FLASH"), FS_app, {Storage::Partition::Type::data, 100}); |
| 90 | printPart(part); |
| 91 | printPart(part); |
| 92 | printPart(part); |
| 93 | |
| 94 | Serial.println(_F("** Reading SysMem device (RAM)")); |
| 95 | const size_t bufferSize{4096}; |
| 96 | auto buffer = std::make_unique<char[]>(bufferSize); |
| 97 | FS_app.readFlash(0, buffer.get(), bufferSize); |
| 98 | part = Storage::sysMem.editablePartitions().add(F("fs_app RAM"), {Storage::Partition::Type::data, 100}, |
| 99 | storage_size_t(buffer.get()), bufferSize); |
| 100 | printPart(part); |
| 101 | printPart(part); |
| 102 | printPart(part); |
| 103 | |
| 104 | Serial.println(_F("** Reading ProgMem device")); |
| 105 | part = |
| 106 | Storage::progMem.editablePartitions().add(F("fs_app PROGMEM"), FS_app, {Storage::Partition::Type::data, 100}); |
| 107 | printPart(part); |
| 108 | printPart(part); |
| 109 | printPart(part); |
| 110 | } |
nothing calls this directly
no test coverage detected