From 61cdfebc8a0a820f5ccd375c7bb36dc70d53dc04 Mon Sep 17 00:00:00 2001 From: Russel Yasol Date: Mon, 27 May 2024 22:48:37 +0800 Subject: [PATCH 1/3] index refactoring not finish --- simpleadmin/www/index.html | 1133 ++++++++---------------------------- 1 file changed, 237 insertions(+), 896 deletions(-) diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index d55960a..3c2bbf1 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -23,7 +23,7 @@
- -
+
@@ -160,7 +160,10 @@ d="M0 336c0 79.5 64.5 144 144 144H512c70.7 0 128-57.3 128-128c0-61.9-44-113.6-102.4-125.4c4.1-10.7 6.4-22.4 6.4-34.6c0-53-43-96-96-96c-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32C167.6 32 96 103.6 96 192c0 2.7 .1 5.4 .2 8.1C40.2 219.8 0 273.2 0 336z" /> -

+

@@ -177,11 +180,11 @@ Active Sim - + Network Provider - + MCCMNC @@ -193,7 +196,7 @@ Network Mode - + Bands @@ -261,7 +264,7 @@
-
+
+ - \ No newline at end of file + From 4a3a7775dd42deb91de9c72efc44637783d1b78f Mon Sep 17 00:00:00 2001 From: Russel Yasol Date: Tue, 28 May 2024 14:25:12 +0800 Subject: [PATCH 2/3] added changes to home, integrated sms from snjzb, and fixed minor error --- simpleadmin/script/sms.sh | 31 - simpleadmin/www/cgi-bin/get_sms | 12 - simpleadmin/www/cgi-bin/send_sms | 29 +- simpleadmin/www/index.html | 951 +++++++++++++++++++++++++++++-- simpleadmin/www/network.html | 2 +- simpleadmin/www/sms.html | 761 ++++++++++++------------- 6 files changed, 1289 insertions(+), 497 deletions(-) delete mode 100644 simpleadmin/script/sms.sh delete mode 100644 simpleadmin/www/cgi-bin/get_sms diff --git a/simpleadmin/script/sms.sh b/simpleadmin/script/sms.sh deleted file mode 100644 index 6a2af92..0000000 --- a/simpleadmin/script/sms.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -# Check if the required parameters are provided -if [ "$#" -ne 2 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Assign the provided parameters to variables -phone_number="$1" -message="$2" - -# Send the AT command to set the message format to text mode -echo -ne "AT+CMGF=1\r" > microcom -s /dev/ttyOUT2 -sleep 1 -echo -ne "AT+CNMI=2,1\r" > microcom /dev/ttyOUT2 -sleep 1 -echo -ne 'AT+CMGS="09938931024"\r' > microcom /dev/ttyOUT2 -sleep 1 - -# Send the message -echo -ne "$message" > microcom /dev/ttyOUT2 -echo -ne "\032" > microcom /dev/ttyOUT2 - -# Wait for the response -sleep 1 - -# Capture and output the response -runcmd=$(microcom /dev/ttyOUT2) -# echo "Content-type: text/plain" -echo "$runcmd" \ No newline at end of file diff --git a/simpleadmin/www/cgi-bin/get_sms b/simpleadmin/www/cgi-bin/get_sms deleted file mode 100644 index a341832..0000000 --- a/simpleadmin/www/cgi-bin/get_sms +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -SMS_FORMAT="AT+CMGF=1" -SMS_LIST="AT+CMGL=\"ALL\"" -send_at_command() { - local command="$1" - echo -en "$command\r\n" | microcom -t 2000 /dev/ttyOUT2 -} -send_at_command "$SMS_FORMAT" -runcmd=$(send_at_command "$SMS_LIST") - -echo "Content-type: text/plain" -echo "$runcmd" \ No newline at end of file diff --git a/simpleadmin/www/cgi-bin/send_sms b/simpleadmin/www/cgi-bin/send_sms index 2e8f316..cc70e4e 100644 --- a/simpleadmin/www/cgi-bin/send_sms +++ b/simpleadmin/www/cgi-bin/send_sms @@ -20,35 +20,12 @@ fi phone_number="$number" message_encoded="$msg" -phone_number="+86$phone_number" send_at_command() { local cmd=$1 - echo "Sending command: $cmd" >&2 - echo -en "$cmd\r" | microcom -t 1000 /dev/ttyOUT2 - sleep 2 - local response=$(microcom -t 1000 /dev/ttyOUT2) - echo "Response: $response" >&2 - echo "$response" + echo -en "$cmd\r" | microcom -t 100 /dev/ttyOUT2 } -send_at_command "AT+CMGF=1" -send_at_command "AT+CSCS=\"UCS2\"" - -encode_ucs2() { - local input="$1" - local output="" - local i - for ((i=0; i<${#input}; i++)); do - hex=$(printf "%04X" "'${input:$i:1}") - output="$output$hex" - done - echo "$output" -} - -phone_number_ucs2=$(encode_ucs2 "$phone_number") -ATCMD="AT+CMGS=\"$phone_number_ucs2\"" -send_at_command "$ATCMD" - -runcmd=$((echo -en "$message_encoded"; sleep 1; echo -en "\x1A") | microcom -t 1000 /dev/ttyOUT2) +send_at_command "AT+CMGS=\"$phone_number\","$Command"" +runcmd=$((echo -en "$message_encoded"; echo -en "\x1A") | microcom -t 500 /dev/ttyOUT2) echo "$runcmd" \ No newline at end of file diff --git a/simpleadmin/www/index.html b/simpleadmin/www/index.html index 3c2bbf1..94166c0 100644 --- a/simpleadmin/www/index.html +++ b/simpleadmin/www/index.html @@ -118,11 +118,11 @@

- + - +
@@ -213,11 +213,11 @@ PCI - + IPv4 @@ -264,7 +264,7 @@
- + @@ -614,6 +626,34 @@ networkMode: "Disconnected", bands: "Unknown Bands", bandwidth: "Unknown Bandwidth", + earfcns: "000", + pccPCI: "0", + sccPCI: "-", + ipv4: "000.000.000.000", + ipv6: "0000:0000:0000:0000:0000:0000:0000:0000", + cellID: "Unknown", + eNBID: "Unknown", + tac: "Unknown", + csq: "-", + rssi: "-", + rsrpLTE: "-", + rsrpNR: "-", + rsrpLTEPercentage: "0%", + rsrpNRPercentage: "0%", + rsrqLTE: "-", + rsrqNR: "-", + rsrqLTEPercentage: "0%", + rsrqNRPercentage: "0%", + sinrLTE: "-", + sinrNR: "-", + sinrLTEPercentage: "0%", + sinrNRPercentage: "0%", + signalPercentage: "0", + signalAssessment: "Unknown", + uptime: "Unknown", + lastUpdate: new Date().toLocaleString(), + newRefreshRate: null, + refreshRate: 3, fetchAllInfo() { this.atcmd = @@ -635,6 +675,8 @@ const rawdata = data; const lines = rawdata.split("\n"); + console.log(lines); + // --- Temperature --- // find this example value from lines "+QTEMP:"cpuss-0-usr","50" this.temperature = lines @@ -652,7 +694,7 @@ .split(",")[1]; if (sim_status == 1) { - this.simStatus = "SIM Inserted"; + this.simStatus = "Active"; } else if (sim_status == 0) { this.simStatus = "No SIM"; } @@ -708,35 +750,56 @@ // --- Network Mode --- // find this example value from lines "+QENG: \"servingcell\",\"NOCONN\",\"NR5G-SA\",\"TDD\",515,66,7000C4001,475,702000,620640,78,12,-83,-3,16,1,-\r" - // Use a try and except try { const network_mode = lines - .find((line) => line.includes("+QENG:")) + .find((line) => line.includes('+QENG: "servingcell"')) .split(",")[2] .replace(/"/g, ""); + + const duplex_mode = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[3] + .replace(/"/g, ""); if (network_mode == "NR5G-SA") { - this.networkMode = "5G Standalone"; + if (duplex_mode == "TDD") { + this.networkMode = "5G SA TDD"; + } else if (duplex_mode == "FDD") { + this.networkMode = "5G SA FDD"; + } + } + + if (network_mode == "LTE") { + // get the FDD | TDD value + const is_tdd = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[3] + .replace(/"/g, ""); + + if (is_tdd == "TDD") { + this.networkMode = "4G LTE TDD"; + } else if (is_tdd == "FDD") { + this.networkMode = "4G LTE FDD"; + } } } catch (error) { // find this example value from lines "+QENG: \"LTE\",\"FDD\",515,03,22AE76D,398,1350,3,4,4,BF82,-110,-13,-78,10,6,200,-\r" const network_mode_lte = lines - .find((line) => line.includes("+QENG:")) - .split(",")[1] + .find((line) => line.includes('+QENG: "LTE"')) + .split(",")[0] + .replace("+QENG: ", "") .replace(/"/g, ""); try { // find this example value from lines "+QENG: \"NR5G-NSA\",515,03,843,-95,20,-11,528030,41,8,1\r" const network_mode_5g = lines - .find((line) => line.includes("+QENG:")) + .find((line) => line.includes('+QENG: "NR5G-NSA"')) .split(",")[0] .replace("+QENG: ", "") .replace(/"/g, ""); - if (network_mode_5g == "NR5G-NSA") { - this.networkMode = "5G Non-Standalone"; - } + this.networkMode = "5G NSA"; } catch (error) { if (network_mode_lte == "FDD") { this.networkMode = "4G LTE FDD"; @@ -779,13 +842,11 @@ } // --- Bandwidth --- - if (this.networkMode == "5G Standalone") { + if (this.networkMode == "5G SA TDD" || this.networkMode == "5G SA FDD") { // find this example value from lines "+QENG: \"servingcell\" const bandwidth_line = lines.find((line) => - line.includes("+QENG: \"servingcell\"") + line.includes('+QENG: "servingcell"') ); - - console.log(bandwidth_line); const nr_bw = bandwidth_line.split(",")[11]; const calculated_bandwidth = this.calculate_nr_bw(nr_bw); this.bandwidth = "NR " + calculated_bandwidth + " MHz"; @@ -795,36 +856,553 @@ ) { // find this example value from lines "+QENG: \"servingcell\" const bandwidth_line = lines.find((line) => - line.includes("+QENG: \"servingcell\"") + line.includes('+QENG: "servingcell"') ); const lte_bw_ul = bandwidth_line.split(",")[10]; const lte_bw_dl = bandwidth_line.split(",")[11]; - const calculated_bandwidth_ul = this.calculate_lte_bw(lte_bw_ul); - const calculated_bandwidth_dl = this.calculate_lte_bw(lte_bw_dl); - this.bandwidth = calculated_bandwidth_ul + " / " + calculated_bandwidth_dl + " MHz"; - } else if (this.networkMode == "5G Non-Standalone") { + const calculated_bandwidth_ul = + this.calculate_lte_bw(lte_bw_ul); + const calculated_bandwidth_dl = + this.calculate_lte_bw(lte_bw_dl); + this.bandwidth = + calculated_bandwidth_ul + + " UL / " + + calculated_bandwidth_dl + + " DL MHz"; + } else if (this.networkMode == "5G NSA") { // find this example value from lines "+QENG: \"LTE\" for LTE const lte_bandwidth_line = lines.find((line) => - line.includes("+QENG: \"LTE\"") + line.includes('+QENG: "LTE"') ); const lte_bw_ul = lte_bandwidth_line.split(",")[8]; const lte_bw_dl = lte_bandwidth_line.split(",")[9]; - const calculated_bandwidth_ul = this.calculate_lte_bw(lte_bw_ul); - const calculated_bandwidth_dl = this.calculate_lte_bw(lte_bw_dl); + const calculated_bandwidth_ul = + this.calculate_lte_bw(lte_bw_ul); + const calculated_bandwidth_dl = + this.calculate_lte_bw(lte_bw_dl); + // find this example value from lines "+QENG: \"NR5G-NSA\" for NR5G + const nr_bandwidth_line = lines.find((line) => + line.includes('+QENG: "NR5G-NSA"') + ); - - const nr_bw = bandwidth_line.split(",")[9]; + const nr_bw = nr_bandwidth_line.split(",")[9]; const calculated_bandwidth = this.calculate_nr_bw(nr_bw); // combine the bandwidths - this.bandwidth = "NR " + calculated_bandwidth + " MHz, " + calculated_bandwidth_ul + " / " + calculated_bandwidth_dl + " MHz"; + this.bandwidth = + calculated_bandwidth_ul + + " UL / " + + calculated_bandwidth_dl + + " DL MHz" + + " / NR " + + calculated_bandwidth + + " MHz"; } else { this.bandwidth = "Unknown Bandwidth"; } + + // --- E/ARFCN --- + if (this.networkMode == "5G SA TDD" || this.networkMode == "5G SA FDD") { + // find this value from lines "+QCAINFO: \"PCC\" + const nr_pcc_arfcn = lines + .find((line) => line.includes('+QCAINFO: "PCC"')) + .split(",")[1]; + + try { + // Look for all the lines with this value "+QCAINFO: \"SCC\" and store them in an array + const nr_scc_arfcn = lines.filter((line) => + line.includes('+QCAINFO: "SCC"') + ); + + // if empty, then proceed to error block + if (nr_scc_arfcn.length == 0) { + throw "No SCC ARFCN"; + } + + // process all the values in the array and extract the ARFCN part only + for (let i = 0; i < nr_scc_arfcn.length; i++) { + nr_scc_arfcn[i] = nr_scc_arfcn[i].split(",")[1]; + } + + // combine the PCC and SCC ARFCN values + this.earfcns = + nr_pcc_arfcn + ", " + nr_scc_arfcn.join(", "); + } catch (error) { + this.earfcns = nr_pcc_arfcn.replace(/,/g, ""); + } + } else if ( + this.networkMode == "4G LTE FDD" || + this.networkMode == "4G LTE TDD" + ) { + // find this value from lines "+QCAINFO: \"PCC\" + const lte_pcc_arfcn = lines + .find((line) => line.includes('+QCAINFO: "PCC"')) + .split(",")[1]; + + try { + // Look for all the lines with this value "+QCAINFO: \"SCC\" and store them in an array + const lte_scc_arfcn = lines.filter((line) => + line.includes('+QCAINFO: "SCC"') + ); + + // if empty, then proceed to error block + if (lte_scc_arfcn.length == 0) { + throw "No SCC ARFCN"; + } + + // process all the values in the array and extract the ARFCN part only + for (let i = 0; i < lte_scc_arfcn.length; i++) { + lte_scc_arfcn[i] = lte_scc_arfcn[i].split(",")[1]; + } + + // combine the PCC and SCC ARFCN values + this.earfcns = + lte_pcc_arfcn + ", " + lte_scc_arfcn.join(", "); + } catch (error) { + this.earfcns = lte_pcc_arfcn.replace(/,/g, ""); + } + } else if (this.networkMode == "5G NSA") { + // find this value from lines "+QCAINFO: \"PCC\" + const lte_pcc_arfcn = lines + .find((line) => line.includes('+QCAINFO: "PCC"')) + .split(",")[5]; + + try { + // Look for all the lines with this value "+QCAINFO: \"SCC\" and store them in an array + const lte_scc_arfcn = lines.filter((line) => + line.includes('+QCAINFO: "SCC"') + ); + + // If empty, then proceed to error block + if (lte_scc_arfcn.length == 0) { + throw "No SCC ARFCN"; + } + + // process all the values in the array and extract the ARFCN part only + for (let i = 0; i < lte_scc_arfcn.length; i++) { + lte_scc_arfcn[i] = lte_scc_arfcn[i].split(",")[1]; + } + + // combine the PCC and SCC ARFCN values + this.earfcns = + lte_pcc_arfcn + ", " + lte_scc_arfcn.join(", "); + } catch (error) { + this.earfcns = lte_pcc_arfcn.replace(/,/g, ""); + } + } else { + this.earfcns = "Unknown E/ARFCN"; + } + + // --- PCI --- + if (this.networkMode == "5G SA TDD" || this.networkMode == "5G SA FDD") { + const nr_pcc_pci = lines + .find((line) => line.includes('+QCAINFO: "PCC"')) + .split(",")[4]; + + try { + // Look for all the lines with this value "+QCAINFO: \"SCC\" and store them in an array + const nr_scc_pci = lines.filter((line) => + line.includes('+QCAINFO: "SCC"') + ); + + // if empty, then proceed to error block + if (nr_scc_pci.length == 0) { + throw "No SCC PCI"; + } + + // process all the values in the array and extract the PCI part only + for (let i = 0; i < nr_scc_pci.length; i++) { + nr_scc_pci[i] = nr_scc_pci[i].split(",")[5]; + } + + // combine the PCC and SCC PCI values + this.pccPCI = nr_pcc_pci; + this.sccPCI = nr_scc_pci.join(", "); + } catch (error) { + // remove comma if only one value + this.pccPCI = nr_pcc_pci.replace(/,/g, ""); + this.sccPCI = "-"; + } + } else if ( + this.networkMode == "4G LTE FDD" || + this.networkMode == "4G LTE TDD" + ) { + // find this value from lines "+QCAINFO: \"PCC\" + const lte_pcc_pci = lines + .find((line) => line.includes('+QCAINFO: "PCC"')) + .split(",")[5]; + + try { + // Look for all the lines with this value "+QCAINFO: \"SCC\" and store them in an array + const lte_scc_pci = lines.filter((line) => + line.includes('+QCAINFO: "SCC"') + ); + + // if empty, then proceed to error block + if (lte_scc_pci.length == 0) { + throw "No SCC PCI"; + } + + // process all the values in the array and extract the PCI part only + for (let i = 0; i < lte_scc_pci.length; i++) { + lte_scc_pci[i] = lte_scc_pci[i].split(",")[5]; + } + + // combine the PCC and SCC PCI values + this.pccPCI = lte_pcc_pci; + this.sccPCI = lte_scc_pci.join(", "); + } catch (error) { + this.pccPCI = lte_pcc_pci; + this.sccPCI = "-"; + } + } else if (this.networkMode == "5G NSA") { + // find this value from lines "+QCAINFO: \"PCC\" + const lte_pcc_pci = lines + .find((line) => line.includes('+QCAINFO: "PCC"')) + .split(",")[5]; + + try { + // Look for all the lines with this value "+QCAINFO: \"SCC\" and store them in an array + const lte_scc_pci = lines.filter((line) => + line.includes('+QCAINFO: "SCC"') + ); + + // if empty, then proceed to error block + if (lte_scc_pci.length == 0) { + throw "No SCC PCI"; + } + + // process all the values in the array and extract the PCI part only + for (let i = 0; i < lte_scc_pci.length; i++) { + // if line contains LTE BAND then do this process + if (lte_scc_pci[i].includes("LTE BAND")) { + lte_scc_pci[i] = lte_scc_pci[i].split(",")[5]; + } else { + lte_scc_pci[i] = lte_scc_pci[i].split(",")[4]; + } + } + + // combine the PCC and SCC PCI values + this.pccPCI = lte_pcc_pci; + this.sccPCI = lte_scc_pci.join(", "); + } catch (error) { + this.pccPCI = lte_pcc_pci.replace(/,/g, ""); + this.sccPCI = "-"; + } + } else { + this.pccPCI = "0"; + this.sccPCI = "-"; + } + + // --- IPv4 and IPv6 --- + // find the value from line "IPV4" + this.ipv4 = lines + .find((line) => line.includes("IPV4")) + .split(",")[4] + .replace(/"/g, ""); + + // find the value from line "IPV6" + this.ipv6 = lines + .find((line) => line.includes("IPV6")) + .split(",")[4] + .replace(/"/g, ""); + + // Signal Informations + + const currentNetworkMode = this.networkMode; + + if ( + currentNetworkMode == "5G SA TDD" || + currentNetworkMode == "5G SA FDD" || + currentNetworkMode == "4G LTE FDD" || + currentNetworkMode == "4G LTE TDD" + ) { + // find the value from line "+QENG: \"servingcell\"" + // CellID + const longCID = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[6] + .replace(/"/g, ""); + + // Get the eNBID. Its just Cell ID minus the last 2 characters + this.eNBID = longCID.substring(0, longCID.length - 2); + + // Get the short Cell ID (Last 2 characters of the Cell ID) + const shortCID = longCID.substring(longCID.length - 2); + + if (currentNetworkMode == "5G SA TDD" || currentNetworkMode == "5G SA FDD") { + // TAC + this.tac = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[8] + .replace(/"/g, ""); + + // CSQ + this.csq = "NR-SA Mode"; + + // RSRP + this.rsrpNR = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[12] + .replace(/"/g, ""); + + // RSRQ + this.rsrqNR = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[13] + .replace(/"/g, ""); + + // SINR + this.sinrNR = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[14] + .replace(/"/g, ""); + + // Calculate the RSRP Percentage + this.rsrpNRPercentage = this.calculateRSRPPercentage( + parseInt(this.rsrpNR) + ); + + // Calculate the RSRQ Percentage + this.rsrqNRPercentage = this.calculateRSRQPercentage( + parseInt(this.rsrqNR) + ); + + // Calculate the SINR Percentage + this.sinrNRPercentage = this.calculateSINRPercentage( + parseInt(this.sinrNR) + ); + + // Calculate the Signal Percentage + this.signalPercentage = this.calculateSignalPercentage( + this.rsrpNRPercentage, + this.sinrNRPercentage + ); + + // Calculate the Signal Assessment + this.signalAssessment = this.signalQuality( + this.signalPercentage + ); + } else { + // LTE Only + // TAC + this.tac = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[12] + .replace(/"/g, ""); + + // CSQ + this.csq = lines + .find((line) => line.includes("+CSQ:")) + .split(" ")[1] + .replace("+CSQ: ", "") + .replace(/"/g, ""); + + // RSRP + this.rsrpLTE = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[13] + .replace(/"/g, ""); + + // RSRQ + this.rsrqLTE = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[14] + .replace(/"/g, ""); + + // RSSI + this.rssi = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[15] + .replace(/"/g, ""); + + // SINR + this.sinrLTE = lines + .find((line) => line.includes('+QENG: "servingcell"')) + .split(",")[16] + .replace(/"/g, ""); + + // Calculate the RSRP Percentage + this.rsrpLTEPercentage = this.calculateRSRPPercentage( + parseInt(this.rsrpLTE) + ); + + // Calculate the RSRQ Percentage + this.rsrqLTEPercentage = this.calculateRSRQPercentage( + parseInt(this.rsrqLTE) + ); + + // Calculate the SINR Percentage + this.sinrLTEPercentage = this.calculateSINRPercentage( + parseInt(this.sinrLTE) + ); + + // Calculate the Signal Percentage + this.signalPercentage = this.calculateSignalPercentage( + this.rsrpLTEPercentage, + this.sinrLTEPercentage + ); + + // Calculate the Signal Assessment + this.signalAssessment = this.signalQuality( + this.signalPercentage + ); + } + + this.cellID = + "Short " + + shortCID + + "(" + + parseInt(shortCID, 16) + + ")" + + ", " + + "Long " + + longCID + + "(" + + parseInt(longCID, 16) + + ")"; + } else if (currentNetworkMode == "5G NSA") { + // find the value from line "+QENG: \"LTE\" for LTE + // LongCID + const longCID = lines + .find((line) => line.includes('+QENG: "LTE"')) + .split(",")[4] + .replace(/"/g, ""); + + // Get the eNBID. Its just Cell ID minus the last 2 characters + this.eNBID = longCID.substring(0, longCID.length - 2); + + // Get the short Cell ID (Last 2 characters of the Cell ID) + const shortCID = longCID.substring(longCID.length - 2); + + // cellID + this.cellID = + "Short " + + shortCID + + "(" + + parseInt(shortCID, 16) + + ")" + + ", " + + "Long " + + longCID + + "(" + + parseInt(longCID, 16) + + ")"; + + // TAC + this.tac = lines + .find((line) => line.includes('+QENG: "LTE"')) + .split(",")[10] + .replace(/"/g, ""); + + // CSQ + this.csq = lines + .find((line) => line.includes("+CSQ:")) + .split(" ")[1] + .replace("+CSQ: ", "") + .replace(/"/g, ""); + + // RSRP LTE + this.rsrpLTE = lines + .find((line) => line.includes('+QENG: "LTE"')) + .split(",")[11] + .replace(/"/g, ""); + + // RSRQ LTE + this.rsrqLTE = lines + .find((line) => line.includes('+QENG: "LTE"')) + .split(",")[12] + .replace(/"/g, ""); + + // RSSI LTE + this.rssi = lines + .find((line) => line.includes('+QENG: "LTE"')) + .split(",")[13] + .replace(/"/g, ""); + + // SINR LTE + this.sinrLTE = lines + .find((line) => line.includes('+QENG: "LTE"')) + .split(",")[14] + .replace(/"/g, ""); + + // Calculate the RSRP LTE Percentage + this.rsrpLTEPercentage = this.calculateRSRPPercentage( + parseInt(this.rsrpLTE) + ); + + // Calculate the RSRQ LTE Percentage + this.rsrqLTEPercentage = this.calculateRSRQPercentage( + parseInt(this.rsrqLTE) + ); + + // Calculate the SINR LTE Percentage + this.sinrLTEPercentage = this.calculateSINRPercentage( + parseInt(this.sinrLTE) + ); + + // Calculate the Signal Percentage + const lte_signal_percentage = + this.calculateSignalPercentage( + this.rsrpLTEPercentage, + this.sinrLTEPercentage + ); + + // find the value from line "+QENG: \"NR5G-NSA\" for NR5G + // RSRP NR + this.rsrpNR = lines + .find((line) => line.includes('+QENG: "NR5G-NSA"')) + .split(",")[4] + .replace(/"/g, ""); + + // RSRQ NR + this.rsrqNR = lines + .find((line) => line.includes('+QENG: "NR5G-NSA"')) + .split(",")[5] + .replace(/"/g, ""); + + // SINR NR + this.sinrNR = lines + .find((line) => line.includes('+QENG: "NR5G-NSA"')) + .split(",")[6] + .replace(/"/g, ""); + + // Calculate the RSRP NR Percentage + this.rsrpNRPercentage = this.calculateRSRPPercentage( + parseInt(this.rsrpNR) + ); + + // Calculate the RSRQ NR Percentage + this.rsrqNRPercentage = this.calculateRSRQPercentage( + parseInt(this.rsrqNR) + ); + + // Calculate the SINR NR Percentage + this.sinrNRPercentage = this.calculateSINRPercentage( + parseInt(this.sinrNR) + ); + + // Calculate the Signal Percentage + const nr_signal_percentage = this.calculateSignalPercentage( + this.rsrpNRPercentage, + this.sinrNRPercentage + ); + + // Average the LTE and NR Signal Percentages + this.signalPercentage = + (lte_signal_percentage + nr_signal_percentage) / 2; + + // Calculate the Signal Assessment + this.signalAssessment = this.signalQuality( + this.signalPercentage + ); + } else { + this.signalAssessment = "No Signal"; + } } }); }); @@ -872,7 +1450,266 @@ } }, + calculateRSRPPercentage(rsrp) { + let RSRP_min = -135; + let RSRP_max = -65; + + // If rsrp is null, return 0% + if (isNaN(rsrp) || rsrp < -140) { + return 0; + } + + let percentage = ((rsrp - RSRP_min) / (RSRP_max - RSRP_min)) * 100; + + if (percentage > 100) { + percentage = 100; + } + + return Math.round(percentage); + }, + + calculateRSRQPercentage(rsrq) { + let RSRQ_min = -20; + let RSRQ_max = -8; + + // If rsrq is null, return 0% + if (isNaN(rsrq) || rsrq < -20) { + return 0; + } + + let percentage = ((rsrq - RSRQ_min) / (RSRQ_max - RSRQ_min)) * 100; + + if (percentage > 100) { + percentage = 100; + } + + return Math.round(percentage); + }, + + calculateSINRPercentage(sinr) { + let SINR_min = -10; // Changed from 0 + let SINR_max = 35; + + // If sinr is null, return 0% + if (isNaN(sinr) || sinr < -10) { + return 0; + } + + let percentage = ((sinr - SINR_min) / (SINR_max - SINR_min)) * 100; + + if (percentage > 100) { + percentage = 100; + } + + return Math.round(percentage); + }, + + // Calculate the overall signal assessment + calculateSignalPercentage(rsrpNRPercentage, sinrNRPercentage) { + // Get the average of the RSRP Percentage and SINR Percentage + let average = (rsrpNRPercentage + sinrNRPercentage) / 2; + return Math.round(average); + }, + + signalQuality(percentage) { + if (percentage >= 80) { + return "Excellent"; + } else if (percentage >= 60) { + return "Good"; + } else if (percentage >= 40) { + return "Fair"; + } else if (percentage >= 0) { + return "Poor"; + } else { + return "No Signal"; + } + }, + + fetchUpTime() { + // Content-Type: text/plain + // + // 1 hour 44, minute + fetch("/cgi-bin/get_uptime") + .then((response) => response.text()) + .then((data) => { + // Example result + // 01:17:02 up 3 days, 2:41, load average: 0.65, 0.66, 0.60 + + // Look for xx days in the result + const days = data.match(/(\d+) day/); + // Do the same for hours + const hours = data.match(/(\d+) hour/); + // Do the same for minutes + const minutes = data.match(/(\d+) min/); + // 2:41 + const hoursAndMinutes = data.match(/(\d+):(\d+),/); + + if (hoursAndMinutes != null) { + if (days != null) { + if (days[1] === "1") { + if (hoursAndMinutes[1] === "1") { + this.uptime = + days[1] + + " day, " + + hoursAndMinutes[1] + + " hour " + + hoursAndMinutes[2] + + " minutes"; + } else if (hoursAndMinutes[2] === 1) { + this.uptime = + days[1] + + " day, " + + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minute"; + } else { + this.uptime = + days[1] + + " day, " + + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minutes"; + } + } else { + if (hoursAndMinutes[1] === "1") { + this.uptime = + days[1] + + " days, " + + hoursAndMinutes[1] + + " hour " + + hoursAndMinutes[2] + + " minutes"; + } else if (hoursAndMinutes[2] === 1) { + this.uptime = + days[1] + + " days, " + + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minute"; + } else { + this.uptime = + days[1] + + " days, " + + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minutes"; + } + } + } else { + if (hoursAndMinutes[1] === "1") { + this.uptime = + hoursAndMinutes[1] + + " hour " + + hoursAndMinutes[2] + + " minutes"; + } else if (hoursAndMinutes[2] === 1) { + this.uptime = + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minute"; + } else { + this.uptime = + hoursAndMinutes[1] + + " hours " + + hoursAndMinutes[2] + + " minutes"; + } + } + } else if (days != null) { + if (hours != null) { + if (days[1] === "1") { + if (hours[1] === "1") { + this.uptime = days[1] + " day, " + hours[1] + " hour"; + } else { + this.uptime = days[1] + " day, " + hours[1] + " hours"; + } + } else { + if (hours[1] === "1") { + this.uptime = days[1] + " days, " + hours[1] + " hour"; + } else { + this.uptime = days[1] + " days, " + hours[1] + " hours"; + } + } + } else if (minutes != null) { + if (days[1] === "1") { + if (minutes[1] === "1") { + this.uptime = + days[1] + " day, " + minutes[1] + " minute"; + } else { + this.uptime = + days[1] + " day, " + minutes[1] + " minutes"; + } + } else { + if (minutes[1] === "1") { + this.uptime = + days[1] + " days, " + minutes[1] + " minute"; + } else { + this.uptime = + days[1] + " days, " + minutes[1] + " minutes"; + } + } + } else { + if (days[1] === "1") { + this.uptime = days[1] + " day"; + } else { + this.uptime = days[1] + " days"; + } + } + } else if (hours != null) { + if (hours[1] === "1") { + this.uptime = hours[1] + " hour"; + } else { + this.uptime = hours[1] + " hours"; + } + } else if (minutes != null) { + if (minutes[1] === "1") { + this.uptime = minutes[1] + " minute"; + } else { + this.uptime = minutes[1] + " minutes"; + } + } else { + this.uptime = "Unknown Time"; + } + }); + }, + + updateRefreshRate() { + // Check if the refresh rate is less than 3 + if (this.newRefreshRate < 3) { + this.newRefreshRate = 3; + } + + // Clear the old interval + clearInterval(this.intervalId); + + // Set the refresh rate + 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() { + // Fetch uptime + this.fetchUpTime(); + + // 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) + : 3; // Change 3 to your desired default value + this.fetchAllInfo(); this.requestPing() @@ -889,9 +1726,37 @@ console.error("Error:", error); this.internetConnectionStatus = "Disconnected"; }); + + this.lastUpdate = new Date().toLocaleString(); + console.log("Initialized"); + + // Set the refresh rate for interval + this.intervalId = setInterval(() => { + this.fetchUpTime(); + + this.fetchAllInfo(); + + this.requestPing() + .then((data) => { + const response = data.trim(); + // Trim any leading/trailing spaces + if (response === "OK") { + this.internetConnection = "Connected"; + } else { + this.internetConnection = "Disconnected"; + } + }) + .catch((error) => { + console.error("Error:", error); + this.internetConnection = "Disconnected"; + }); + + this.lastUpdate = new Date().toLocaleString(); + console.log("Refreshed"); + }, this.refreshRate * 1000); }, }; } - + \ No newline at end of file diff --git a/simpleadmin/www/network.html b/simpleadmin/www/network.html index 6a1c2d0..34e6053 100644 --- a/simpleadmin/www/network.html +++ b/simpleadmin/www/network.html @@ -814,7 +814,7 @@ }, cellLockDisableLTE() { // Send the atcmd command to reset the locked bands - const atcmd = 'AT+QNWLOCK="common/4g,0"'; + const atcmd = 'AT+QNWLOCK="common/4g",0'; this.showModal = true; this.sendATcommand(atcmd); diff --git a/simpleadmin/www/sms.html b/simpleadmin/www/sms.html index 5806604..8c41fde 100644 --- a/simpleadmin/www/sms.html +++ b/simpleadmin/www/sms.html @@ -1,422 +1,415 @@ - - - - - Simple Admin - - - - - - - - + - - + + + + Simple Admin + + + + + + + + - -
-
-
+ + @@ -388,19 +434,29 @@ this.manufacturer = lines[1].trim(); this.modelName = lines[3].trim(); this.firmwareVersion = lines[5].trim(); - this.imsi = lines[7].trim(); - this.iccid = lines[9].trim().replace("+ICCID: ", ""); this.imei = lines[11].trim(); this.lanIp = lines[13].trim().split(",")[3]; this.wwanIpv4 = lines[15].trim().split(",")[4].replace(/"/g, ""); this.wwanIpv6 = lines[16].trim().split(",")[4].replace(/"/g, ""); - this.phoneNumber = lines[18].trim().split(",")[1].replace(/"/g, ""); - if (this.phoneNumber === "") { - this.phoneNumber = "Unknown"; + try { + this.imsi = lines[7].trim(); + this.iccid = lines[9].trim().replace("+ICCID: ", ""); + this.phoneNumber = lines[18] + .trim() + .split(",")[1] + .replace(/"/g, ""); + + if (this.phoneNumber === "") { + this.phoneNumber = "Unknown"; + } + } catch (error) { + this.phoneNumber = "No SIM Card Inserted or Detected"; + this.imsi = " "; + this.iccid = " "; } - this.simpleAdminVersion = "SimpleAdminRev-Alpha-0.6"; + this.simpleAdminVersion = "SimpleAdminRev-Beta-1.0"; this.isLoading = false; }, @@ -445,7 +501,7 @@ alert("IMEI is the same as the current IMEI"); return; } - + this.showModal = true; }, diff --git a/simpleadmin/www/network.html b/simpleadmin/www/network.html index 34e6053..e1aa427 100644 --- a/simpleadmin/www/network.html +++ b/simpleadmin/www/network.html @@ -604,24 +604,27 @@ atcmd = `AT+QNWPREFCFG="lte_band",${newCheckedValues.join( ":" )}`; + console.log(atcmd); this.sendATcommand(atcmd); } else if (selectedMode === "NSA") { atcmd = `AT+QNWPREFCFG="nsa_nr5g_band",${newCheckedValues.join( ":" )}`; + console.log(atcmd); this.sendATcommand(atcmd); } else if (selectedMode === "SA") { atcmd = `AT+QNWPREFCFG="nr5g_band",${newCheckedValues.join( ":" )}`; + console.log(atcmd); this.sendATcommand(atcmd); } else { alert("Invalid network mode selected"); } - // Do a 5 second countdown + // Do a 2 second countdown this.showModal = true; - this.countdown = 5; + this.countdown = 2; const interval = setInterval(() => { this.countdown--; if (this.countdown === 0) { diff --git a/simpleadmin/www/settings.html b/simpleadmin/www/settings.html index da6e108..16ee78d 100644 --- a/simpleadmin/www/settings.html +++ b/simpleadmin/www/settings.html @@ -326,7 +326,7 @@ Go to Cell Scanner -->

Go to Cell Scanner

-

Go to WatchCat

+