export PATH=${PATH}:/usr/sbin
WORKING_DIR=/home/kurth/tmp/mips
CHANNEL=14
#CHANNEL=11
# startup
insmod wlan
insmod ath_hal
insmod wlan_scan_sta
insmod ath_rate_minstrel
insmod ath_rate_sample
insmod ath_pci  countrycode=395 outdoor=1 # yes, you are Japan
#insmod ath_pci  outdoor=1
wlanconfig ath0 destroy 2>&1 || true
wlanconfig ath0 create wlandev wifi0 wlanmode monitor
iwconfig ath0 essid WiFiNoDe channel ${CHANNEL} rts off rate 1M
#iwconfig ath0 txpower
echo '804' > /proc/sys/net/ath0/dev_type
# ip is bogus, but there must be an ip set
ifconfig ath0 10.8.0.1 netmask 255.255.255.0 mtu 2290 up
#iwpriv ath0 mode 3      # 802.11bg
#iwpriv ath0 pureg 1     # disable b
#iwpriv ath0 protmode 0  # no ofdm protection
iwpriv ath0 wmm 0       # no multimedia
iwpriv ath0 ar 0        # no adaptive radio
iwpriv ath0 burst 0     # no burst
iwpriv ath0 ff 0        # no fast frame
iwpriv ath0 abolt 0     # no atheros proprietary in general
#iwconfig ath0 rate 1M
sysctl -w dev.wifi0.diversity=0
sysctl -w dev.wifi0.txantenna=1
sysctl -w dev.wifi0.rxantenna=1
sysctl -w dev.wifi0.intmit=0
sysctl -w net.ath0.monitor_phy_errors=0
sysctl -w net.ath0.monitor_crc_errors=0
cd ${WORKING_DIR} && ./click --allow-reconfigure -e "_simDeviceMaster :: SimDeviceMaster(TCP, 7777)" > out.txt 2>&1 &