#!/bin/sh

/bin/config set radio_number=0x3
/bin/config set ssid_number_per_radio=0x3
module_name=$(cat /module_name)
if [ "${module_name}" = "RAX10" -o "${module_name}" = "RAX10v2" -o "${module_name}" = "R6700AXv2" -o "${module_name}" = "RAX36S" -o "${module_name}" = "RAX36" ]; then
	/bin/config set radio_number=0x3
	/bin/config set wl2g_int="wl0"
	/bin/config set wl5g1_int="wl1"
	/bin/config set wl5g2_int="wl2"
	if [ "${module_name}" = "WAX204" ]; then
		/bin/config set ssid_number_per_radio=0x7
	fi
	
	# Fix [RAX10V2-0281] [RAX36][RAX36S][NH][iOS][Wireless] After App onboarding, (1) Nighthawk App cannot show 5G Main & Guest interfaces correctly. (2) The default 5G bandwidth becomes 80MHz. 
	valid_5G_channel_list="36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140 144 149 153 157 161 165 169 173 177"

	current_wla_hidden_channel="$(/bin/config get wla_hidden_channel)"
	current_wla_channel="$(/bin/config get wla_channel)"

	valid=0
	wla_valid=0
	wla_hidden_valid=0

	for channel in ${valid_5G_channel_list}
	do
	    if [ "${current_wla_channel}" = ${channel}  ] ; then
		wla_valid=1
		break
	    fi
	done

	for channel in ${valid_5G_channel_list}
	do
	    if [ "${current_wla_hidden_channel}" = ${channel}  ] ; then
		wla_hidden_valid=1
		break
	    fi
	done

	if [ ${wla_valid} = 1  -a  ${wla_hidden_valid} = 1 ]; then
	   valid=1 
	fi

	# Follow /etc/init.d/boot script, set default channel
	if [ ${valid} != 1 ]; then
	    if [ "${module_name}" = "RAX36" -o "${module_name}" = "RAX36S" ]; then
		/bin/config set wla_channel=36
		/bin/config set wla_hidden_channel=44
		/bin/config set wla_htmode="HT160"
		/bin/config set wla_simple_mode=10
		/bin/config set wla_ht160=1
	    else
		region="$(/sbin/artmtd -r region | grep REGION | awk '{print $2}')"
		case "$region" in
		NA|CA|PA)
		    /bin/config set wla_hidden_channel=153
		    ;;
		*)
		    /bin/config set wla_hidden_channel=44
		    ;;
		esac
		/bin/config set wla_channel=36
		/bin/config set wla_htmode="HT80"
		/bin/config set wla_simple_mode=9
		/bin/config set wla_ht160=0
	    fi
	fi
	# End of Fix [RAX10V2-0281] [RAX36][RAX36S][NH][iOS][Wireless] After App onboarding, (1) Nighthawk App cannot show 5G Main & Guest interfaces correctly. (2) The default 5G bandwidth becomes 80MHz. 

elif [ "${module_name}" = "RAX70" -o "${module_name}" = "RAX78" ]; then
	/bin/config set radio_number=0x7
	/bin/config set wl2g_int="wl1"
	/bin/config set wl5g1_int="wl2"
	/bin/config set wl5g2_int="wl0"
fi

