Skip to content

Commit 7f2e8e3

Browse files
fixed logging
1 parent 9f2b611 commit 7f2e8e3

16 files changed

+253
-222
lines changed

examples/Logger/Logger.ino

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ void performUpdate() {
9797
backingUP = true;
9898
unsigned lastUpdateBytes = lastUpdateFile.readAsString().toInt(); // Read the last update size from the file
9999

100-
debugPrint("Last update bytes: " + String(lastUpdateBytes));
100+
Arduino_UnifiedStorage::debugPrint("Last update bytes: " + String(lastUpdateBytes));
101101

102102
if (lastUpdateBytes >= bytesWritten) {
103-
debugPrint("No new data to copy. ");
103+
Arduino_UnifiedStorage::debugPrint("No new data to copy. ");
104104
backupFile.close();
105105
lastUpdateFile.close();
106106
backingUP = false;
@@ -109,14 +109,14 @@ void performUpdate() {
109109

110110
logFile.seek(lastUpdateBytes); // Move the file pointer to the last update position
111111
unsigned long totalBytesToMove = bytesWritten - lastUpdateBytes;
112-
debugPrint("New update bytes: " + String(totalBytesToMove));
112+
Arduino_UnifiedStorage::debugPrint("New update bytes: " + String(totalBytesToMove));
113113

114114
uint8_t* buffer = new uint8_t[totalBytesToMove];
115115

116116
size_t bytesRead = logFile.read(buffer, totalBytesToMove);
117117
size_t bytesMoved = backupFile.write(buffer, bytesRead); // Only write the bytes that haven't been backed up yet
118118

119-
debugPrint("Successfully copied " + String(bytesMoved) + " new bytes. ");
119+
Arduino_UnifiedStorage::debugPrint("Successfully copied " + String(bytesMoved) + " new bytes. ");
120120

121121
lastUpdateFile.changeMode(FileMode::WRITE); // Open the last update file in write mode
122122
lastUpdateFile.write(String(lastUpdateBytes + bytesMoved)); // Update the last update size
@@ -138,32 +138,32 @@ void performUpdate() {
138138
void backupToUSB() {
139139
if(usbAvailable && !usbIntialized){
140140
usbStorage.begin();
141-
debugPrint("First drive insertion, creating folders... ");
141+
Arduino_UnifiedStorage::debugPrint("First drive insertion, creating folders... ");
142142
Folder usbRoot = usbStorage.getRootFolder();
143143
String folderName = "LoggerBackup" + String(random(9999));
144144
backupFolder = usbRoot.createSubfolder(folderName);
145-
debugPrint("Successfully created backup folder: " + backupFolder.getPathAsString());
145+
Arduino_UnifiedStorage::debugPrint("Successfully created backup folder: " + backupFolder.getPathAsString());
146146
usbStorage.unmount();
147147
usbIntialized = true;
148148
}
149149
else if(usbAvailable && usbIntialized) {
150-
debugPrint("USB Mass storage is available ");
150+
Arduino_UnifiedStorage::debugPrint("USB Mass storage is available ");
151151
delay(100);
152152
if (!usbStorage.isMounted()) {
153153

154-
debugPrint("Mounting USB Mass Storage ");
154+
Arduino_UnifiedStorage::debugPrint("Mounting USB Mass Storage ");
155155
digitalWrite(USB_MOUNTED_LED, LOW);
156156
if(usbStorage.begin()){
157157
performUpdate();
158158
}
159159

160160
} else if (usbStorage.isMounted()) {
161-
debugPrint("USB Mass storage is connected, performing update ");
161+
Arduino_UnifiedStorage::debugPrint("USB Mass storage is connected, performing update ");
162162
performUpdate();
163163

164164
}
165165
} else {
166-
debugPrint("USB Mass storage is not available ");
166+
Arduino_UnifiedStorage::debugPrint("USB Mass storage is not available ");
167167
}
168168

169169

@@ -185,17 +185,17 @@ void setup() {
185185
usbStorage.onDisconnect(disconnectionCallback);
186186

187187
pinMode(USB_MOUNTED_LED, OUTPUT);
188-
debugPrint("Formatting internal storage... ");
188+
Arduino_UnifiedStorage::debugPrint("Formatting internal storage... ");
189189
int formatted = internalStorage.format(FS_LITTLEFS);
190-
debugPrint("QSPI Format status: " + String(formatted));
190+
Arduino_UnifiedStorage::debugPrint("QSPI Format status: " + String(formatted));
191191

192192

193193

194194
if (!internalStorage.begin()) {
195-
debugPrint("Failed to initialize internal storage ");
195+
Arduino_UnifiedStorage::debugPrint("Failed to initialize internal storage ");
196196
return;
197197
} else {
198-
debugPrint("Initialized storage ");
198+
Arduino_UnifiedStorage::debugPrint("Initialized storage ");
199199
}
200200

201201
}

extras/tests/TestExisting/TestExisting.ino

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,42 @@ void setup() {
2626

2727

2828
// Test copyTo
29-
debugPrint("Testing copyTo...");
29+
Arduino_UnifiedStorage::debugPrint("Testing copyTo...");
3030
Folder sourceFolder2 = root.createSubfolder("source_folder");
31-
debugPrint("Folder 1 created");
31+
Arduino_UnifiedStorage::debugPrint("Folder 1 created");
3232

33-
debugPrint("Trying to create a folder on top of an existing one... without overwrite");
33+
Arduino_UnifiedStorage::debugPrint("Trying to create a folder on top of an existing one... without overwrite");
3434
Folder sourceFolder3 = root.createSubfolder("source_folder");
3535

3636

37-
debugPrint("Trying to create a folder on top of an existing one... with overwrite");
37+
Arduino_UnifiedStorage::debugPrint("Trying to create a folder on top of an existing one... with overwrite");
3838
Folder sourceFolder4 = root.createSubfolder("source_folder", true);
3939

4040

4141

4242
Folder destinationFolder2 = root.createSubfolder("destination_folder");
43-
debugPrint("Folder 2 created");
43+
Arduino_UnifiedStorage::debugPrint("Folder 2 created");
4444

4545

4646

4747
bool copyResult = sourceFolder2.copyTo(destinationFolder2, true); // Overwrite if exists
4848
if (copyResult) {
49-
debugPrint("Copy successful");
49+
Arduino_UnifiedStorage::debugPrint("Copy successful");
5050
} else {
51-
debugPrint("Copy failed");
51+
Arduino_UnifiedStorage::debugPrint("Copy failed");
5252
}
5353

5454

5555
// Test moveTo
5656
Folder sourceFolder = root.createSubfolder("source");
5757
Folder destinationFolder = root.createSubfolder("destination");
5858

59-
debugPrint("Testing moveTo... ");
59+
Arduino_UnifiedStorage::debugPrint("Testing moveTo... ");
6060
bool moveResult = sourceFolder.moveTo(destinationFolder, true); // Overwrite if exists
6161
if (moveResult) {
62-
debugPrint("Move successful");
62+
Arduino_UnifiedStorage::debugPrint("Move successful");
6363
} else {
64-
debugPrint("Move failed");
64+
Arduino_UnifiedStorage::debugPrint("Move failed");
6565
}
6666

6767

@@ -75,10 +75,10 @@ void setup() {
7575

7676

7777
bool success = someFile.copyTo(someOtherFolder);
78-
debugPrint("trying to copy file without overwrite: " + String(success));
78+
Arduino_UnifiedStorage::debugPrint("trying to copy file without overwrite: " + String(success));
7979

8080
success = someFile.copyTo(someOtherFolder,true);
81-
debugPrint("trying to copy file with overwrite: " + String(success));
81+
Arduino_UnifiedStorage::debugPrint("trying to copy file with overwrite: " + String(success));
8282

8383
}
8484

0 commit comments

Comments
 (0)