diff --git a/simpleadmin/www/cgi-bin/get_atcommand b/simpleadmin/www/cgi-bin/get_atcommand index bfe675f..1e70ecc 100644 --- a/simpleadmin/www/cgi-bin/get_atcommand +++ b/simpleadmin/www/cgi-bin/get_atcommand @@ -16,20 +16,11 @@ fi x=$(urldecode "$atcmd") MYATCMD=$(printf '%b\n' "${atcmd//%/\\x}") if [ -n "${MYATCMD}" ]; then - # 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 - 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 + # Capture the response and remove ANSI color codes using awk + runcmd=$(atcmd11 "$x" | awk '{ gsub(/\x1B\[[0-9;]*[mG]/, "") }1') fi echo "Content-type: text/plain" echo $x echo "" -echo $runcmd \ No newline at end of file +echo "$runcmd" \ No newline at end of file diff --git a/simpleadmin/www/cgi-bin/user_atcommand b/simpleadmin/www/cgi-bin/user_atcommand new file mode 100644 index 0000000..386e60c --- /dev/null +++ b/simpleadmin/www/cgi-bin/user_atcommand @@ -0,0 +1,26 @@ +#!/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 + +x=$(urldecode "$atcmd") +MYATCMD=$(printf '%b\n' "${atcmd//%/\\x}") +if [ -n "${MYATCMD}" ]; then + # Capture the response and remove ANSI color codes using awk + runcmd=$(atcmd "$x" | awk '{ gsub(/\x1B\[[0-9;]*[mG]/, "") }1') +fi + +echo "Content-type: text/plain" +echo $x +echo "" +echo "$runcmd" \ No newline at end of file diff --git a/simpleadmin/www/settings.html b/simpleadmin/www/settings.html index 644fea9..675ca30 100644 --- a/simpleadmin/www/settings.html +++ b/simpleadmin/www/settings.html @@ -104,7 +104,7 @@ placeholder="ATI" aria-describedby="atCommandInput" x-model="atcmd" - @keydown.enter="sendATCommand()" + @keydown.enter="sendUserATCommand()" />