From f7780a589ee5281d040a28fc5e9a36015d286cd7 Mon Sep 17 00:00:00 2001 From: Cameron Thompson <50184035+iamromulan@users.noreply.github.com> Date: Sun, 14 Jul 2024 00:32:59 -0400 Subject: [PATCH] Update get_atcommand Uses atcmd11 now instead of microcom --- simpleadmin/www/cgi-bin/get_atcommand | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) 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