From db4ee5cc461b5277003db9467b1f0f3a14f31324 Mon Sep 17 00:00:00 2001 From: iamromulan <50184035+iamromulan@users.noreply.github.com> Date: Sun, 5 May 2024 01:44:29 -0400 Subject: [PATCH] Reapply "Merge pull request #41 from dr-dolomite/development-socat" This reverts commit 0543a18a4003cf5e809558a8350235b0ac9ace0d. --- simpleadmin/www/cgi-bin/get_atcommand | 4 +- simpleadmin/www/cgi-bin/get_ttl_status.old | 20 ++++ simpleadmin/www/cgi-bin/set_ttl.old | 61 ++++++++++++ simpleadmin/www/deviceinfo.html | 17 ++-- simpleadmin/www/index.html | 107 +++++++++++++++------ simpleadmin/www/js/parse-settings.js | 6 +- simpleadmin/www/network.html | 23 +++-- simpleadmin/www/settings.html | 17 ++-- simpleadmin/www/sms.html | 17 ++-- 9 files changed, 204 insertions(+), 68 deletions(-) create mode 100644 simpleadmin/www/cgi-bin/get_ttl_status.old create mode 100644 simpleadmin/www/cgi-bin/set_ttl.old diff --git a/simpleadmin/www/cgi-bin/get_atcommand b/simpleadmin/www/cgi-bin/get_atcommand index 710625b..9d81981 100644 --- a/simpleadmin/www/cgi-bin/get_atcommand +++ b/simpleadmin/www/cgi-bin/get_atcommand @@ -16,8 +16,8 @@ fi MYATCMD=$(printf '%b\n' "${atcmd//%/\\x}") if [ -n "${MYATCMD}" ]; then x=$(urldecode "$atcmd") - # Initialize wait time to 1 second - wait_time=1000 + # Initialize wait time to 200 ms + wait_time=200 while true; do runcmd=$(echo -en "$x\r\n" | microcom -t $wait_time /dev/ttyOUT2) # Check if "OK" or "ERROR" is present in the response diff --git a/simpleadmin/www/cgi-bin/get_ttl_status.old b/simpleadmin/www/cgi-bin/get_ttl_status.old new file mode 100644 index 0000000..03d366b --- /dev/null +++ b/simpleadmin/www/cgi-bin/get_ttl_status.old @@ -0,0 +1,20 @@ +#!/bin/bash + +# Check iptables for ttlvalue +ttlvalue=$(iptables -t mangle -vnL | awk '/TTL/ {print $13; exit}') +ttlenabled=true; + +# Set Variables +if [ -z "${ttlvalue}" ]; then + ttlvalue=0 + ttlenabled=false +fi + +echo "Content-type: text/json" +echo "" +cat </dev/null || true + ip6tables -t mangle -D POSTROUTING -o rmnet+ -j HL --hl-set ${ttlcheck} &>/dev/null || true + fi + + # Echo TTL to file + echo $setTTL > /usrdata/simplefirewall/ttlvalue + + # Set Start Service + /usrdata/simplefirewall/ttl-override start +fi + + + +# Check iptables for ttlvalue +ttlvalue=$(iptables -t mangle -vnL | grep TTL | awk '{print $13}') +ttlenabled=true; + +# Set Variables +if [ -z "${ttlvalue}" ]; then + ttlvalue=0 + ttlenabled=false +fi + +echo "Content-type: text/json" +echo "" +cat <SMS - - + - - - diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index 2b7c1c3..607b316 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -40,7 +40,9 @@ @@ -272,7 +272,6 @@ } } }" > -
- +
@@ -322,7 +323,9 @@ :class="getProgressBarClass()" :style="'width: ' + rsrqNRPercentage + '%'" > - + @@ -360,7 +363,9 @@ :class="getProgressBarClass()" :style="'width: ' + rsrpLTEPercentage + '%'" > - + @@ -398,7 +403,9 @@ :class="getProgressBarClass()" :style="'width: ' + rsrpNRPercentage + '%'" > - + @@ -436,7 +443,9 @@ :class="getProgressBarClass()" :style="'width: ' + sinrLTEPercentage +'%'" > - + @@ -474,7 +483,9 @@ :class="getProgressBarClass()" :style="'width: ' + sinrNRPercentage +'%'" > - + @@ -543,7 +554,7 @@ internetConnection: "Disconnected", lastUpdate: new Date().toLocaleString(), newRefreshRate: null, - refreshRate: 3, + refreshRate: 30, intervalId: null, fetchNetworkInfo() { this.atcmd = @@ -610,18 +621,38 @@ } else { let networkMode2, networkMode3; - networkMode2 = lines[28].split(":")[1].replace(/"/g, ""); - networkMode2 = networkMode2.split(",")[0]; - if ( - lines[29] !== undefined && - lines[29] !== "OK" && - lines[29] !== "" + lines[27] !== undefined && + lines[27] !== "OK" && + lines[27] !== "" && + lines[27] !== "/r" ) { - networkMode3 = lines[29].split(":")[1].replace(/"/g, ""); - networkMode3 = networkMode3.split(",")[0]; + // Check if lines[27] doesnt have NOCONN + if (lines[27].match(/servingcell/) === null) { + networkMode2 = lines[27].split(",")[2].replace(/"/g, ""); + networkMode2 = networkMode2.split(",")[0].trim(); + console.log(networkMode2); + } + + if (networkMode2 !== "LTE") { + networkMode2 = lines[28].split(":")[1].replace(/"/g, ""); + networkMode2 = networkMode2.split(",")[0]; + + if ( + lines[29] !== undefined && + lines[29] !== "OK" && + lines[29] !== "" + ) { + networkMode3 = lines[29] + .split(":")[1] + .split(",")[0] + .replace(/"/g, ""); + networkMode3 = networkMode3.split(",")[0]; + } + } } + console.log(networkMode2, networkMode3); // Check if networkMode3 is not empty if (networkMode3 !== undefined) { this.network_mode = networkMode2 + ", " + networkMode3; @@ -871,6 +902,9 @@ this.signalPercentage = (this.signalPercentage + nrSignalPercentage) / 2; + // Round the signalPercentage value + this.signalPercentage = Math.round(this.signalPercentage); + // Get the Signal Assessment this.signalAssessment = this.signalQuality( this.signalPercentage @@ -998,8 +1032,9 @@ const rawdata = data; const lines = rawdata.split("\n"); + console.log("CSQ: ", lines); - this.csq = lines[0].split(":")[1].split(",")[0].trim(); + this.csq = lines[1].split(":")[1].split(",")[0].trim(); }); }); } @@ -1031,11 +1066,22 @@ this.refreshRate = this.newRefreshRate; console.log("Refresh Rate Updated to " + this.refreshRate); + // Store the refresh rate in local storage or session storage + localStorage.setItem("refreshRate", this.refreshRate); + // Initialize with the new refresh rate this.init(); }, init() { + // Retrieve the refresh rate from local storage or session storage + const storedRefreshRate = localStorage.getItem("refreshRate"); + + // If a refresh rate is stored, use it; otherwise, use a default value + this.refreshRate = storedRefreshRate + ? parseInt(storedRefreshRate) + : 5; // Change 5 to your desired default value + this.fetchNetworkInfo(); // sleep for 2 seconds setTimeout(() => { @@ -1044,7 +1090,8 @@ this.requestPing() .then((data) => { - const response = data.trim(); // Trim any leading/trailing spaces + const response = data.trim(); + // Trim any leading/trailing spaces if (response === "OK") { this.internetConnection = "Connected"; } else { @@ -1069,7 +1116,8 @@ this.requestPing() .then((data) => { - const response = data.trim(); // Trim any leading/trailing spaces + const response = data.trim(); + // Trim any leading/trailing spaces if (response === "OK") { this.internetConnection = "Connected"; } else { @@ -1082,7 +1130,6 @@ }); this.lastUpdate = new Date().toLocaleString(); - console.log("Refreshed"); }, this.refreshRate * 1000); }, diff --git a/simpleadmin/www/js/parse-settings.js b/simpleadmin/www/js/parse-settings.js index 06b6bf8..409cbd5 100644 --- a/simpleadmin/www/js/parse-settings.js +++ b/simpleadmin/www/js/parse-settings.js @@ -15,14 +15,16 @@ function parseCurrentSettings(rawdata) { let bands = []; - // Append the values if there is separated by comma + // Append the values if there is separated by comma with a space. + // i.e. LTE BAND 3, LTE BAND 1 for (let i = 13; i < 17; i++) { if (lines[i].split(",").length > 1) { - bands.push(lines[i].split(",")[3].replace(/\"/g, "")); + bands.push(lines[i].split(",")[3].replace(/\"/g, " ")); } } this.bands = bands; + if (this.cellLock4GStatus == 1 && this.cellLock5GStatus == 1) { this.cellLockStatus = "Locked to 4G and 5G"; diff --git a/simpleadmin/www/network.html b/simpleadmin/www/network.html index e27d15e..e3d58f1 100644 --- a/simpleadmin/www/network.html +++ b/simpleadmin/www/network.html @@ -43,7 +43,12 @@ Home - - + - - - @@ -552,7 +555,7 @@ updatedLockedBands: null, sim: "-", newSim: null, - cellLockStatus: null, + cellLockStatus: "Unknown", bands: "Fetching Bands...", init() { // Function to populate checkboxes diff --git a/simpleadmin/www/settings.html b/simpleadmin/www/settings.html index b205cad..9a691a4 100644 --- a/simpleadmin/www/settings.html +++ b/simpleadmin/www/settings.html @@ -39,14 +39,16 @@ Simple Network - -