From bb9785494bfbfa484ca485dab9d5e955b552d53f Mon Sep 17 00:00:00 2001 From: Zhiquan Yeo Date: Thu, 24 Aug 2023 21:10:21 -0400 Subject: [PATCH] Add support for XRP status on removable drive (#15) Co-authored-by: Zhiquan Yeo --- src/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 345ca8a..c904f89 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include #include #include @@ -29,6 +31,18 @@ int _baselineUsedHeap = 0; unsigned long _avgLoopTimeUs = 0; unsigned long _loopTimeMeasurementCount = 0; +// Generate the status text file +void writeStatusToDisk() { + File f = LittleFS.open("/status.txt", "w"); + f.printf("Chip ID: %s\n", chipID); + f.printf("WiFi Mode: %s\n", "AP"); + f.printf("AP SSID: %s\n", DEFAULT_SSID); + f.printf("AP PASS: %s\n", "xrp-wpilib"); + + f.printf("IP Address: %s\n", WiFi.localIP().toString().c_str()); + f.close(); +} + // void handleIndexRoute() { // webServer.send(200, "text/plain", "You probably want the WS interface on /wpilibws"); // } @@ -96,6 +110,7 @@ void setup() { sprintf(DEFAULT_SSID, "XRP-%s", chipID); Serial.begin(115200); + LittleFS.begin(); // Set up the I2C pins Wire1.setSCL(19); @@ -151,6 +166,10 @@ void setup() { _lastMessageStatusPrint = millis(); _baselineUsedHeap = rp2040.getUsedHeap(); + + // Write current status file + writeStatusToDisk(); + singleFileDrive.begin("status.txt", "XRP-Status.txt"); } int lastCheckedNumClients = 0;