@@ -36,7 +36,7 @@ constexpr boolean createFakeFiles = true;
36
36
boolean done = false ;
37
37
volatile boolean connected = false ;
38
38
39
- USBStorage thumbDrive = USBStorage() ;
39
+ USBStorage thumbDrive;
40
40
41
41
42
42
void addSomeFakeFiles (Folder * folder){
@@ -72,14 +72,6 @@ void move(Folder * source, Folder * dest){
72
72
}
73
73
74
74
75
- void onConnected (){
76
- connected = true ;
77
- }
78
-
79
- void onDisconnected (){
80
- connected = false ;
81
- }
82
-
83
75
84
76
85
77
@@ -89,46 +81,50 @@ void setup(){
89
81
Serial.begin (115200 );
90
82
while (!Serial);
91
83
92
- Serial.println (" USB Thumb Drive has been inserted" );
93
- bool thumbMounted = thumbDrive.begin (FS_FAT);
94
- if (thumbMounted){
95
- Serial.println (" USB Thumb Drive has been mounted" );
84
+ // toggle this to to true to enable logging output
85
+ Arduino_UnifiedStorage::loggingEnabled = false ;
96
86
97
- Folder thumbRoot = thumbDrive.getRootFolder ();
98
- String folderName = " InternalBackup_" + String (millis ());
99
- Serial.println (folderName);
100
- Folder backupFolder = thumbRoot.createSubfolder (folderName);
87
+ thumbDrive = USBStorage ();
101
88
102
- int partitionIndex = 0 ;
89
+ bool thumbMounted = thumbDrive.begin (FS_FAT);
90
+ if (thumbMounted){
91
+ Serial.println (" USB Thumb Drive has been mounted" );
103
92
104
- std::vector<Partition> partitions = InternalStorage::readPartitions ();
105
- Serial.println (" Found " + String (partitions.size ()) + " partitions on internalStorage \n " );
93
+ Folder thumbRoot = thumbDrive.getRootFolder ();
94
+ String folderName = " InternalBackup_" + String (millis ());
95
+ Serial.println (folderName);
96
+ Folder backupFolder = thumbRoot.createSubfolder (folderName);
106
97
107
- for (auto part: partitions){
108
- partitionIndex++;
109
- const char * partitionName = createPartitionName (partitionIndex);
110
- Folder thisPartitionBackupFolder = backupFolder.createSubfolder (partitionName);
98
+ int partitionIndex = 0 ;
111
99
112
- InternalStorage thisPartition = InternalStorage (partitionIndex, partitionName, part. fileSystemType );
113
- thisPartition. begin ( );
100
+ std::vector<Partition> partitions = InternalStorage::readPartitions ( );
101
+ Serial. println ( " Found " + String (partitions. size ()) + " partitions on internalStorage \n " );
114
102
115
- Folder partitionRootFolder = thisPartition.getRootFolder ();
116
- Serial.println (partitionRootFolder.getPathAsString ());
103
+ for (auto part: partitions){
104
+ partitionIndex++;
105
+ const char * partitionName = createPartitionName (partitionIndex);
106
+ Folder thisPartitionBackupFolder = backupFolder.createSubfolder (partitionName);
117
107
118
- if (createFakeFiles){
119
- addSomeFakeFiles (&partitionRootFolder);
120
- }
108
+ InternalStorage thisPartition = InternalStorage (partitionIndex, partitionName, part.fileSystemType );
109
+ thisPartition.begin ();
121
110
122
- move (&partitionRootFolder, &thisPartitionBackupFolder);
123
- thisPartition.unmount ();
124
- }
111
+ Folder partitionRootFolder = thisPartition.getRootFolder ();
112
+ Serial.println (partitionRootFolder.getPathAsString ());
125
113
126
- thumbDrive.unmount ();
127
-
114
+ if (createFakeFiles){
115
+ addSomeFakeFiles (&partitionRootFolder);
116
+ }
128
117
129
- Serial.println (" DONE, you can restart the board now" );
118
+ move (&partitionRootFolder, &thisPartitionBackupFolder);
119
+ thisPartition.unmount ();
130
120
}
131
121
122
+ thumbDrive.unmount ();
123
+
124
+
125
+ Serial.println (" DONE, you can restart the board now" );
126
+ }
127
+
132
128
133
129
}
134
130
0 commit comments