Files
quectel-rgmii-toolkit/simpleadmin/www/cgi-bin/get_atcommand
iamromulan c01c9e88e0 Sync stable Changes with development
-NSA and SA stats now show correctly
-Entware is now considered out of BETA
-ttyd installation process improved
-Added install option for speedtest and fast CLI commands

Co-Authored-By: Russel Yasol <73575327+dr-dolomite@users.noreply.github.com>
2024-03-26 01:57:29 -04:00

36 lines
1.0 KiB
Bash

#!/bin/bash
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")
# 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
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"
echo $x
echo ""
echo $runcmd