I wrote a simple sketch for the Opta that creates a new file in the root folder of a connected USB device and then writes inside it.
I planned to use the connection callback to immediately initialize the USB storage, but unfortunately it did not work. In fact the following sketch cannot create a new file:
Furthemore, I suspect the storage might not be initialized at all when using the above code, as a simple call to root.exists() in the loop would halt the execution causing a board reset.
If I instead move the storage initialization code in the loop() function, the sketch works as expected. I will attach the functioning sketch below for completeness:
I wrote a simple sketch for the Opta that creates a new file in the root folder of a connected USB device and then writes inside it.
I planned to use the connection callback to immediately initialize the USB storage, but unfortunately it did not work. In fact the following sketch cannot create a new file:
Click to expand
```cpp #includeFurthemore, I suspect the storage might not be initialized at all when using the above code, as a simple call to
root.exists()
in the loop would halt the execution causing a board reset.If I instead move the storage initialization code in the
loop()
function, the sketch works as expected. I will attach the functioning sketch below for completeness:Click to expand
```cpp #includeI did not find any mention of this behavior in the docs. If I can provide further details or assistance ping me!