mr scripts v1
[wilink8-wlan/wl18xx-target-scripts.git] / mr / p2p_add.sh
1 #!/system/bin/sh\r
2 \r
3 if [ "$1" == "" -o "$2" == "" ] ; then \r
4         echo "Please insert parameters <IP> [MAC]" \r
5         echo "MAC is optional" \r
6         echo "ie: p2p_add.sh 10.2.47.6 08:00:28:13:33:38" \r
7         exit 0 \r
8 fi\r
9 \r
10 INSMOD=/system/bin/insmod\r
11 IFCONFIG=/system/xbin/busybox/ifconfig\r
12 HOSTAPD=/system/bin/hostapd\r
13 IW=/system/bin/iw\r
14 WPA_CLI=/system/bin/wpa_cli\r
15 HOSTAPD_CONF=/data/misc/wifi/hostapd.conf\r
16 P2P_CONF=/data/misc/wifi/p2p_supplicant.conf\r
17 SOCKET_PATH=/data/misc/wifi\r
18 \r
19 SERVICE_SUPPLICANT=wpa_supplicant\r
20 SERVICE_HOSTAPD=hostapd_bin\r
21 \r
22 WLAN_IF_SUT=wlan0\r
23 WLAN_IF_aGO=p2p_wlan0\r
24 WLAN_IP=$1\r
25 WLAN_NETMASK=255.255.255.02\r
26 MAC=$2\r
27 PHY=`ls /sys/class/ieee80211/`\r
28 \r
29 \r
30 echo "creating new interface"\r
31 $IW $PHY interface add $WLAN_IF_aGO type managed\r
32 sleep 1\r
33 \r
34 if [ "$MAC" != "" ] ; then\r
35         echo "setting new mac" \r
36         $IFCONFIG $WLAN_IF_aGO hw ether $MAC \r
37 fi\r
38 \r
39 echo "enable interface"\r
40 $IFCONFIG $WLAN_IF_aGO up $WLAN_IP netmask $WLAN_NETMASK\r
41 sleep 1\r
42 \r
43 if [ ! -f $P2P_CONF ] ; then \r
44         cp /etc/wifi/p2p_supplicant.conf $P2P_CONF \r
45 fi\r
46 chmod 777 $P2P_CONF \r
47 \r
48 echo "loading p2p supplicant"\r
49 $SERVICE_SUPPLICANT -Dnl80211 -i $WLAN_IF_aGO -c $P2P_CONF -d &\r
50 sleep 1\r
51 \r
52 \r