mr scripts: dos2unix on some files
[wilink8-wlan/wl18xx-target-scripts.git] / mr / aGO_add.sh
1 #!/system/bin/sh
3 if [ "$1" == "" -o "$2" == "" ] ; then 
4         echo "Please insert parameters <IP> <NEW_aGO_CHANNEL> [MAC]" 
5         echo "MAC is optional" 
6         echo "ie: aGO_add.sh 10.2.47.6 6 08:00:28:13:33:38" 
7         exit 0 
8 fi
10 INSMOD=/system/bin/insmod
11 IFCONFIG=/system/xbin/busybox/ifconfig
12 HOSTAPD=/system/bin/hostapd
13 IW=/system/bin/iw
14 WPA_CLI=/system/bin/wpa_cli
15 HOSTAPD_CONF=/data/misc/wifi/hostapd.conf
16 P2P_CONF=/data/misc/wifi/p2p_supplicant.conf
17 SOCKET_PATH=/data/misc/wifi
19 SERVICE_SUPPLICANT=wpa_supplicant
20 SERVICE_HOSTAPD=hostapd_bin
22 WLAN_IF_SUT=wlan0
23 WLAN_IF_aGO=p2p_wlan0
24 WLAN_IP=$1
25 WLAN_NETMASK=255.255.255.0
26 MAC=$3
27 CHANNEL=$2
28 PHY=`ls /sys/class/ieee80211/`
29 DEV_NAME=p2p_blaze
30 GO_INTENT=7
31 CHANNEL_FREQ=0
33 if [ "$CHANNEL" -ge 149 ] ; then 
34         let "CHANNEL_FREQ = (($CHANNEL - 149) * 5) + 5745"
35 elif [ "$CHANNEL" -ge 36 ] ; then 
36         let "CHANNEL_FREQ = (($CHANNEL - 36) * 5) + 5180"
37 elif [ "$CHANNEL" -ge 1 ] ; then 
38         let "CHANNEL_FREQ = (($CHANNEL - 1) * 5) + 2412"
39 else
40         echo "CH in not in range" 
41 fi
43 echo "creating new interface"
44 $IW $PHY interface add $WLAN_IF_aGO type managed
45 sleep 1
47 if [ "$MAC" != "" ] ; then
48         echo "setting new mac" 
49         $IFCONFIG $WLAN_IF_aGO hw ether $MAC 
50 fi
52 echo "enable interface"
53 $IFCONFIG $WLAN_IF_aGO up $WLAN_IP netmask $WLAN_NETMASK
54 sleep 1
56 if [ ! -f $P2P_CONF ] ; then 
57         cp /etc/wifi/p2p_supplicant.conf $P2P_CONF 
58 fi
59 chmod 777 $P2P_CONF 
61 echo "loading p2p supplicant"
62 $SERVICE_SUPPLICANT -Dnl80211 -i $WLAN_IF_aGO -c $P2P_CONF -d &
63 sleep 1
65 echo "Configurating p2p parameters"
66 $WPA_CLI -i $WLAN_IF_aGO -p $SOCKET_PATH set device_name $DEV_NAME
67 $WPA_CLI -i $WLAN_IF_aGO -p $SOCKET_PATH set p2p_go_intent $GO_INTENT
68 sleep 1
70 echo "Starting aGO in ch : $CHANNEL_FREQ"
71 $WPA_CLI -i $WLAN_IF_aGO -p $SOCKET_PATH p2p_group_add freq=$CHANNEL_FREQ
72 sleep 1