Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix USB-MSC not re-attaching #667

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions src/provisioning/tinyusb/Wippersnapper_FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3_REVTFT) || \
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2_REVTFT) || \
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_N4R2)
#include "print_dependencies.h"
#include "Wippersnapper_FS.h"
#include "print_dependencies.h"
// On-board external flash (QSPI or SPI) macros should already
// defined in your board variant if supported
// - EXTERNAL_FLASH_USE_QSPI
Expand Down Expand Up @@ -92,11 +92,11 @@ bool setVolumeLabel() {
/**************************************************************************/
Wippersnapper_FS::Wippersnapper_FS() {
#if PRINT_DEPENDENCIES
WS_DEBUG_PRINTLN("Build Dependencies:");
WS_DEBUG_PRINTLN("*********************");
WS_DEBUG_PRINTLN(project_dependencies);
WS_DEBUG_PRINTLN("*********************");
WS_PRINTER.flush();
WS_DEBUG_PRINTLN("Build Dependencies:");
WS_DEBUG_PRINTLN("*********************");
WS_DEBUG_PRINTLN(project_dependencies);
WS_DEBUG_PRINTLN("*********************");
WS_PRINTER.flush();
#endif
// Detach USB device during init.
TinyUSBDevice.detach();
Expand Down Expand Up @@ -291,15 +291,15 @@ bool Wippersnapper_FS::createBootFile() {
bootFile.println(project_dependencies);
#endif

// Print ESP-specific info to boot file
#ifdef ARDUINO_ARCH_ESP32
// Print ESP-specific info to boot file
#ifdef ARDUINO_ARCH_ESP32
// Get version of ESP-IDF
bootFile.print("ESP-IDF Version: ");
bootFile.println(ESP.getSdkVersion());
// Get version of this core
bootFile.print("ESP32 Core Version: ");
bootFile.println(ESP.getCoreVersion());
#endif
#endif

bootFile.flush();
bootFile.close();
Expand Down Expand Up @@ -327,19 +327,13 @@ void Wippersnapper_FS::createSecretsFile() {
strcpy(secretsConfig.network.pass, "YOUR_WIFI_PASS_HERE");
secretsConfig.status_pixel_brightness = 0.2;

// Create and fill JSON document from secretsConfig
// Serialize the struct to a JSON document
JsonDocument doc;
doc.set(secretsConfig);

// Serialize JSON to file
serializeJsonPretty(doc, secretsFile);

// Flush and close file
secretsFile.flush();
secretsFile.close();
delay(2500);

// Signal to user that action must be taken (edit secrets.json)
writeToBootOut(
"ERROR: Please edit the secrets.json file. Then, reset your board.\n");
#ifdef USE_DISPLAY
Expand All @@ -349,6 +343,9 @@ void Wippersnapper_FS::createSecretsFile() {
"Please edit it to reflect your Adafruit IO and network credentials. "
"When you're done, press RESET on the board.");
#endif
// Re-attach the USB device for file access
delay(500);
initUSBMSC();
fsHalt("ERROR: Please edit the secrets.json file. Then, reset your board.");
}

Expand Down
Loading