mr scripts v1
authorIdo Reis <idor@ti.com>
Thu, 5 Jan 2012 17:53:49 +0000 (19:53 +0200)
committerIdo Reis <idor@ti.com>
Thu, 5 Jan 2012 17:53:49 +0000 (19:53 +0200)
17 files changed:
mr/ChToFreq.sh [new file with mode: 0755]
mr/FreqToCh.sh [new file with mode: 0755]
mr/HOW TO USE SCRIPTS.txt [new file with mode: 0644]
mr/Load Convert Scripts.ttl [new file with mode: 0644]
mr/Load MR Scripts.ttl [new file with mode: 0644]
mr/aGO_add.sh [new file with mode: 0755]
mr/aGO_remove.sh [new file with mode: 0755]
mr/ap_add.sh [changed mode: 0644->0755]
mr/ap_remove.sh [new file with mode: 0755]
mr/ap_start.sh [changed mode: 0644->0755]
mr/how to load ap multirole.txt [new file with mode: 0644]
mr/how to load sta multirole.txt [new file with mode: 0644]
mr/p2p_add.sh [new file with mode: 0755]
mr/p2p_remove.sh [new file with mode: 0755]
mr/p2p_supplicant.conf [new file with mode: 0644]
mr/sta_add.sh [new file with mode: 0755]
mr/sta_remove.sh [new file with mode: 0755]

diff --git a/mr/ChToFreq.sh b/mr/ChToFreq.sh
new file mode 100755 (executable)
index 0000000..6ceca0e
--- /dev/null
@@ -0,0 +1,16 @@
+CHANNEL=$1\r
+CHANNEL_FREQ=0\r
+\r
+if [ "$CHANNEL" -ge 149] ; then \r
+       let "CHANNEL_FREQ = (($CHANNEL - 149) * 5) + 5745"\r
+elif [ "$CHANNEL" -ge 36 ] ; then \r
+       let "CHANNEL_FREQ = (($CHANNEL - 36) * 5) + 5180"\r
+elif [ "$CHANNEL" -ge 1 ] ; then \r
+       let "CHANNEL_FREQ = (($CHANNEL - 1) * 5) + 2412"\r
+else\r
+       echo "CH in not in range" \r
+fi\r
+\r
+echo $CHANNEL_FREQ\r
+\r
+\r
diff --git a/mr/FreqToCh.sh b/mr/FreqToCh.sh
new file mode 100755 (executable)
index 0000000..0d3beb8
--- /dev/null
@@ -0,0 +1,17 @@
+CHANNEL_FREQ=$1\r
+echo $CHANNEL_FREQ\r
+CHANNEL=0\r
+\r
+if [ "$CHANNEL_FREQ" -ge 5745 ] ; then \r
+       let "CHANNEL = (($CHANNEL_FREQ - 5745) / 5) + 149"\r
+elif [ "$CHANNEL_FREQ" -ge 5180 ] ; then \r
+       let "CHANNEL = (($CHANNEL_FREQ - 5180) / 5) + 36"\r
+elif [ "$CHANNEL_FREQ" -ge 2412 ] ; then \r
+       let "CHANNEL = (($CHANNEL_FREQ - 2412) / 5) + 1"\r
+else\r
+       echo "FREQ in not in range" \r
+fi\r
+\r
+echo $CHANNEL\r
+\r
+\r
diff --git a/mr/HOW TO USE SCRIPTS.txt b/mr/HOW TO USE SCRIPTS.txt
new file mode 100644 (file)
index 0000000..46170c0
--- /dev/null
@@ -0,0 +1,82 @@
+######################################## Texas Instruments - D2I #########################################\r
+###### Before begining to use MR script you must start as STA or AP ( sta_start.sh or ap_start.sh ) ###### \r
+###### <> -- Mandatory parameter                                                                                                                                       ######\r
+###### [] -- Optional parameter                                                                                                                                        ######\r
+###### Script version : v1.1                                                                                                                                           ######\r
+##########################################################################################################\r
+\r
+** All scripts can be loaded to /data/misc/wifi using "Load MR Scripts.ttl" in Tera Term Application.\r
+       \r
+1. sta_add.sh <IP> <New AP Channel> [MAC]\r
+       Parameters  \r
+               1. <IP> - Added STA IP\r
+               2. <New AP Channel> - If required channel is different then hostapd.conf channel, AP will be restarted with required channel. \r
+                                                         "0" says to skip AP reconfiguration. \r
+                                                         Channel enter as number and not as FREQ.\r
+               3. [MAC] - Added STA MAC\r
+\r
+       Example\r
+               1. "sh sta_add.sh 10.2.46.5 11 08:00:28:13:33:36"\r
+                       It means new role of STA will load and AP will be restarted if his current channel is diffrent when 11.\r
+               2. "sh sta_add.sh 10.2.46.5 0"\r
+                       It means new role of STA will load and AP will not be restarted.\r
+                       \r
+2. sta_remove.sh (removes wlan0 interface)     \r
+       Parameters  \r
+               None\r
+               \r
+-----------------------------------------------------------------------------------------------------------\r
+       \r
+3. ap_add.sh <IP> <New AP Channel> [MAC]\r
+       Parameters  \r
+               1. <IP> - Added AP IP\r
+               2. <New AP Channel> - Added AP will be load in required channel.\r
+                                                         Channel enter as number and not as FREQ.\r
+               3. [MAC] - Added AP MAC\r
+       \r
+       Example\r
+               1. "sh ap_add.sh 10.2.46.5 11 08:00:28:13:33:36"\r
+                       It means new role of AP will load and AP will transmit beacon on required channel.\r
+\r
+4. ap_remove.sh (removes wlan1 and mon.wlan1 interfaces)\r
+       Parameters  \r
+               None\r
+\r
+-----------------------------------------------------------------------------------------------------------\r
+\r
+5. aGO_add.sh <IP> <New aGO Channel> [MAC]\r
+       Parameters  \r
+               1. <IP> - Added aGO IP\r
+               2. <New aGO Channel> - Added aGO will be load in required channel.\r
+                                                         Channel enter as number and not as FREQ.\r
+               3. [MAC] - Added aGO MAC\r
+       \r
+       Example\r
+               1. "sh aGO_add.sh 10.2.46.5 11 08:00:28:13:33:36"\r
+                       It means new role of aGO will load and aGO will transmit beacon on required channel.\r
+\r
+6. aGO_remove.sh (removes p2p_wlan0 and mon.p2p_wlan0 interfaces)\r
+       Parameters  \r
+               None\r
+\r
+-----------------------------------------------------------------------------------------------------------\r
+\r
+7. p2p_add.sh <IP> [MAC]\r
+       Parameters  \r
+               1. <IP> - Added P2P Device IP\r
+               2. [MAC] - Added P2P Device MAC\r
+       \r
+       Example\r
+               1. "sh p2p_add.sh 10.2.46.5 08:00:28:13:33:36"\r
+                       It means new role of P2P Device will load.\r
+\r
+8. p2p_remove.sh (removes p2p_wlan0 interface)\r
+       Parameters  \r
+               None\r
+\r
+               \r
+\r
+\r
+               \r
+               \r
+               
\ No newline at end of file
diff --git a/mr/Load Convert Scripts.ttl b/mr/Load Convert Scripts.ttl
new file mode 100644 (file)
index 0000000..b3869fc
--- /dev/null
@@ -0,0 +1,8 @@
+sendln 'cd /data/misc/wifi/'\r
+sendln 'sh remount_rw.sh'\r
+sendln 'rm -r FreqToCh.sh'\r
+sendln 'rm -r ChToFreq.sh'\r
+sendln 'ftpget 20.1.1.10 FreqToCh.sh FreqToCh.sh'\r
+sendln 'ftpget 20.1.1.10 ChToFreq.sh ChToFreq.sh'\r
+sendln 'chmod 777 *'\r
+sendln 'dos2unix *.sh'\r
diff --git a/mr/Load MR Scripts.ttl b/mr/Load MR Scripts.ttl
new file mode 100644 (file)
index 0000000..1724370
--- /dev/null
@@ -0,0 +1,39 @@
+sendln 'cd /data/misc/wifi/'\r
+sendln 'sh remount_rw.sh'\r
+pause 1\r
+sendln 'rm -r aGO_add.sh'\r
+sendln 'rm -r aGO_remove.sh'\r
+\r
+sendln 'rm -r p2p_add.sh'\r
+sendln 'rm -r p2p_remove.sh'\r
+\r
+sendln 'rm -r p2p_supplicant.conf'\r
+\r
+sendln 'rm -r ap_add.sh'\r
+sendln 'rm -r ap_remove.sh'\r
+\r
+sendln 'rm -r sta_add.sh'\r
+sendln 'rm -r sta_remove.sh'\r
+\r
+\r
+pause 1 \r
+sendln 'ftpget 20.1.1.10 aGO_add.sh aGO_add.sh'\r
+sendln 'ftpget 20.1.1.10 aGO_remove.sh aGO_remove.sh'\r
+\r
+sendln 'ftpget 20.1.1.10 p2p_add.sh p2p_add.sh'\r
+sendln 'ftpget 20.1.1.10 p2p_remove.sh p2p_remove.sh'\r
+\r
+sendln 'ftpget 20.1.1.10 p2p_supplicant.conf p2p_supplicant.conf'\r
+\r
+sendln 'ftpget 20.1.1.10 ap_add.sh ap_add.sh'\r
+sendln 'ftpget 20.1.1.10 ap_remove.sh ap_remove.sh'\r
+\r
+sendln 'ftpget 20.1.1.10 sta_add.sh sta_add.sh'\r
+sendln 'ftpget 20.1.1.10 sta_remove.sh sta_remove.sh'\r
+\r
+pause 1\r
+sendln 'chmod 777 *'\r
+pause 1\r
+sendln 'dos2unix *.sh'\r
+pause 1\r
+sendln 'sync'
\ No newline at end of file
diff --git a/mr/aGO_add.sh b/mr/aGO_add.sh
new file mode 100755 (executable)
index 0000000..3d497d5
--- /dev/null
@@ -0,0 +1,75 @@
+#!/system/bin/sh\r
+\r
+if [ "$1" == "" -o "$2" == "" ] ; then \r
+       echo "Please insert parameters <IP> <NEW_aGO_CHANNEL> [MAC]" \r
+       echo "MAC is optional" \r
+       echo "ie: aGO_add.sh 10.2.47.6 6 08:00:28:13:33:38" \r
+       exit 0 \r
+fi\r
+\r
+INSMOD=/system/bin/insmod\r
+IFCONFIG=/system/xbin/busybox/ifconfig\r
+HOSTAPD=/system/bin/hostapd\r
+IW=/system/bin/iw\r
+WPA_CLI=/system/bin/wpa_cli\r
+HOSTAPD_CONF=/data/misc/wifi/hostapd.conf\r
+P2P_CONF=/data/misc/wifi/p2p_supplicant.conf\r
+SOCKET_PATH=/data/misc/wifi\r
+\r
+SERVICE_SUPPLICANT=wpa_supplicant\r
+SERVICE_HOSTAPD=hostapd_bin\r
+\r
+WLAN_IF_SUT=wlan0\r
+WLAN_IF_aGO=p2p_wlan0\r
+WLAN_IP=$1\r
+WLAN_NETMASK=255.255.255.0\r
+MAC=$3\r
+CHANNEL=$2\r
+PHY=`ls /sys/class/ieee80211/`\r
+DEV_NAME=p2p_blaze\r
+GO_INTENT=7\r
+CHANNEL_FREQ=0\r
+\r
+if [ "$CHANNEL" -ge 149 ] ; then \r
+       let "CHANNEL_FREQ = (($CHANNEL - 149) * 5) + 5745"\r
+elif [ "$CHANNEL" -ge 36 ] ; then \r
+       let "CHANNEL_FREQ = (($CHANNEL - 36) * 5) + 5180"\r
+elif [ "$CHANNEL" -ge 1 ] ; then \r
+       let "CHANNEL_FREQ = (($CHANNEL - 1) * 5) + 2412"\r
+else\r
+       echo "CH in not in range" \r
+fi\r
+\r
+echo "creating new interface"\r
+$IW $PHY interface add $WLAN_IF_aGO type managed\r
+sleep 1\r
+\r
+if [ "$MAC" != "" ] ; then\r
+       echo "setting new mac" \r
+       $IFCONFIG $WLAN_IF_aGO hw ether $MAC \r
+fi\r
+\r
+echo "enable interface"\r
+$IFCONFIG $WLAN_IF_aGO up $WLAN_IP netmask $WLAN_NETMASK\r
+sleep 1\r
+\r
+if [ ! -f $P2P_CONF ] ; then \r
+       cp /etc/wifi/p2p_supplicant.conf $P2P_CONF \r
+fi\r
+chmod 777 $P2P_CONF \r
+\r
+echo "loading p2p supplicant"\r
+$SERVICE_SUPPLICANT -Dnl80211 -i $WLAN_IF_aGO -c $P2P_CONF -d &\r
+sleep 1\r
+\r
+echo "Configurating p2p parameters"\r
+$WPA_CLI -i $WLAN_IF_aGO -p $SOCKET_PATH set device_name $DEV_NAME\r
+$WPA_CLI -i $WLAN_IF_aGO -p $SOCKET_PATH set p2p_go_intent $GO_INTENT\r
+sleep 1\r
+\r
+echo "Starting aGO in ch : $CHANNEL_FREQ"\r
+$WPA_CLI -i $WLAN_IF_aGO -p $SOCKET_PATH p2p_group_add freq=$CHANNEL_FREQ\r
+sleep 1\r
+\r
+\r
+\r
diff --git a/mr/aGO_remove.sh b/mr/aGO_remove.sh
new file mode 100755 (executable)
index 0000000..78858c0
--- /dev/null
@@ -0,0 +1,28 @@
+#!/system/bin/sh
+
+INSMOD=/system/bin/insmod
+RMMOD=/system/bin/rmmod
+IFCONFIG=/system/bin/ifconfig
+WPA_CLI=/system/bin/wpa_cli
+IW=/system/bin/iw
+
+WLAN_IF=p2p_wlan0
+WLAN_IF_MON=mon.$WLAN_IF
+WLAN_PID=`ps | grep [p2p_]wlan0 | cut -f3 -d' '`
+
+SERVICE_SUPPLICANT=wpa_supplicant
+
+echo "unload supplicant"
+kill $WLAN_PID
+sleep 1
+
+echo "disable interface"
+$IFCONFIG $WLAN_IF down
+$IFCONFIG $WLAN_IF_MON down
+sleep 1
+
+echo "Removing interface"
+$IW $WLAN_IF del
+sleep 1
+
+
old mode 100644 (file)
new mode 100755 (executable)
index 2a5f031..3b7547b
@@ -1,66 +1,56 @@
-#!/system/bin/sh
-
-INSMOD=/system/bin/insmod
-IFCONFIG=/system/bin/ifconfig
-HOSTAPD=/system/bin/hostapd
-IW=/system/bin/iw
-HOSTAPD_CONF=/data/misc/wifi/hostapd.conf
-
-if [ "$1"=="" -a "$2"=="" ]; then
-echo "please give MAC and desired MAC address - exiting ..." ; exit 1; fi
-
-WLAN1_MAC=$1
-STA_CHANNEL=$2
-WLAN_IF=wlan1
-WLAN_IP=192.168.43.1
-WLAN_NETMASK=255.255.255.0
-
-SERVICE_SUPPLICANT=wpa_supplicant
-SERVICE_HOSTAPD=hostapd_bin
-
-SUPP_STAT=`getprop init.svc.$SERVICE_SUPPLICANT`
-echo "wpa_supplicant state: $SUPP_STAT"
-
-HOSTAPD_STAT=`getprop init.svc.$SERVICE_HOSTAPD`
-echo "hostapd state: $HOSTAPD_STAT"
-if [ "$HOSTAPD_STAT" == "running" ] ; then echo "hostapd is in running state, exiting..." ; exit 0 ; fi
-
-
-sleep 1
-iw wlan0 set power_save off
-
-echo "creating new interface"
-$IW `ls /sys/class/ieee80211/` interface add wlan1 type managed
-ifconfig wlan1 hw ether $WLAN1_MAC
-
-if [ ! -f $HOSTAPD_CONF ] ; then \
-       cp /etc/wifi/hostapd.conf $HOSTAPD_CONF ; \
-       chmod 777 $HOSTAPD_CONF ; \
-fi
-
-echo "loading hostapd"
-echo "setting the correct channel"
-sed s/channel=[0-9]*/channel=$STA_CHANNEL/ $HOSTAPD_CONF > /data/misc/wifi/tmp.conf
-mv -f /data/misc/wifi/tmp.conf $HOSTAPD_CONF
-
-sleep 1
-setprop ctl.start $SERVICE_HOSTAPD
-sleep 2
-
-echo "enable interface"
-$IFCONFIG $WLAN_IF up $WLAN_IP netmask $WLAN_NETMASK
-sleep 1
-$IFCONFIG $WLAN_IF
-sleep 2
-
-echo "starting dhcp deamon"
-udhcpd -f dhcpd.conf &
-
-
-
-
-
-
-
-
-
+#!/system/bin/sh\r
+\r
+if [ "$1" == "" -o "$2" == "" ] ; then \r
+       echo "Please insert parameters <IP> <NEW_APUT_CHANNEL> [MAC]" \r
+       echo "MAC is optional" \r
+       echo "ie: ap_add.sh 10.2.47.6 11 08:00:28:13:33:38" \r
+       exit 0 \r
+fi\r
+\r
+INSMOD=/system/bin/insmod\r
+IFCONFIG=/system/xbin/busybox/ifconfig\r
+HOSTAPD=/system/bin/hostapd\r
+IW=/system/bin/iw\r
+HOSTAPD_CONF=/data/misc/wifi/hostapd.conf\r
+\r
+WLAN_IF_SUT=wlan0\r
+WLAN_IF_APUT=wlan1\r
+WLAN_IP=$1\r
+WLAN_NETMASK=255.255.255.0\r
+MAC=$3\r
+CHANNEL=$2\r
+PHY=`ls /sys/class/ieee80211/`\r
+\r
+SERVICE_SUPPLICANT=wpa_supplicant\r
+SERVICE_HOSTAPD=hostapd_bin\r
+\r
+echo "setting regulatory domain"\r
+$IW reg set `grep country_code= $HOSTAPD_CONF | sed "s:country_code=::"`\r
+$IW reg get\r
+\r
+echo "creating new interface"\r
+$IW $PHY interface add $WLAN_IF_APUT type managed\r
+sleep 1\r
+\r
+if [ "$MAC" != "" ] ; then\r
+       echo "setting new mac" \r
+       $IFCONFIG $WLAN_IF_APUT hw ether $MAC \r
+fi\r
+\r
+if [ ! -f $HOSTAPD_CONF ] ; then \r
+       cp /etc/wifi/hostapd.conf $HOSTAPD_CONF \r
+fi\r
+chmod 777 $HOSTAPD_CONF \r
+\r
+sed -i 's/^channel=[0-9,a-z,A-Z,_,$, ,]*/channel='$CHANNEL'/' $HOSTAPD_CONF\r
+\r
+echo "loading hostapd"\r
+setprop ctl.start $SERVICE_HOSTAPD\r
+sleep 2\r
+\r
+echo "enable interface"\r
+$IFCONFIG $WLAN_IF_APUT $WLAN_IP netmask $WLAN_NETMASK\r
+sleep 1\r
+\r
+echo "starting dhcp deamon"\r
+udhcpd -f dhcpd.conf &\r
diff --git a/mr/ap_remove.sh b/mr/ap_remove.sh
new file mode 100755 (executable)
index 0000000..4458e50
--- /dev/null
@@ -0,0 +1,29 @@
+#!/system/bin/sh
+
+INSMOD=/system/bin/insmod
+RMMOD=/system/bin/rmmod
+IFCONFIG=/system/bin/ifconfig
+HOSTAPD_CLI=/system/bin/wpa_cli
+IW=/system/bin/iw
+
+WLAN_IF=wlan1
+WLAN_IF_MON=mon.$WLAN_IF
+
+SERVICE_HOSTAPD=hostapd_bin
+
+echo "kill udhcpd"
+killall udhcpd
+
+echo "unload hostapd"
+setprop ctl.stop $SERVICE_HOSTAPD
+sleep 1
+
+echo "disable interface"
+$IFCONFIG $WLAN_IF down
+$IFCONFIG $WLAN_IF_MON down
+sleep 1
+
+echo "Removing interface"
+$IW $WLAN_IF del
+sleep 1
+
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/mr/how to load ap multirole.txt b/mr/how to load ap multirole.txt
new file mode 100644 (file)
index 0000000..a579360
--- /dev/null
@@ -0,0 +1,17 @@
+sta then ap\r
+\r
+\r
+iw reg set `grep country_code= /data/misc/wifi/hostapd.conf | sed "s:country_code=::"`\r
+iw reg get\r
+\r
+iw phy0 interface add wlan1 type managed\r
+ifconfig wlan1 hw ether 08:00:28:13:33:38\r
+\r
+ifconfig wlan1 10.2.46.7 netmask 255.255.255.0\r
+\r
+/system/bin/hostapd -d /data/misc/wifi/hostapd.conf &\r
+\r
+\r
+\r
+\r
+\r
diff --git a/mr/how to load sta multirole.txt b/mr/how to load sta multirole.txt
new file mode 100644 (file)
index 0000000..836644a
--- /dev/null
@@ -0,0 +1,6 @@
+\r
+iw phy1 interface add wlan0 type managed\r
+\r
+ifconfig wlan0 hw ether 08:00:28:13:33:38\r
+\r
+setprop ctl.start "wpa_supplicant:-iwlan0 -c/data/misc/wifi/wpa_supplicant.conf"
\ No newline at end of file
diff --git a/mr/p2p_add.sh b/mr/p2p_add.sh
new file mode 100755 (executable)
index 0000000..2ab4bd7
--- /dev/null
@@ -0,0 +1,52 @@
+#!/system/bin/sh\r
+\r
+if [ "$1" == "" -o "$2" == "" ] ; then \r
+       echo "Please insert parameters <IP> [MAC]" \r
+       echo "MAC is optional" \r
+       echo "ie: p2p_add.sh 10.2.47.6 08:00:28:13:33:38" \r
+       exit 0 \r
+fi\r
+\r
+INSMOD=/system/bin/insmod\r
+IFCONFIG=/system/xbin/busybox/ifconfig\r
+HOSTAPD=/system/bin/hostapd\r
+IW=/system/bin/iw\r
+WPA_CLI=/system/bin/wpa_cli\r
+HOSTAPD_CONF=/data/misc/wifi/hostapd.conf\r
+P2P_CONF=/data/misc/wifi/p2p_supplicant.conf\r
+SOCKET_PATH=/data/misc/wifi\r
+\r
+SERVICE_SUPPLICANT=wpa_supplicant\r
+SERVICE_HOSTAPD=hostapd_bin\r
+\r
+WLAN_IF_SUT=wlan0\r
+WLAN_IF_aGO=p2p_wlan0\r
+WLAN_IP=$1\r
+WLAN_NETMASK=255.255.255.02\r
+MAC=$2\r
+PHY=`ls /sys/class/ieee80211/`\r
+\r
+\r
+echo "creating new interface"\r
+$IW $PHY interface add $WLAN_IF_aGO type managed\r
+sleep 1\r
+\r
+if [ "$MAC" != "" ] ; then\r
+       echo "setting new mac" \r
+       $IFCONFIG $WLAN_IF_aGO hw ether $MAC \r
+fi\r
+\r
+echo "enable interface"\r
+$IFCONFIG $WLAN_IF_aGO up $WLAN_IP netmask $WLAN_NETMASK\r
+sleep 1\r
+\r
+if [ ! -f $P2P_CONF ] ; then \r
+       cp /etc/wifi/p2p_supplicant.conf $P2P_CONF \r
+fi\r
+chmod 777 $P2P_CONF \r
+\r
+echo "loading p2p supplicant"\r
+$SERVICE_SUPPLICANT -Dnl80211 -i $WLAN_IF_aGO -c $P2P_CONF -d &\r
+sleep 1\r
+\r
+\r
diff --git a/mr/p2p_remove.sh b/mr/p2p_remove.sh
new file mode 100755 (executable)
index 0000000..78858c0
--- /dev/null
@@ -0,0 +1,28 @@
+#!/system/bin/sh
+
+INSMOD=/system/bin/insmod
+RMMOD=/system/bin/rmmod
+IFCONFIG=/system/bin/ifconfig
+WPA_CLI=/system/bin/wpa_cli
+IW=/system/bin/iw
+
+WLAN_IF=p2p_wlan0
+WLAN_IF_MON=mon.$WLAN_IF
+WLAN_PID=`ps | grep [p2p_]wlan0 | cut -f3 -d' '`
+
+SERVICE_SUPPLICANT=wpa_supplicant
+
+echo "unload supplicant"
+kill $WLAN_PID
+sleep 1
+
+echo "disable interface"
+$IFCONFIG $WLAN_IF down
+$IFCONFIG $WLAN_IF_MON down
+sleep 1
+
+echo "Removing interface"
+$IW $WLAN_IF del
+sleep 1
+
+
diff --git a/mr/p2p_supplicant.conf b/mr/p2p_supplicant.conf
new file mode 100644 (file)
index 0000000..c4c81cb
--- /dev/null
@@ -0,0 +1,9 @@
+update_config=1
+ctrl_interface=/data/misc/wifi
+ap_scan=1
+fast_reauth=1
+device_name=Blaze
+manufacturer=TexasInstruments
+model_name=TI_Connectivity_module
+model_number=wl12xx
+serial_number=12345
diff --git a/mr/sta_add.sh b/mr/sta_add.sh
new file mode 100755 (executable)
index 0000000..9b87b1d
--- /dev/null
@@ -0,0 +1,95 @@
+#!/system/bin/sh
+
+if [ "$1" == "" ] ; then 
+       echo "Please insert parameters <IP> <NEW_APUT_CHANNEL> [MAC]" 
+       echo "MAC is optional, if don't want to change APUT CH then enter second parameter: 0" 
+       echo "ie: sta_add.sh 10.2.47.6 11 08:00:28:13:33:38" 
+       exit 0 
+fi
+
+IW=/system/bin/iw
+INSMOD=/system/bin/insmod
+IFCONFIG=/system/xbin/busybox/ifconfig
+WPA_SUPPLICANT=/system/bin/wpa_supplicant
+
+SUPPLICANT_CONF=/data/misc/wifi/wpa_supplicant.conf
+HOSTAPD_CONF=/data/misc/wifi/hostapd.conf
+
+AP_START=/data/misc/wifi/ap_start.sh
+AP_STOP=/data/misc/wifi/ap_stop.sh
+
+WLAN_IF_SUT=wlan0
+WLAN_IF_APUT=wlan1
+WLAN_IP=$1
+WLAN_NETMASK=255.255.255.0
+MAC=$3
+CHANNEL=$2
+PHY=`ls /sys/class/ieee80211/`
+CURRENT_AP_CHANNEL=`grep channel= $HOSTAPD_CONF | sed "s:channel=::"`
+
+SERVICE_SUPPLICANT=wpa_supplicant
+SERVICE_HOSTAPD=hostapd_bin
+
+echo "adding interface"
+$IW $PHY interface add $WLAN_IF_SUT type managed
+sleep 1
+
+if [ "$MAC" != "" ] ; then
+       echo "setting new mac" 
+       $IFCONFIG $WLAN_IF_SUT hw ether $MAC 
+fi
+
+echo "enable interface"
+$IFCONFIG $WLAN_IF_SUT up $WLAN_IP netmask $WLAN_NETMASK
+sleep 1
+
+if [ ! -f $SUPPLICANT_CONF ] ; then 
+       cp /etc/wifi/wpa_supplicant.conf $SUPPLICANT_CONF 
+fi
+chmod 777 $SUPPLICANT_CONF 
+
+echo "loading supplicant"
+setprop ctl.start "$SERVICE_SUPPLICANT:-i$WLAN_IF_SUT -c$SUPPLICANT_CONF"
+sleep 1
+
+if [ "$CHANNEL" != "$CURRENT_AP_CHANNEL" ] && [ "$CHANNEL" != "0" ] ; then
+       #-------------------------- CHannel Change --------------------
+       sed -i 's/^channel=[0-9,a-z,A-Z,_,$, ,]*/channel='$CHANNEL'/' $HOSTAPD_CONF 
+
+       #---------------------------- STOP_APUT -----------------------
+       echo "kill udhcpd" 
+       killall udhcpd 
+
+       echo "unload hostapd" 
+       setprop ctl.stop $SERVICE_HOSTAPD 
+       sleep 1 
+
+       echo "disable interface" 
+       $IFCONFIG $WLAN_IF_APUT down 
+       #---------------------------- STOP_APUT -----------------------
+
+       sleep 3
+       #---------------------------- START_APUT -----------------------
+       echo "loading hostapd" 
+       setprop ctl.start $SERVICE_HOSTAPD 
+       sleep 2 
+
+       echo "enable interface" 
+       $IFCONFIG $WLAN_IF_APUT up  
+
+       echo "starting dhcp deamon" 
+       udhcpd -f dhcpd.conf & 
+       #---------------------------- START_APUT -----------------------
+fi
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mr/sta_remove.sh b/mr/sta_remove.sh
new file mode 100755 (executable)
index 0000000..55b5063
--- /dev/null
@@ -0,0 +1,25 @@
+#!/system/bin/sh
+
+INSMOD=/system/bin/insmod
+RMMOD=/system/bin/rmmod
+IFCONFIG=/system/bin/ifconfig
+WPA_CLI=/system/bin/wpa_cli
+IW=/system/bin/iw
+
+WLAN_IF=wlan0
+
+SERVICE_SUPPLICANT=wpa_supplicant
+
+echo "unload supplicant"
+setprop ctl.stop $SERVICE_SUPPLICANT
+sleep 1
+
+echo "disable interface"
+$IFCONFIG $WLAN_IF down
+sleep 1
+
+echo "Removing interface"
+$IW $WLAN_IF del
+sleep 1
+
+