incorporated atcmd dynamic wait time to get_atcommand
This commit is contained in:
@@ -97,9 +97,9 @@
|
||||
<div class="content">
|
||||
<textarea
|
||||
class="textarea"
|
||||
x-bind:placeholder="isLoading ? 'Fetching response, please wait...' : 'Please send only 1 AT command at a time'"
|
||||
placeholder="Please send only 1 AT command at a time"
|
||||
rows="10"
|
||||
x-text="atCommandResponse"
|
||||
x-text="isLoading ? 'Fetching response, please wait...' : atCommandResponse"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
@@ -120,6 +120,18 @@
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div class="content">
|
||||
<!-- <div class="field" style="margin-bottom: 1rem">
|
||||
<p class="control">
|
||||
<button
|
||||
class="button is-danger"
|
||||
click="sendRebootCommand()"
|
||||
:disabled="isRebootClicked"
|
||||
|
||||
>
|
||||
Reboot
|
||||
</button>
|
||||
</p>
|
||||
</div> -->
|
||||
<!-- Add your useful commands content here -->
|
||||
<p>Here are some useful commands:</p>
|
||||
<ul>
|
||||
@@ -240,7 +252,7 @@
|
||||
return {
|
||||
isLoading: false,
|
||||
atcmd: null,
|
||||
atCommandResponse: '',
|
||||
atCommandResponse: "",
|
||||
sendAtCommand() {
|
||||
this.isLoading = true;
|
||||
fetch(
|
||||
@@ -265,6 +277,27 @@
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
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>
|
||||
|
||||
@@ -3,24 +3,30 @@ QUERY_STRING=$(echo "${QUERY_STRING}" | sed 's/;//g')
|
||||
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
|
||||
|
||||
if [ "${QUERY_STRING}" ]; then
|
||||
|
||||
export IFS="&"
|
||||
for cmd in ${QUERY_STRING}; do
|
||||
|
||||
if [ "$(echo $cmd | grep '=')" ]; then
|
||||
key=$(echo $cmd | awk -F '=' '{print $1}')
|
||||
value=$(echo $cmd | awk -F '=' '{print $2}')
|
||||
eval $key=$value
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
MYATCMD=$(printf '%b\n' "${atcmd//%/\\x}")
|
||||
if [ -n "${MYATCMD}" ]; then
|
||||
x=$(urldecode "$atcmd")
|
||||
runcmd=$(echo -en "$x\r\n" | microcom -t 2000 /dev/ttyOUT2)
|
||||
# Initialize wait time to 2 seconds
|
||||
wait_time=2
|
||||
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
|
||||
if [[ $runcmd =~ "OK" ]] || [[ $runcmd =~ "ERROR" ]]; then
|
||||
break # Exit the loop if "OK" or "ERROR" is found
|
||||
fi
|
||||
# If neither "OK" nor "ERROR" is found, increment wait time by 1 second
|
||||
((wait_time++))
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Content-type: text/plain"
|
||||
|
||||
Reference in New Issue
Block a user