diff --git a/Control/data/favicon.ico b/Control/data/favicon.ico
new file mode 100644
index 0000000..cbaef43
Binary files /dev/null and b/Control/data/favicon.ico differ
diff --git a/Control/data/index.html b/Control/data/index.html
new file mode 100644
index 0000000..e9ed800
--- /dev/null
+++ b/Control/data/index.html
@@ -0,0 +1,304 @@
+
+
+
+
+ Rover Control Panel
+
+
+
+
+
+
+
+
+
+
+ ROVER COMMAND CENTER
+
+
+
+
+
+
Movement Control
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Sensor Data
+
+
+ -
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+ 28mm
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Control/src/main.cpp b/Control/src/main.cpp
index a76a5e3..6cc0738 100644
--- a/Control/src/main.cpp
+++ b/Control/src/main.cpp
@@ -8,9 +8,10 @@
#include
#include
#include
-#ifdef LOG_LOCAL_LEVEL
- #undef LOG_LOCAL_LEVEL
-#endif
+#include
+
+// Enable extra debugging info
+#undef LOG_LOCAL_LEVEL
#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
#include "esp_log.h"
@@ -32,313 +33,22 @@ Ticker ticker(returnSensorData, 500, 0, MILLIS);
int battery_voltage = 0;
int distance_travelled = 0;
-#pragma region HTMLsource
-char index_html[] PROGMEM = R"=====(
-
-
-
-
-Rover Control Panel
-
-
-
-
-
-
-
-ROVER COMMAND CENTER
-
-
-
-
-
-
Movement Control
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Sensor Data
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 28mm
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-)=====";
-#pragma endregion
-
void setup()
{
- esp_log_level_set("*", ESP_LOG_ERROR); // set all components to ERROR level
- esp_log_level_set("wifi", ESP_LOG_WARN); // enable WARN logs from WiFi stack
- esp_log_level_set("dhcpc", ESP_LOG_INFO); // enable INFO logs from DHCP client
+ esp_log_level_set("*", ESP_LOG_ERROR); // set all components to ERROR level
+ esp_log_level_set("wifi", ESP_LOG_WARN); // enable WARN logs from WiFi stack
+ esp_log_level_set("dhcpc", ESP_LOG_INFO); // enable INFO logs from DHCP client
Serial.begin(115200); // Set up hardware UART0 (Connected to USB port)
Serial1.begin(9600, SERIAL_8N1, RX1pin, TX1pin); // Set up hardware UART1
// Set up remaining communication ports here (Energy, Drive, Vision)
+ if (!SPIFFS.begin(true))
+ {
+ Serial.println("SPIFFS failed to mount");
+ return;
+ }
+
Serial.println("Connecting to AP");
WiFi.begin(WIFI_SSID, WIFI_PW);
while (WiFi.status() != WL_CONNECTED)
@@ -354,8 +64,10 @@ void setup()
}
Serial.println("mDNS set up, access Control Panel at 'rover.local/'");
- webserver.on("/", [](AsyncWebServerRequest *request)
- { request->send_P(200, "text/html", index_html); });
+ webserver.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
+ { request->send(SPIFFS, "/index.html", "text/html"); });
+ webserver.on("/favicon.ico", HTTP_GET, [](AsyncWebServerRequest *request)
+ { request->send(SPIFFS, "/favicon.ico", "image/png"); });
webserver.onNotFound(notFound);
webserver.begin();
@@ -404,47 +116,47 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, size_t length)
{
switch (type)
{
- case WStype_DISCONNECTED:
- {
- Serial.printf("Client[%u] Disconnected!\n", num);
- }
- break;
- case WStype_CONNECTED:
- {
- IPAddress ip = websocketserver.remoteIP(num);
- Serial.printf("Client[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);
- }
- break;
- case WStype_TEXT:
- {
- Serial.printf("Client[%u] sent Text: %s\n", num, payload);
- String command = String((char *)(payload));
+ case WStype_DISCONNECTED:
+ {
+ Serial.printf("Client[%u] Disconnected!\n", num);
+ }
+ break;
+ case WStype_CONNECTED:
+ {
+ IPAddress ip = websocketserver.remoteIP(num);
+ Serial.printf("Client[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);
+ }
+ break;
+ case WStype_TEXT:
+ {
+ Serial.printf("Client[%u] sent Text: %s\n", num, payload);
+ String command = String((char *)(payload));
- DynamicJsonDocument doc(200); //creating an instance of a DynamicJsonDocument allocating 200bytes on the heap.
- DeserializationError error = deserializeJson(doc, command); // deserialize 'doc' and parse for parameters we expect to receive.
- if (error)
- {
- Serial.print("deserializeJson() failed: ");
- Serial.println(error.c_str());
- return;
- }
-
- int MVM_F_status = doc["MVM_F"];
- int MVM_L_status = doc["MVM_L"];
- int MVM_R_status = doc["MVM_R"];
- int MVM_B_status = doc["MVM_B"];
-
- Serial.println('<' + MVM_F_status + ',' + MVM_B_status + ',' + MVM_L_status + ',' + MVM_R_status + '>');
- }
- break;
- case WStype_PONG:
+ DynamicJsonDocument doc(200); //creating an instance of a DynamicJsonDocument allocating 200bytes on the heap.
+ DeserializationError error = deserializeJson(doc, command); // deserialize 'doc' and parse for parameters we expect to receive.
+ if (error)
{
- Serial.println("Websocket keep-alive PONG");
- }
- default:
- {
- Serial.println(String("Websocket received invalid event type: ") + type + String(", exiting"));
- exit(1);
+ Serial.print("deserializeJson() failed: ");
+ Serial.println(error.c_str());
+ return;
}
+
+ int MVM_F_status = doc["MVM_F"];
+ int MVM_L_status = doc["MVM_L"];
+ int MVM_R_status = doc["MVM_R"];
+ int MVM_B_status = doc["MVM_B"];
+
+ Serial.println('<' + MVM_F_status + ',' + MVM_B_status + ',' + MVM_L_status + ',' + MVM_R_status + '>');
+ }
+ break;
+ case WStype_PONG:
+ {
+ Serial.println("Websocket keep-alive PONG");
+ }
+ default:
+ {
+ Serial.println(String("Websocket received invalid event type: ") + type + String(", exiting"));
+ exit(1);
+ }
}
}