Skip to content

Commit

Permalink
[SD] Push #offline config into the PIO build ini for one platform only
Browse files Browse the repository at this point in the history
  • Loading branch information
brentru committed Nov 25, 2024
1 parent ebb269c commit a81fa03
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 58 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ lib_compat_mode = soft ; can be strict once pio detects SleepyDog on RP2040
extends = common:esp32
board = esp32dev
board_build.partitions = default_8MB.csv
build_flags = -DARDUINO_ESP32_DEV
build_flags = -DARDUINO_ESP32_DEV -DOFFLINE_MODE_DEBUG
board_build.filesystem = littlefs
upload_speed = 921600

Expand Down
1 change: 0 additions & 1 deletion src/Wippersnapper_V2.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#define WIPPERSNAPPER_V2_H

// Debug Flags
#define OFFLINE_MODE_DEBUG 1 ///< Debug flag for offline mode (read via serial)
// #DEBUG_PROFILE 1 ///< Enable debug output for function profiling

// Cpp STD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Wippersnapper_Manager manager;
#define API_PIN 0

void setup() {
// NOTE: Provisioning must occur prior to serial init.
manager.checkAPIVersion(API_PIN);
// NOTE: Provisioning must occur prior to serial init.h
manager.checkAPIVersion(API_PIN);
manager.provision();

Serial.begin(115200);
Expand Down
37 changes: 37 additions & 0 deletions src/Wippersnapper_demo_wokwi.ino.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 1 "/var/folders/ff/dmzflvf52tq9kzvt6g8jglxw0000gn/T/tmprced9hfl"
#include <Arduino.h>
# 1 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo_wokwi.ino"
# 14 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo_wokwi.ino"
#define IO_USERNAME "brubell"
#define IO_KEY "YOUR_AIO_KEY"

#define WIFI_SSID "Wokwi-GUEST"
#define WIFI_PASS ""

#define WS_DEBUG

#define API_PIN 0
#include "ws_manager.h"


Wippersnapper_Manager manager;
Wippersnapper_WiFiV2 wipper(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, "io.adafruit.com", 8883);
void setup();
void loop();
#line 30 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo_wokwi.ino"
void setup() {

manager.checkAPIVersion(API_PIN);
manager.provision();

Serial.begin(115200);

Serial.println("Adafruit Wippersnapper API Manager Demo");
Serial.print("Running Wippersnapper API Version: ");
Serial.println(manager.getAPIVersion());
manager.connect();
}

void loop() {
manager.run();
}
46 changes: 0 additions & 46 deletions src/Wippersnapper_demo_wokwi.ino.skip

This file was deleted.

22 changes: 14 additions & 8 deletions src/provisioning/sdcard/ws_sdcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ws_sdcard::ws_sdcard() {
mode_offline = false;
_wokwi_runner = false;
_use_test_data = false;
}

/**************************************************************************/
Expand Down Expand Up @@ -172,16 +173,21 @@ bool ws_sdcard::parseConfigFile() {

// Attempt to open and deserialize the JSON config file
DeserializationError error;
#ifndef OFFLINE_MODE_DEBUG
// Read the config file from the SD card
file_config = _sd.open("config.json", FILE_READ);
error = deserializeJson(doc, file_config, max_json_len);
#else
#ifdef OFFLINE_MODE_DEBUG
// Test Mode - do not use the SD card, use test data instead!
if (_use_test_data)
if (_use_test_data == true) {
WS_DEBUG_PRINTLN("[SD] Using SERIAL INPUT for JSON config...");
error = deserializeJson(doc, _serialInput.c_str(), max_json_len);
else
}
else {
WS_DEBUG_PRINTLN("[SD] Using TEST DATA for JSON config...");
error = deserializeJson(doc, json_test_data, max_json_len);
}
#else
WS_DEBUG_PRINTLN("[SD] Opening config.json FILE...");
file_config = _sd.open("config.json", FILE_READ);
// TODO: Unimplemented
// error = deserializeJson(doc, file_config, max_json_len);
#endif

// If the JSON document failed to deserialize - halt the running device and
Expand Down Expand Up @@ -459,7 +465,7 @@ bool ws_sdcard::waitForSerialConfig() {
// 2. Provide a JSON string via the hardware's serial input
// 3. Use a test JSON string - for debugging purposes ONLY

_use_test_data = false;
_use_test_data = true;
json_test_data = "{"
"\"exportVersion\": \"1.0.0\","
"\"exportedBy\": \"tester\","
Expand Down

0 comments on commit a81fa03

Please sign in to comment.