Skip to content

Commit

Permalink
Add support for XRP status on removable drive
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhiquan Yeo committed Aug 24, 2023
1 parent 3fc84f9 commit e736ae4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <Arduino.h>
#include <ArduinoJson.h>
#include <LittleFS.h>
#include <SingleFileDrive.h>
#include <WebServer.h>
#include <WebSockets4WebServer.h>
#include <WebSocketsServer.h>
Expand Down Expand Up @@ -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");
// }
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e736ae4

Please sign in to comment.