[][MAC80211][WiFi6/7][app][Change ATECHANNEL mapping cmd]

[Description]
Change ATECHANNEL mapping cmd format.
iw dev <interface> set freq <control> [HT20|HT40+|HT40-|80MHz|160MHz|...]
is currently not allowed in latest iw daemon.
So, change it to the following format:
iw dev <interface> set freq <control> [20|40|80|160|320]
[<center freq 1> [<center freq 2>]]

[Release-log]
N/A

Change-Id: Ia1a24da370de83128e7ce78ac241f6f803fcdf31
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9392058
diff --git a/feed/app/atenl/files/iwpriv.sh b/feed/app/atenl/files/iwpriv.sh
index a010e00..a4257f1 100755
--- a/feed/app/atenl/files/iwpriv.sh
+++ b/feed/app/atenl/files/iwpriv.sh
@@ -427,11 +427,12 @@
 
 function convert_channel {
     local ch=$(echo $1 | sed s/:/' '/g | cut -d " " -f 1)
+    local control_ch=$(echo $1 | sed s/:/' '/g | cut -d " " -f 1)
     local band=$(echo $1 | sed s/:/' '/g | cut -d " " -f 2)
     local pri_sel=$(echo $1 | sed s/:/' '/g | cut -d " " -f 3)
     local ctrl_band_idx=$(get_config "ATECTRLBANDIDX" ${iwpriv_file})
     local bw=$(get_config "ATETXBW" ${iwpriv_file} | cut -d ":" -f 1)
-    local bw_str="HT20"
+    local bw_str="20"
     local base_chan=1
     local control_freq=0
     local base_freq=0
@@ -468,286 +469,52 @@
         case ${bw} in
             "1")
                 if [ "${ch}" -lt "3" ] || [ "${ch}" -gt "12" ]; then
-                    local bw_str="HT20"
+                    bw_str="20"
                 else
-                    local bw_str="HT40+"
-                    ch=$(expr ${ch} - "2")
+                    bw_str="40"
+                    control_ch=$(expr ${ch} - "2")
                 fi
                 ;;
         esac
-        local base_freq=2412
-    elif [ "${band}" = "1" ]; then
-        case ${bw} in
-            "5")
-                bw_str="160MHz"
-                if [ ${ch} -lt "68" ]; then
-                    ch="36"
-                elif [ ${ch} -lt "100" ]; then
-                    ch="68"
-                elif [ ${ch} -lt "132" ]; then
-                    ch="100"
-                elif [ ${ch} -lt "181" ]; then
-                    ch="149"
-                fi
-                ;;
-            "2")
-                bw_str="80MHz"
-                if [ ${ch} -lt "52" ]; then
-                    ch="36"
-                elif [ ${ch} -lt "68" ]; then
-                    ch="52"
-                elif [ ${ch} -lt "84" ]; then
-                    ch="68"
-                elif [ ${ch} -lt "100" ]; then
-                    ch="84"
-                elif [ ${ch} -lt "116" ]; then
-                    ch="100"
-                elif [ ${ch} -lt "132" ]; then
-                    ch="116"
-                elif [ ${ch} -lt "149" ]; then
-                    ch="132"
-                elif [ ${ch} -lt "165" ]; then
-                    ch="149"
-                elif [ ${ch} -lt "181" ]; then
-                    ch="165"
-                fi
-                ;;
-            "1")
-                if [ ${ch} -lt "44" ]; then
-                    ch=$([ "${ch}" -lt "40" ] && echo "36" || echo "40")
-                    bw_str=$([ "${ch}" -le "38" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "52" ]; then
-                    ch=$([ "${ch}" -lt "48" ] && echo "44" || echo "48")
-                    bw_str=$([ "${ch}" -le "46" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "60" ]; then
-                    ch=$([ "${ch}" -lt "56" ] && echo "52" || echo "56")
-                    bw_str=$([ "${ch}" -le "54" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "68" ]; then
-                    ch=$([ "${ch}" -lt "64" ] && echo "60" || echo "64")
-                    bw_str=$([ "${ch}" -le "62" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "76" ]; then
-                    ch=$([ "${ch}" -lt "72" ] && echo "68" || echo "72")
-                    bw_str=$([ "${ch}" -le "70" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "84" ]; then
-                    ch=$([ "${ch}" -lt "80" ] && echo "76" || echo "80")
-                    bw_str=$([ "${ch}" -le "78" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "92" ]; then
-                    ch=$([ "${ch}" -lt "88" ] && echo "84" || echo "88")
-                    bw_str=$([ "${ch}" -le "86" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "100" ]; then
-                    ch=$([ "${ch}" -lt "96" ] && echo "92" || echo "96")
-                    bw_str=$([ "${ch}" -le "94" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "108" ]; then
-                    ch=$([ "${ch}" -lt "104" ] && echo "100" || echo "104")
-                    bw_str=$([ "${ch}" -le "102" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "116" ]; then
-                    ch=$([ "${ch}" -lt "112" ] && echo "108" || echo "112")
-                    bw_str=$([ "${ch}" -le "110" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "124" ]; then
-                    ch=$([ "${ch}" -lt "120" ] && echo "116" || echo "120")
-                    bw_str=$([ "${ch}" -le "118" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "132" ]; then
-                    ch=$([ "${ch}" -lt "128" ] && echo "124" || echo "128")
-                    bw_str=$([ "${ch}" -le "126" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "140" ]; then
-                    ch=$([ "${ch}" -lt "136" ] && echo "132" || echo "136")
-                    bw_str=$([ "${ch}" -le "134" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "149" ]; then
-                    ch=$([ "${ch}" -lt "144" ] && echo "140" || echo "144")
-                    bw_str=$([ "${ch}" -le "142" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "157" ]; then
-                    ch=$([ "${ch}" -lt "153" ] && echo "149" || echo "153")
-                    bw_str=$([ "${ch}" -le "151" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "165" ]; then
-                    ch=$([ "${ch}" -lt "161" ] && echo "157" || echo "161")
-                    bw_str=$([ "${ch}" -le "159" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "173" ]; then
-                    ch=$([ "${ch}" -lt "169" ] && echo "165" || echo "169")
-                    bw_str=$([ "${ch}" -le "167" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "181" ]; then
-                    ch=$([ "${ch}" -lt "177" ] && echo "173" || echo "177")
-                    bw_str=$([ "${ch}" -le "175" ] && echo "HT40+" || echo "HT40-")
-                fi
-                ;;
-            "0")
-                local bw_str="HT20"
-                ;;
-        esac
-        local base_freq=5180
-        local base_chan=36
+        base_freq=2412
     else
-        local base_freq=5955
         case ${bw} in
             "12")
-                local bw_str="320"
-                if [ ${ch} == "31" ]; then
-                    local control_freq="5955"
-                elif [ ${ch} == "63" ]; then
-                    local control_freq="6115"
-                elif [ ${ch} == "95" ]; then
-                    local control_freq="6275"
-                elif [ ${ch} == "127" ]; then
-                    local control_freq="6435"
-                elif [ ${ch} == "159" ]; then
-                    local control_freq="6595"
-                elif [ ${ch} == "191" ]; then
-                    local control_freq="6755"
-                fi
-                local center_freq=$(((ch - base_chan) * 5 + base_freq))
-                do_cmd "iw dev mon${phy_idx} set freq ${control_freq} ${bw_str} ${center_freq}"
-                return
+                bw_str="320"
+                control_ch=$(expr ${ch} - "30")
                 ;;
             "5")
-                bw_str="160MHz"
-                if [ ${ch} -lt "33" ]; then
-                    ch="1"
-                elif [ ${ch} -lt "65" ]; then
-                    ch="33"
-                elif [ ${ch} -lt "97" ]; then
-                    ch="65"
-                elif [ ${ch} -lt "129" ]; then
-                    ch="97"
-                elif [ ${ch} -lt "161" ]; then
-                    ch="129"
-                elif [ ${ch} -lt "193" ]; then
-                    ch="161"
-                elif [ ${ch} -lt "225" ]; then
-                    ch="193"
-                fi
+                bw_str="160"
+                control_ch=$(expr ${ch} - "14")
                 ;;
             "2")
-                bw_str="80MHz"
-                if [ ${ch} -lt "17" ]; then
-                    ch="1"
-                elif [ ${ch} -lt "33" ]; then
-                    ch="17"
-                elif [ ${ch} -lt "49" ]; then
-                    ch="33"
-                elif [ ${ch} -lt "65" ]; then
-                    ch="49"
-                elif [ ${ch} -lt "81" ]; then
-                    ch="65"
-                elif [ ${ch} -lt "97" ]; then
-                    ch="81"
-                elif [ ${ch} -lt "113" ]; then
-                    ch="97"
-                elif [ ${ch} -lt "129" ]; then
-                    ch="113"
-                elif [ ${ch} -lt "145" ]; then
-                    ch="129"
-                elif [ ${ch} -lt "161" ]; then
-                    ch="145"
-                elif [ ${ch} -lt "177" ]; then
-                    ch="161"
-                elif [ ${ch} -lt "193" ]; then
-                    ch="177"
-                elif [ ${ch} -lt "209" ]; then
-                    ch="193"
-                elif [ ${ch} -lt "225" ]; then
-                    ch="209"
-                fi
+                bw_str="80"
+                control_ch=$(expr ${ch} - "6")
                 ;;
             "1")
-                if [ ${ch} -lt "9" ]; then
-                    ch=$([ "${ch}" -lt "5" ] && echo "1" || echo "5")
-                    bw_str=$([ "${ch}" -le "3" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "17" ]; then
-                    ch=$([ "${ch}" -lt "13" ] && echo "9" || echo "13")
-                    bw_str=$([ "${ch}" -le "11" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "25" ]; then
-                    ch=$([ "${ch}" -lt "21" ] && echo "17" || echo "21")
-                    bw_str=$([ "${ch}" -le "19" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "33" ]; then
-                    ch=$([ "${ch}" -lt "29" ] && echo "25" || echo "29")
-                    bw_str=$([ "${ch}" -le "27" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "33" ]; then
-                    ch=$([ "${ch}" -lt "29" ] && echo "25" || echo "29")
-                    bw_str=$([ "${ch}" -le "27" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "41" ]; then
-                    ch=$([ "${ch}" -lt "37" ] && echo "33" || echo "37")
-                    bw_str=$([ "${ch}" -le "35" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "49" ]; then
-                    ch=$([ "${ch}" -lt "45" ] && echo "41" || echo "45")
-                    bw_str=$([ "${ch}" -le "43" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "57" ]; then
-                    ch=$([ "${ch}" -lt "53" ] && echo "49" || echo "53")
-                    bw_str=$([ "${ch}" -le "51" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "65" ]; then
-                    ch=$([ "${ch}" -lt "61" ] && echo "57" || echo "61")
-                    bw_str=$([ "${ch}" -le "59" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "73" ]; then
-                    ch=$([ "${ch}" -lt "69" ] && echo "65" || echo "69")
-                    bw_str=$([ "${ch}" -le "67" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "81" ]; then
-                    ch=$([ "${ch}" -lt "77" ] && echo "73" || echo "77")
-                    bw_str=$([ "${ch}" -le "75" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "89" ]; then
-                    ch=$([ "${ch}" -lt "85" ] && echo "81" || echo "85")
-                    bw_str=$([ "${ch}" -le "83" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "97" ]; then
-                    ch=$([ "${ch}" -lt "93" ] && echo "89" || echo "93")
-                    bw_str=$([ "${ch}" -le "91" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "105" ]; then
-                    ch=$([ "${ch}" -lt "101" ] && echo "97" || echo "101")
-                    bw_str=$([ "${ch}" -le "99" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "113" ]; then
-                    ch=$([ "${ch}" -lt "109" ] && echo "105" || echo "109")
-                    bw_str=$([ "${ch}" -le "107" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "121" ]; then
-                    ch=$([ "${ch}" -lt "117" ] && echo "113" || echo "117")
-                    bw_str=$([ "${ch}" -le "115" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "129" ]; then
-                    ch=$([ "${ch}" -lt "125" ] && echo "121" || echo "125")
-                    bw_str=$([ "${ch}" -le "123" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "137" ]; then
-                    ch=$([ "${ch}" -lt "133" ] && echo "129" || echo "133")
-                    bw_str=$([ "${ch}" -le "131" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "145" ]; then
-                    ch=$([ "${ch}" -lt "141" ] && echo "137" || echo "141")
-                    bw_str=$([ "${ch}" -le "139" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "153" ]; then
-                    ch=$([ "${ch}" -lt "149" ] && echo "145" || echo "149")
-                    bw_str=$([ "${ch}" -le "147" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "161" ]; then
-                    ch=$([ "${ch}" -lt "157" ] && echo "153" || echo "157")
-                    bw_str=$([ "${ch}" -le "155" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "169" ]; then
-                    ch=$([ "${ch}" -lt "165" ] && echo "161" || echo "165")
-                    bw_str=$([ "${ch}" -le "163" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "177" ]; then
-                    ch=$([ "${ch}" -lt "173" ] && echo "169" || echo "173")
-                    bw_str=$([ "${ch}" -le "171" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "185" ]; then
-                    ch=$([ "${ch}" -lt "181" ] && echo "177" || echo "181")
-                    bw_str=$([ "${ch}" -le "179" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "193" ]; then
-                    ch=$([ "${ch}" -lt "189" ] && echo "185" || echo "189")
-                    bw_str=$([ "${ch}" -le "187" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "201" ]; then
-                    ch=$([ "${ch}" -lt "197" ] && echo "193" || echo "197")
-                    bw_str=$([ "${ch}" -le "195" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "209" ]; then
-                    ch=$([ "${ch}" -lt "205" ] && echo "201" || echo "205")
-                    bw_str=$([ "${ch}" -le "203" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "217" ]; then
-                    ch=$([ "${ch}" -lt "213" ] && echo "209" || echo "213")
-                    bw_str=$([ "${ch}" -le "211" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "225" ]; then
-                    ch=$([ "${ch}" -lt "221" ] && echo "217" || echo "221")
-                    bw_str=$([ "${ch}" -le "219" ] && echo "HT40+" || echo "HT40-")
-                elif [ ${ch} -lt "233" ]; then
-                    ch=$([ "${ch}" -lt "229" ] && echo "225" || echo "229")
-                    bw_str=$([ "${ch}" -le "227" ] && echo "HT40+" || echo "HT40-")
-                fi
+                bw_str="40"
+                control_ch=$(expr ${ch} - "2")
                 ;;
             "0")
-                local bw_str="HT20"
+                bw_str="20"
+                control_ch=${ch}
                 ;;
         esac
+        if [ "${band}" = "1" ]; then
+            base_freq=5180
+            base_chan=36
+        else
+            base_freq=5955
+        fi
     fi
 
-    local control_freq=$(((ch - base_chan) * 5 + base_freq))
-    do_cmd "iw dev mon${phy_idx} set freq ${control_freq} ${bw_str}"
+    local center_freq=$(((ch - base_chan) * 5 + base_freq))
+    local control_freq=$(((control_ch - base_chan) * 5 + base_freq))
+    if [ "${center_freq}" == "${control_freq}" ]; then
+        do_cmd "iw dev mon${phy_idx} set freq ${control_freq} ${bw_str}"
+    else
+        do_cmd "iw dev mon${phy_idx} set freq ${control_freq} ${bw_str} ${center_freq}"
+    fi
 }
 
 function convert_rxstat {