+
+ No gui support
+
+
+ Auto refresh
+ Refresh
-
-
↻
-
↓
-
↺
+
+
+
+ ←
+ O
+ →
+
+
+ ↻
+ ↓
+ ↺
+
+
+ DFU
+ RESET
+
-
-
DFU
-
RESET
+
+
Temp: ?
+
Lat: ?
+
Lon: ?
+
Heading: ?
+
Sats: ?
+
📌
+
Open file manager
-
-
Temp: ?
-
Lat: ?
-
Lon: ?
-
Heading: ?
-
Sats: ?
-
📌
-
@@ -148,7 +177,8 @@
ESP32 PP v0.1
var respWaiting = PROMPT;
var respCallBack = null;
var enableSend = false; //keep track if sending is allowed or not
- var gateway = `ws://${window.location.hostname}/ws`;
+ //var gateway = `ws://${window.location.hostname}/ws`;
+ var gateway = `ws://192.168.4.1/ws`;
var websocket;
var respLines = []; //resp lines list.
var respLastLine = ""; //last line of resp
@@ -158,18 +188,10 @@
ESP32 PP v0.1
function enadisaControls(ena) {
enableSend = ena;
- document.getElementById("btnCtrUp").disabled = !ena;
- document.getElementById("btnCtrLeft").disabled = !ena;
- document.getElementById("btnCtrEnter").disabled = !ena;
- document.getElementById("btnCtrRight").disabled = !ena;
- document.getElementById("btnCtrRotLeft").disabled = !ena;
- document.getElementById("btnCtrDown").disabled = !ena;
- document.getElementById("btnCtrRotRight").disabled = !ena;
- document.getElementById("btnCtrDFU").disabled = !ena;
- document.getElementById("btnCtrRST").disabled = !ena;
- document.getElementById("bntRefresh").disabled = !ena;
- document.getElementById("btnManualSend").disabled = !ena;
- document.getElementById("btnGps").disabled = !ena;
+ var elementsToDisable = document.querySelectorAll('.uicontrols');
+ elementsToDisable.forEach(function (element) {
+ element.disabled = !ena;
+ });
}
function log(data) {
@@ -187,7 +209,14 @@
ESP32 PP v0.1
websocket.onopen = onOpen;
websocket.onclose = onClose;
websocket.onmessage = onMessage;
+ websocket.error = onError;
}
+
+ function onError(event) {
+ log("WS error");
+ console.log(event);
+ }
+
function onOpen(event) {
log("WS Connected");
document.getElementById("connState").innerHTML = "WS Connected.";
@@ -256,23 +285,28 @@
ESP32 PP v0.1
}
//any ws message
function onMessage(event) {
- var str = String(event.data);
- for (let i = 0; i < str.length; i++) {
- var resetline = false;
- respLastLine += str[i];
- if (str[i] == "\n") {
- respLines.push(respLastLine);
- onMessageLine(respLastLine);
- resetline = true;
- }
- if (respLastLine.endsWith(respWaiting)) {
- onDataArrived();
- }
- if (respLastLine.endsWith(PROMPT)) {//this counts too
- onMessageLine(respLastLine);
- resetline = true;
+ try {
+ var str = String(event.data);
+ for (let i = 0; i < str.length; i++) {
+ var resetline = false;
+ respLastLine += str[i];
+ if (str[i] == "\n") {
+ respLines.push(respLastLine);
+ onMessageLine(respLastLine);
+ resetline = true;
+ }
+ if (respLastLine.endsWith(respWaiting)) {
+ onDataArrived();
+ }
+ if (respLastLine.endsWith(PROMPT)) {//this counts too
+ onMessageLine(respLastLine);
+ resetline = true;
+ }
+ if (resetline) respLastLine = "";
}
- if (resetline) respLastLine = "";
+ }
+ catch (err) {
+ console.log(err);
}
}
@@ -369,6 +403,111 @@
ESP32 PP v0.1
respCallBack = screenUpdated;
sendMessage(tosend);
}
+
+ function fileSelected() {
+ var selectElement = document.getElementById("fileList");
+ var selectedOption = selectElement.options[selectElement.selectedIndex];
+ var selectedValue = selectedOption.value;
+ if (selectedValue == "..") {
+ cwdup();
+ return;
+ }
+ if (selectedValue.endsWith("/")) {
+ var path = document.getElementById("filePath").innerHTML;
+ path += selectedValue;
+ document.getElementById("filePath").innerHTML = path;
+ ls();
+ return;
+ }
+ else {
+ if (!selectedValue.endsWith(".tar") && !selectedValue.endsWith(".bin")) {
+ fileDownload();
+ }
+ else {
+ fileFlash();
+ }
+ }
+ }
+
+ function fileDownload() {
+ var path = document.getElementById("filePath").innerHTML;
+ if (!path.endsWith("/") && path.length > 1) path = path + "/";
+ var selectElement = document.getElementById("fileList");
+ var selectedOption = selectElement.options[selectElement.selectedIndex];
+ var selectedValue = selectedOption.value;
+ if (selectedValue.endsWith("/")) {
+ log("Can't download a folder yet.");
+ }
+ else {
+ //start file download
+ alert("NIY"); //todo
+ }
+ }
+
+ function fileUpload() {
+ alert("NIY"); //todo
+ }
+
+ function fileFlash() {
+ var path = document.getElementById("filePath").innerHTML;
+ if (!path.endsWith("/") && path.length > 1) path = path + "/";
+ var selectElement = document.getElementById("fileList");
+ var selectedOption = selectElement.options[selectElement.selectedIndex];
+ var selectedValue = selectedOption.value;
+ if (!selectedValue.endsWith(".tar") && !selectedValue.endsWith(".bin")) {
+ log("Can flash only TAR and BIN files. Selected: " + selectedValue);
+ }
+ else {
+ if (confirm("Really flash " + selectedValue + " ?")) {
+ alert("NIY"); //todo
+ }
+
+ }
+ }
+
+ function filesLsArrived() {
+ var fl = document.getElementById("fileList");
+ fl.innerHTML = "";
+ var path = document.getElementById("filePath").innerHTML;
+ if (path != "/") {
+ fl.innerHTML += "
.. ";
+ }
+ for (let i = 0; i < respLines.length; i++) {
+ var line = respLines[i].trim();
+ if (line.startsWith("ls ")) continue;
+ if (line.startsWith(PROMPT)) continue;
+ fl.innerHTML += "
" + line + " ";
+ }
+ }
+ function ls() {
+ var path = document.getElementById("filePath").innerHTML;
+ if (path.endsWith("/") && path.length > 1) path = path.substring(0, path.length - 1);
+ var tosend = "ls " + path + "\r\n";
+ respWaiting = PROMPT;
+ respLines = [];
+ enadisaControls(false);
+ preventSrenneRefresh = true;
+ respCallBack = filesLsArrived;
+ sendMessage(tosend);
+ }
+
+ function cwdup() {
+ var path = document.getElementById("filePath").innerHTML;
+ if (path.length > 1) {
+ path = path.replace(/\/+$/, ''); // Remove trailing '/'
+
+ // Find the last occurrence of '/'
+ let lastSlashIndex = path.lastIndexOf('/');
+
+ // If '/' is found, remove the last segment
+ if (lastSlashIndex >= 0) {
+ path = path.substring(0, lastSlashIndex + 1);
+ }
+ }
+ document.getElementById("filePath").innerHTML = path;
+ ls();
+ }
+
function manualSend() {
var tosend = document.getElementById("manualtxt").value;
if (!tosend.endsWith("\r\n")) { tosend += "\r\n"; }
@@ -413,6 +552,19 @@
ESP32 PP v0.1
}
}
+ function fileManClose() {
+ document.getElementById("filemanager").style.display = "none";
+ document.getElementById("mainscreencontent").style.display = "flex";
+ document.getElementById("manualcommand").style.display = "block";
+ }
+ function fileManOpen() {
+ document.getElementById("filemanager").style.display = "block";
+ document.getElementById("mainscreencontent").style.display = "none";
+ document.getElementById("manualcommand").style.display = "none";
+
+ ls();
+ }
+