Merge pull request #19 from dr-dolomite/development
Added various new features and fixes
This commit is contained in:
@@ -56,6 +56,17 @@ get_secondary_bands() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_secondary_bands_sa() {
|
||||
# Extract the NR5G SA BANDs from SCC lines from /tmp/qa.txt.
|
||||
# If there are multiple bands, they will be concatenated with <br/> tags.
|
||||
SC_BANDS=$(grep -o '"NR5G BAND [0-9]\+"' /tmp/modemstatus.txt | tr -d '"' | sed '1d' | sed ':a;N;$!ba;s/\n/<br\/>/g')
|
||||
|
||||
# If there are no NR5G SA bands, set SC_BANDS to empty
|
||||
if [ -z "$SC_BANDS" ]; then
|
||||
SC_BANDS="-"
|
||||
fi
|
||||
}
|
||||
|
||||
# Get the modem model from /tmp/modemmodel.txt and parse it
|
||||
MODEM_MODEL=$(</tmp/modemmodel.txt)
|
||||
# Get the model name from the modem model (they either start with RG or RM)
|
||||
@@ -305,9 +316,9 @@ case $RAT in
|
||||
if [ -n "$QENG5" ]; then
|
||||
MODE="$RAT $(echo $QENG5 | cut -d, -f4)"
|
||||
PCI=$(echo $QENG5 | cut -d, -f8)
|
||||
get_secondary_bands
|
||||
get_secondary_bands_sa
|
||||
# Apply | sed '1d' to NR_BAND
|
||||
NR_BAND=$(echo $NR_BAND | sed '1d')
|
||||
# Temporarily removed the sed command for testing
|
||||
CHANNEL=$(echo $QENG5 | cut -d, -f10)
|
||||
LBAND=$(echo $QENG5 | cut -d, -f11)
|
||||
PC_BAND="NR5G BAND "$LBAND
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<script src="/js/alpinejs.min.js" defer></script>
|
||||
<link rel="stylesheet" href="/css/bulma.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/admin.css" />
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -122,23 +123,40 @@
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div class="content">
|
||||
<!-- <div class="field" style="margin-bottom: 1rem">
|
||||
<div
|
||||
class="field"
|
||||
style="margin-bottom: 1rem"
|
||||
x-data="atCommands()"
|
||||
>
|
||||
<p class="control">
|
||||
<button
|
||||
class="button is-danger"
|
||||
click="sendRebootCommand()"
|
||||
:disabled="isRebootClicked"
|
||||
|
||||
@click="sendRebootCommand()"
|
||||
:disabled="isRebooting"
|
||||
>
|
||||
Reboot
|
||||
</button>
|
||||
</p>
|
||||
</div> -->
|
||||
|
||||
<!-- Loading modal -->
|
||||
<div x-show="isRebooting" class="modal-overlay">
|
||||
<div class="loading-modal">
|
||||
<div class="spinner"></div>
|
||||
<div class="loading-text" style="display: flex; flex-direction: column;">
|
||||
<h3>Rebooting...</h3>
|
||||
<p style="margin-top: 0.5rem;">Please wait for
|
||||
<span x-text="countdown" style="font-weight: 500;"></span> seconds before
|
||||
refreshing the page.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Add your useful commands content here -->
|
||||
<p>Here are some useful commands:</p>
|
||||
<ul>
|
||||
<li>
|
||||
See https://github.com/iamromulan/RM520N-GL#at-commands for
|
||||
<!-- Open to another tab -->
|
||||
See <a href="https://github.com/iamromulan/RM520N-GL#at-commands" target="_blank" style="cursor: pointer;">https://github.com/iamromulan/RM520N-GL#at-commands</a> for
|
||||
more
|
||||
</li>
|
||||
<li>AT+CFUN=1,1 (reboot)</li>
|
||||
@@ -247,15 +265,25 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END Useful Commands Section -->
|
||||
|
||||
<script>
|
||||
function atCommands() {
|
||||
return {
|
||||
isLoading: false,
|
||||
isRebooting: false,
|
||||
countdown: 40, // Total waiting time in seconds
|
||||
atcmd: null,
|
||||
defaultAtCommand: "ATI",
|
||||
atCommandResponse: "",
|
||||
sendAtCommand() {
|
||||
if (!this.atcmd) {
|
||||
// Use ATI as default command
|
||||
this.atcmd = "ATI";
|
||||
console.log(
|
||||
"AT Command is empty, using ATI as default command: ",
|
||||
this.atcmd
|
||||
);
|
||||
}
|
||||
this.isLoading = true;
|
||||
fetch(
|
||||
"/cgi-bin/get_atcommand?" +
|
||||
@@ -277,29 +305,35 @@
|
||||
clearResponses() {
|
||||
this.atCommandResponse = "";
|
||||
},
|
||||
sendRebootCommand() {
|
||||
this.atcmd = "AT+CFUN=1,1";
|
||||
this.isRebooting = true;
|
||||
console.log("Reboot command sent: ", this.atcmd);
|
||||
fetch(
|
||||
"/cgi-bin/get_atcommand?" +
|
||||
new URLSearchParams({
|
||||
atcmd: this.atcmd,
|
||||
})
|
||||
)
|
||||
.then((res) => {
|
||||
return res.text();
|
||||
})
|
||||
.then((data) => {
|
||||
this.atCommandResponse =
|
||||
"Rebooting... Please wait a few seconds before refreshing the page.";
|
||||
})
|
||||
.finally(() => {
|
||||
let timer = setInterval(() => {
|
||||
this.countdown--;
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(timer);
|
||||
this.isRebooting = false;
|
||||
}
|
||||
}, 1000); // Update countdown every second
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function sendRebootCommand() {
|
||||
var isRebootClicked = true;
|
||||
console.log("Reboot command triggered");
|
||||
var atcmd = "AT+CFUN=1,1";
|
||||
fetch(
|
||||
"/cgi-bin/get_atcommand?" +
|
||||
new URLSearchParams({
|
||||
atcmd: atcmd,
|
||||
})
|
||||
)
|
||||
.then((res) => {
|
||||
return res.text();
|
||||
})
|
||||
.then((data) => {
|
||||
console.log(data); // Logging the response for debugging purposes
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -16,8 +16,8 @@ fi
|
||||
MYATCMD=$(printf '%b\n' "${atcmd//%/\\x}")
|
||||
if [ -n "${MYATCMD}" ]; then
|
||||
x=$(urldecode "$atcmd")
|
||||
# Initialize wait time to 2 seconds
|
||||
wait_time=2
|
||||
# Initialize wait time to 1 second
|
||||
wait_time=1000
|
||||
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
|
||||
|
||||
24
simpleadmin/www/cgi-bin/get_sms
Normal file
24
simpleadmin/www/cgi-bin/get_sms
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is a simple scrip that fetches the SMS messages from the device
|
||||
SMS_MESSAGE_INDICATION="AT+CNMI=2,1"
|
||||
SMS_FORMAT="AT+CMGF=1"
|
||||
SMS_LIST="AT+CMGL=\"ALL\""
|
||||
|
||||
# Send the all the AT commands 1 by 1 with 2 seconds waiting time for each command
|
||||
runcmd=$(echo -en "$SMS_MESSAGE_INDICATION\r\n" | microcom -t 1000 /dev/ttyOUT2)
|
||||
runcmd=$(echo -en "$SMS_FORMAT\r\n" | microcom -t 1000 /dev/ttyOUT2)
|
||||
|
||||
while true; do
|
||||
runcmd=$(echo -en "$SMS_LIST\r\n" | microcom -t 2000 /dev/ttyOUT2)
|
||||
if [[ $runcmd =~ "OK" ]] || [[ $runcmd =~ "ERROR" ]]; then
|
||||
break
|
||||
fi
|
||||
((wait_time++))
|
||||
done
|
||||
|
||||
|
||||
# Print the list of SMS messages as JSON plain text
|
||||
echo "Content-type: text/plain"
|
||||
echo ""
|
||||
echo $runcmd
|
||||
@@ -99,61 +99,20 @@
|
||||
function atCommands() {
|
||||
return {
|
||||
isLoading: false,
|
||||
atcmd: 'AT+CMGL="ALL"',
|
||||
atCommandResponse: null,
|
||||
atCommandResponse: "",
|
||||
// get the SMS list through cgi-bin/get_sms
|
||||
sendAtCommand() {
|
||||
this.isLoading = true; // Set loading state to true before fetching data
|
||||
fetch(
|
||||
"/cgi-bin/get_atcommand?" +
|
||||
new URLSearchParams({
|
||||
atcmd: this.atcmd,
|
||||
})
|
||||
)
|
||||
.then((res) => {
|
||||
return res.text();
|
||||
})
|
||||
this.isLoading = true;
|
||||
fetch("/cgi-bin/get_sms")
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
this.atCommandResponse = data;
|
||||
// Split the response into individual messages
|
||||
const messages = data.trim().split("\n\n");
|
||||
|
||||
// Parse each message and construct an array of objects
|
||||
const parsedMessages = messages.map((message) => {
|
||||
const lines = message.split("\n");
|
||||
const sender = decodeHexString(
|
||||
lines[1].split(",")[2].slice(1, -1)
|
||||
);
|
||||
const time = lines[2].split(',"')[1];
|
||||
const messageText = decodeHexString(lines[3]);
|
||||
return {
|
||||
"Người gửi": sender,
|
||||
"Thời gian": time,
|
||||
"Tin nhắn": messageText,
|
||||
};
|
||||
});
|
||||
|
||||
// Log the parsed messages array as JSON to the console
|
||||
console.log(JSON.stringify(parsedMessages, null, 2));
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Không thể tìm thấy dữ liệu:", error);
|
||||
})
|
||||
.finally(() => {
|
||||
this.isLoading = false; // Set loading state to false after fetching data
|
||||
console.log(data);
|
||||
this.isLoading = false;
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
// Hàm giải mã chuỗi hex sang văn bản
|
||||
function decodeHexString(hexString) {
|
||||
let decodedString = "";
|
||||
for (let i = 0; i < hexString.length; i += 4) {
|
||||
let hex = hexString.substr(i, 4);
|
||||
let intValue = parseInt(hex, 16);
|
||||
decodedString += String.fromCharCode(intValue);
|
||||
}
|
||||
return decodedString;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
41
simpleadmin/www/styles.css
Normal file
41
simpleadmin/www/styles.css
Normal file
@@ -0,0 +1,41 @@
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.loading-modal {
|
||||
background-color: #fff;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
border: 4px solid rgba(0, 0, 0, 0.1);
|
||||
border-left-color: #333;
|
||||
border-radius: 50%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 0 auto 10px auto;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user