fix OFFLINE requirement that is causing msc detach/attach after logging

This commit is contained in:
brentru 2025-04-11 16:17:32 -04:00
parent 49124174eb
commit eda059e13b
6 changed files with 7 additions and 14 deletions

View file

@ -12,7 +12,6 @@
#include "ws_adapters.h" #include "ws_adapters.h"
ws_adapter_wifi wipper; ws_adapter_wifi wipper;
#define WS_DEBUG // Enable debug output! #define WS_DEBUG // Enable debug output!
#define BUILD_OFFLINE_ONLY
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);

View file

@ -12,7 +12,6 @@
#include "ws_adapters.h" #include "ws_adapters.h"
ws_adapter_offline wipper; ws_adapter_offline wipper;
#define WS_DEBUG // Enable debug output! #define WS_DEBUG // Enable debug output!
#define BUILD_OFFLINE_ONLY
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);

View file

@ -434,7 +434,7 @@ platform = https://github.com/maxgerhardt/platform-raspberrypi.git#develop
board = adafruit_feather_adalogger board = adafruit_feather_adalogger
platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
board_build.filesystem_size = 0.5m board_build.filesystem_size = 0.5m
build_flags = -DUSE_TINYUSB -DBUILD_OFFLINE_ONLY build_flags = -DUSE_TINYUSB
; Once https://github.com/platformio/platformio-core > 6.1.11 these can be removed ; Once https://github.com/platformio/platformio-core > 6.1.11 these can be removed
lib_ignore = WiFiNINA, WiFi101, Adafruit Zero DMA Library lib_ignore = WiFiNINA, WiFi101, Adafruit Zero DMA Library

View file

@ -96,11 +96,9 @@ void Wippersnapper_V2::provision() {
if (WsV2._sdCardV2->isSDCardInitialized()) { if (WsV2._sdCardV2->isSDCardInitialized()) {
return; // SD card initialized, cede control back to loop() return; // SD card initialized, cede control back to loop()
} else { } else {
#ifdef BUILD_OFFLINE_ONLY
haltErrorV2("SD initialization failed.\nDo not reformat the card!\nIs the " haltErrorV2("SD initialization failed.\nDo not reformat the card!\nIs the "
"card correctly inserted?\nIs there a wiring/soldering " "card correctly inserted?\nIs there a wiring/soldering "
"problem\nIs the config.json file malformed?"); "problem\nIs the config.json file malformed?");
#endif
// SD card not initialized, so just continue with online-mode provisioning // SD card not initialized, so just continue with online-mode provisioning
} }

View file

@ -1,16 +1,16 @@
// Adafruit IO WipperSnapper // Adafruit IO WipperSnapper - Offline Mode
// USE ONLY WITH DEVICES WITH A NETWORK ADAPTER LIKE ESP32-x
// //
// Adafruit invests time and resources providing this open source code. // Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing // Please support Adafruit and open source hardware by purchasing
// products from Adafruit! // products from Adafruit!
// //
// Brent Rubell for Adafruit Industries, 2020-2025 // Brent Rubell for Adafruit Industries, 2025
// //
// All text above must be included in any redistribution. // All text above must be included in any redistribution.
#include "ws_adapters.h" #include "ws_adapters.h"
ws_adapter_wifi wipper; ws_adapter_offline wipper;
#define WS_DEBUG // Enable debug output! #define WS_DEBUG // Enable debug output!
void setup() { void setup() {

View file

@ -143,11 +143,6 @@ Wippersnapper_FS::Wippersnapper_FS() {
HaltFilesystem("FATAL ERROR: Could not write filesystem contents!"); HaltFilesystem("FATAL ERROR: Could not write filesystem contents!");
} }
// Initialize USB-MSC
#ifndef BUILD_OFFLINE_ONLY
InitUsbMsc();
#endif
// If we wrote a fresh secrets.json file, halt until user edits the file and // If we wrote a fresh secrets.json file, halt until user edits the file and
// RESETs the device Signal to user that action must be taken (edit // RESETs the device Signal to user that action must be taken (edit
// secrets.json) // secrets.json)
@ -683,6 +678,7 @@ void Wippersnapper_FS::WriteFileBoot(PGM_P str) {
/**************************************************************************/ /**************************************************************************/
void Wippersnapper_FS::HaltFilesystem(String msg) { void Wippersnapper_FS::HaltFilesystem(String msg) {
if (!_did_init_msc) { if (!_did_init_msc) {
WS_DEBUG_PRINTLN("HaltFilesystem: InitUsbMsc");
InitUsbMsc(); InitUsbMsc();
} }
TinyUSBDevice.attach(); TinyUSBDevice.attach();
@ -706,6 +702,7 @@ void Wippersnapper_FS::HaltFilesystem(String msg) {
void Wippersnapper_FS::HaltFilesystem(String msg, void Wippersnapper_FS::HaltFilesystem(String msg,
ws_led_status_t ledStatusColor) { ws_led_status_t ledStatusColor) {
if (!_did_init_msc) { if (!_did_init_msc) {
WS_DEBUG_PRINTLN("HaltFilesystem: InitUsbMsc");
InitUsbMsc(); InitUsbMsc();
} }
TinyUSBDevice.attach(); TinyUSBDevice.attach();