Skip to content

Commit a81fa03

Browse files
committed
[SD] Push #offline config into the PIO build ini for one platform only
1 parent ebb269c commit a81fa03

File tree

6 files changed

+54
-58
lines changed

6 files changed

+54
-58
lines changed

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ lib_compat_mode = soft ; can be strict once pio detects SleepyDog on RP2040
130130
extends = common:esp32
131131
board = esp32dev
132132
board_build.partitions = default_8MB.csv
133-
build_flags = -DARDUINO_ESP32_DEV
133+
build_flags = -DARDUINO_ESP32_DEV -DOFFLINE_MODE_DEBUG
134134
board_build.filesystem = littlefs
135135
upload_speed = 921600
136136

src/Wippersnapper_V2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#define WIPPERSNAPPER_V2_H
2020

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

2524
// Cpp STD

src/Wippersnapper_demo.ino renamed to src/Wippersnapper_demo.ino.skip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Wippersnapper_Manager manager;
2525
#define API_PIN 0
2626

2727
void setup() {
28-
// NOTE: Provisioning must occur prior to serial init.
29-
manager.checkAPIVersion(API_PIN);
28+
// NOTE: Provisioning must occur prior to serial init.h
29+
manager.checkAPIVersion(API_PIN);
3030
manager.provision();
3131

3232
Serial.begin(115200);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 1 "/var/folders/ff/dmzflvf52tq9kzvt6g8jglxw0000gn/T/tmprced9hfl"
2+
#include <Arduino.h>
3+
# 1 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo_wokwi.ino"
4+
# 14 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo_wokwi.ino"
5+
#define IO_USERNAME "brubell"
6+
#define IO_KEY "YOUR_AIO_KEY"
7+
8+
#define WIFI_SSID "Wokwi-GUEST"
9+
#define WIFI_PASS ""
10+
11+
#define WS_DEBUG
12+
13+
#define API_PIN 0
14+
#include "ws_manager.h"
15+
16+
17+
Wippersnapper_Manager manager;
18+
Wippersnapper_WiFiV2 wipper(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, "io.adafruit.com", 8883);
19+
void setup();
20+
void loop();
21+
#line 30 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo_wokwi.ino"
22+
void setup() {
23+
24+
manager.checkAPIVersion(API_PIN);
25+
manager.provision();
26+
27+
Serial.begin(115200);
28+
29+
Serial.println("Adafruit Wippersnapper API Manager Demo");
30+
Serial.print("Running Wippersnapper API Version: ");
31+
Serial.println(manager.getAPIVersion());
32+
manager.connect();
33+
}
34+
35+
void loop() {
36+
manager.run();
37+
}

src/Wippersnapper_demo_wokwi.ino.skip

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/provisioning/sdcard/ws_sdcard.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ws_sdcard::ws_sdcard() {
2323
mode_offline = false;
2424
_wokwi_runner = false;
25+
_use_test_data = false;
2526
}
2627

2728
/**************************************************************************/
@@ -172,16 +173,21 @@ bool ws_sdcard::parseConfigFile() {
172173

173174
// Attempt to open and deserialize the JSON config file
174175
DeserializationError error;
175-
#ifndef OFFLINE_MODE_DEBUG
176-
// Read the config file from the SD card
177-
file_config = _sd.open("config.json", FILE_READ);
178-
error = deserializeJson(doc, file_config, max_json_len);
179-
#else
176+
#ifdef OFFLINE_MODE_DEBUG
180177
// Test Mode - do not use the SD card, use test data instead!
181-
if (_use_test_data)
178+
if (_use_test_data == true) {
179+
WS_DEBUG_PRINTLN("[SD] Using SERIAL INPUT for JSON config...");
182180
error = deserializeJson(doc, _serialInput.c_str(), max_json_len);
183-
else
181+
}
182+
else {
183+
WS_DEBUG_PRINTLN("[SD] Using TEST DATA for JSON config...");
184184
error = deserializeJson(doc, json_test_data, max_json_len);
185+
}
186+
#else
187+
WS_DEBUG_PRINTLN("[SD] Opening config.json FILE...");
188+
file_config = _sd.open("config.json", FILE_READ);
189+
// TODO: Unimplemented
190+
// error = deserializeJson(doc, file_config, max_json_len);
185191
#endif
186192

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

462-
_use_test_data = false;
468+
_use_test_data = true;
463469
json_test_data = "{"
464470
"\"exportVersion\": \"1.0.0\","
465471
"\"exportedBy\": \"tester\","

0 commit comments

Comments
 (0)