blob: 922935ecad79339bf88b18b1b5716b8baf2f75e6 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#!/bin/sh
2#
3# script file to start network
4#
5# Usage: wps_init.sh {pbc | pin} {PINNUM}
6#
7
8##if [ $# -lt 2 ]; then echo "Usage: $0 {gw | ap} {all | bridge | wan}"; exit 1 ; fi
9ROOT=`nv get wifi_root_dir`
10LOG=$ROOT/wifi/realtek/slog
11
12CONFIG_ROOT_DIR="$ROOT/wifi/realtek/rtl8192c"
13
14ID=`nv get wifi_wps_index`
15echo "enter wps init.sh wifi_wps_index=$ID >>>>>>>>" >> $LOG
16ID=`expr $ID - 1`
17echo "enter wps init.sh ID=$ID >>>>>>>>" >> $LOG
18
19if [ "$ID" = "0" ];then
20#CONFIG_DIR=$CONFIG_ROOT_DIR/wlan0
21#WLAN_INTERFACE="wlan0"
22CONFIG_DIR=$CONFIG_ROOT_DIR/wlan0-va$ID
23WLAN_INTERFACE="wlan0-va$ID"
24else
25CONFIG_DIR=$CONFIG_ROOT_DIR/wlan0-va$ID
26WLAN_INTERFACE="wlan0-va$ID"
27fi
28
29echo "enter wps init.sh $CONFIG_DIR >>>>>>>>" >> $LOG
30if [ -z "$SCRIPT_DIR" ]; then
31 SCRIPT_DIR=`cat $CONFIG_ROOT_DIR/wifi_script_dir`
32fi
33START_WLAN_APP=$SCRIPT_DIR/wlanapp_8192c.sh
34echo "0" > $CONFIG_DIR/wsc_upnp_enabled
35echo "1" > $CONFIG_DIR/wsc_configured
36echo "0" > $CONFIG_DIR/wsc_disabled
37if [ $1 = "pbc" ]; then
38 echo "2" > $CONFIG_DIR/wsc_method
39else
40 echo "1" > $CONFIG_DIR/wsc_method
41 echo $2 > $CONFIG_DIR/wsc_pin
42fi
43
44echo "<<<<<wps init $1 $2 >>>>>>>>" >> $LOG
45
46
47GET_WLAN_ENCRYPT=`cat $CONFIG_DIR/encrypt`
48if [ "$GET_WLAN_ENCRYPT" = "2" ]; then #WPAPSK
49 echo "2" > $CONFIG_DIR/wsc_auth
50 GET_WLAN_AUTH=`cat $CONFIG_DIR/wpa_cipher`
51 if [ "$GET_WLAN_AUTH" = "1" ]; then #TKIP
52 echo "4" > $CONFIG_DIR/wsc_enc
53 elif [ "$GET_WLAN_AUTH" = "2" ]; then #AES
54 echo "8" > $CONFIG_DIR/wsc_enc
55 else #TKIPAES
56 echo "12" > $CONFIG_DIR/wsc_enc
57 fi
58 GET_PSK=`cat $CONFIG_DIR/wpa_psk`
59 echo $GET_PSK > $CONFIG_DIR/wsc_psk
60elif [ "$GET_WLAN_ENCRYPT" = "4" ]; then #WPA2PSK
61 echo "32" > $CONFIG_DIR/wsc_auth
62 if [ "$GET_WLAN_AUTH" = "1" ]; then #TKIP
63 echo "4" > $CONFIG_DIR/wsc_enc
64 elif [ "$GET_WLAN_AUTH" = "2" ]; then #AES
65 echo "8" > $CONFIG_DIR/wsc_enc
66 else #TKIPAES
67 echo "12" > $CONFIG_DIR/wsc_enc
68 fi
69 GET_PSK=`cat $CONFIG_DIR/wpa_psk`
70 echo $GET_PSK > $CONFIG_DIR/wsc_psk
71elif [ "$GET_WLAN_ENCRYPT" = "6" ]; then #WPAPSKWPA2PSK
72 echo "34" > $CONFIG_DIR/wsc_auth
73 if [ "$GET_WLAN_AUTH" = "1" ]; then #TKIP
74 echo "4" > $CONFIG_DIR/wsc_enc
75 elif [ "$GET_WLAN_AUTH" = "2" ]; then #AES
76 echo "8" > $CONFIG_DIR/wsc_enc
77 else #TKIPAES
78 echo "12" > $CONFIG_DIR/wsc_enc
79 fi
80 GET_PSK=`cat $CONFIG_DIR/wpa_psk`
81 echo $GET_PSK > $CONFIG_DIR/wsc_psk
82else #open
83 echo "1" > $CONFIG_DIR/wsc_auth
84 echo "1" > $CONFIG_DIR/wsc_enc
85fi
86
87
88echo "0" > $CONFIG_DIR/wsc_manual_enabled
89echo "0" > $CONFIG_DIR/wsc_upnp_enabled
90echo "1" > $CONFIG_DIR/wsc_registrar_enabled
91ESSID=`cat $CONFIG_DIR/ssid`
92echo $ESSID > $CONFIG_DIR/wsc_ssid
93echo "0" > $CONFIG_DIR/wsc_configbyextreg
94
95echo -e "\n test to check if loop here\n" >> $LOG
96
97BR_INTERFACE="br0"
98echo -e "\n <<<${START_WLAN_APP##*/} start $WLAN_INTERFACE $BR_INTERFACE>>>" >> $LOG
99$START_WLAN_APP start $WLAN_INTERFACE $BR_INTERFACE
100ERR=`echo $?`
101if [ $ERR != 0 ]; then
102 exit $ERR;
103fi