hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/sbin/busybox sh
 
module_path_8188eu=/res/8188eu.ko
module_path_8192cu=/res/8192cu.ko
module_path_rk903=/res/rkwifi.ko
module_path_rt5370=/res/rt5370sta.ko
module_path_mt7601=/res/mt7601sta.ko
module_path_mtPrealloc7601=/res/mtprealloc7601Usta.ko
module_path_8723au=/res/8723au.ko
module_path_8723as=/res/8723as.ko
module_path_wlan=/res/wlan.ko
module_path_esp8089=/system/lib/modules/esp8089.ko
result_file=/tmp/scan_result.txt
result_file2=/tmp/scan_result2.txt
chip_type_path=/sys/class/rkwifi/chip
driver_node=/sys/class/rkwifi/driver
pcba_node=/sys/class/rkwifi/pcba
version_path=/proc/version
module_path=$module_path_wlan
chip_broadcom=false
driver_buildin=false
interface_up=true
version=.3.0.36+
mt5931_kitkat=false
android_kitkat=false
 
jmax=3
 
if busybox cat $chip_type_path | busybox grep RK903; then
  module_path=$module_path_rk903
  chip_broadcom=true
  echo 1 > $pcba_node
fi
 
if busybox cat $chip_type_path | busybox grep RK901; then
  module_path=$module_path_rk903
  chip_broadcom=true
  echo 1 > $pcba_node
fi
 
if busybox cat $chip_type_path | busybox grep BCM4330; then
  module_path=$module_path_rk903
  chip_broadcom=true
  echo 1 > $pcba_node
fi
 
if busybox cat $chip_type_path | busybox grep RTL8188CU; then
  jmax=6
  module_path=$module_path_8192cu
fi
 
if busybox cat $chip_type_path | busybox grep RTL8188EU; then
  jmax=6
  module_path=$module_path_8188eu
fi
 
if busybox cat $chip_type_path | busybox grep RT5370; then
  jmax=6
  module_path=$module_path_rt5370
fi
 
if busybox cat $chip_type_path | busybox grep MT7601; then
  jmax=6
  module_path=$module_path_mt7601
  echo "mt7601 insmod pre-alloc driver & copy firmware"
  insmod "$module_path_mtPrealloc7601"
  busybox cp /system/etc/firmware/RT2870STA.dat /etc/firmware/
  #interface_up=false
fi
 
if busybox cat $chip_type_path | busybox grep RTL8723AU; then
  module_path=$module_path_8723au
fi
 
if busybox cat $chip_type_path | busybox grep RTL8723AS; then
  module_path=$module_path_8723as
fi  
 
if busybox cat $chip_type_path | busybox grep ESP8089; then
  module_path=$module_path_esp8089
fi
 
if busybox cat $version_path | busybox grep 3.0.36+; then
  echo "kernel version 3.0.36+"
  if [ -e $module_path$version ]; then
    module_path=$module_path$version
  fi
fi
 
if busybox ls /dev/wmtWifi | busybox grep wmtWifi; then
  echo "mt5931_kitkat=true"
  mt5931_kitkat=true
fi
 
if busybox ifconfig wlan0; then
  echo "android_kitkat=true"
  android_kitkat=true
fi
 
if busybox ls $driver_node; then
  echo "wifi driver is buildin"
  driver_buildin=true
fi
 
echo "touch $result_file"
busybox touch $result_file
 
j=0
 
echo "get scan results"
while [ $j -lt $jmax ]; 
do
    echo "insmod wifi driver"
    if [ $mt5931_kitkat = "true" ]; then
        echo "echo 1 > /dev/wmtWifi"
        echo 1 > /dev/wmtWifi
    else
      if [ $android_kitkat = "false" ]; then
        if [ $driver_buildin = "true" ]; then
          echo "echo 1 > $driver_node"
          echo 1 > "$driver_node"
        else
          echo "insmod $module_path"
          insmod "$module_path"
        fi
      fi
    fi
    if [ $? -ne 0 ]; then
        echo "insmod failed"
        exit 0
    fi
 
    echo "sleep 3s"
    busybox sleep 3
 
    if busybox ifconfig wlan0; then
        if [ $interface_up = "true" ]; then
            busybox ifconfig wlan0 up
        fi
        #if [ $? -ne 0 ]; then
        #    echo "ifconfig wlan0 up failed"
        #    exit 0
        #fi
    
        iwlist wlan0 scanning > $result_file
        if [ $chip_broadcom = "true" ]; then
            echo "sleep 3s"
            busybox sleep 3    
        fi
        iwlist wlan0 scanning last | busybox grep SSID > $result_file
        busybox cat $result_file
        iwlist wlan0 scanning last | busybox grep "Signal level" > $result_file2
        busybox cat $result_file2
        echo "success"
        exit 1
    fi
 
    echo "remove wifi driver"
    if [ $mt5931_kitkat = "true" ]; then
        echo "echo 0 > /dev/wmtWifi"
        echo 0 > /dev/wmtWifi
    else
      if [ $android_kitkat = "false" ]; then
        if [ $driver_buildin = "true" ]; then
          echo "echo 0 > $driver_node"
          echo 0 > "$driver_node"
        else
          echo "rmmod wlan"
          rmmod wlan
        fi
      fi
    fi
    busybox sleep 1
    
    j=$((j+1))
done
 
echo "wlan test failed"
exit 0