#!/system/bin/busybox sh
chmod 777 /data/misc/widi_socket
case $1 in
RAL5370)
insmod /system/lib/modules/widi/rtutil5572sta.ko
insmod /system/lib/modules/widi/rt5572sta.ko
insmod /system/lib/modules/widi/rtnet5572sta.ko
busybox ifconfig ra0 up
busybox ifconfig p2p0 up
busybox ifconfig
iwpriv ra0 set WpaSupport=0
iwpriv ra0 set AutoReconnect=1
iwpriv ra0 set WidiEnable=1
iwpriv ra0 set p2pWidiEnable=1
;;
RTL8192CU)
insmod /system/lib/modules/cfg80211.ko
insmod /system/lib/modules/widi/wlan.ko
busybox ifconfig wlan0 up
sleep 1
;;
RTL8192EU)
insmod /system/lib/modules/cfg80211.ko
insmod /system/lib/modules/widi/8192eu.ko
busybox ifconfig wlan0 up
sleep 1
;;
ATH1021)
insmod /system/lib/modules/widi/compat.ko
insmod /system/lib/modules/widi/cfg80211_ath6k.ko
insmod /system/lib/modules/widi/ath6kl_usb.ko chip_pwd_l=0 ht40_24ghz=1 htcoex=1 ath6kl_p2p=1
iw dev wlan0 interface add p2p0 type managed
sleep 1
iw dev wlan0 set power_save off
iw dev p2p0 set power_save off
busybox ifconfig wlan0 up
busybox ifconfig p2p0 up
;;
ATH9375)
insmod /system/lib/modules/widi/compat_9375.ko
insmod /system/lib/modules/widi/cfg80211_ath6k_9375.ko
insmod /system/lib/modules/widi/ath6kl_usb_9375.ko ath6kl_p2p=0x19 debug_quirks=0x200
sleep 1
iw dev wlan0 set power_save off
iw dev p2p0 set power_save off
busybox ifconfig wlan0 up
busybox ifconfig p2p0 up
;;
ATH9374)
insmod /system/lib/modules/widi/compat_9374.ko
insmod /system/lib/modules/widi/cfg80211_ath6k_9374.ko
insmod /system/lib/modules/widi/ath6kl_usb_9374.ko chip_pwd_l=0 ht40_24ghz=1 htcoex=1 ath6kl_p2p=1
iw dev wlan0 interface add p2p0 type managed
sleep 1
iw dev wlan0 set power_save off
iw dev p2p0 set power_save off
busybox ifconfig wlan0 up
busybox ifconfig p2p0 up
;;
*)
echo "no driver!!!"
;;
esac

busybox sysctl -w net.core.rmem_max=8388608

if [ ! -f /data/adapter.config ]; then
  echo "/data/adapter.config does not exist, copy /data/adapter.config"
  busybox cp /etc/Wireless/adapter.config /data/adapter.config
  busybox chmod 777 /data/adapter.config
fi

if [ ! -f /data/profiles.config ]; then
  echo "/data/profiles.config does not exist, touch /Customer/profiles.config"
  touch /data/profiles.config
  busybox chmod 777 /data/profiles.config
fi

if [ ! -f /Customer/qrdata.config ]; then
  echo "/Customer/qrdata.config does not exist, copy /Customer/qrdata.config"
  busybox cp /etc/Wireless/qrdata.config /Customer/qrdata.config
  busybox chmod 777 /Customer/qrdata.config
fi
