Compared files  

Left
/fw/roborock.vacuum.a15/4.1.2_0978/xout/_root/opt/rockrobo/wlan/wifi_start.sh
Last modified2021-03-31 09:10:53
Size7.4 Kb (284 Lines)
EncodingLatin 1 - ANSI (CP1252) default
Right
/fw/roborock.vacuum.a15/4.1.2_1050/xout/_root/opt/rockrobo/wlan/wifi_start.sh
Last modified2021-04-28 07:09:30
Size11.1 Kb (392 Lines)
EncodingLatin 1 - ANSI (CP1252) default


   Comparison Statistics  

Detailed Statistics

All Changes
 BlocksLines
Unchanged16215
Inserted418
Deleted00
Ignored00
Changed11228




   Comparison Details  

5 skipped lines
6 6 DEVICE_MODEL=""
7 7 SET_MAC=""
8 8 SET_CHANNEL_PLAN=""
9 wifi_module="8189es" 9 WIFI_MODULE_RTW="8189es"
  10 WIFI_MODULE_SSV="ssv6x5x"
  11 WIFI_MODULE_HI3881="hi3881"
  12 WIFI_MODULE_ARRAY=(${WIFI_MODULE_RTW} ${WIFI_MODULE_SSV} ${WIFI_MODULE_HI3881})
10 13 WIFI_DIR=/mnt/data/wlan
11 14 WPA_CONF=/mnt/data/wlan/wpa_supplicant.conf
12 15 TMP_WPA_CONF=/tmp/wpa_supplicant.conf.gbk
1 skipped line
14 17 HOSTAPD_CONF=/tmp/hostapd.conf
15 18 DNSMASQ_CONF=/tmp/dnsmasq.conf
16 19  
  20 HI3881_DEFAULT_CONF=/etc/hi3881_wifi.cfg
  21 HI3881_DEFAULT_CONF_FCC=/etc/hi3881_wifi_fcc.cfg
  22 HI3881_CONF=/tmp/hi3881_wifi.cfg
  23  
  24 SSV6X5X_DEFAULT_CONF=/etc/ssv6x5x-wifi.cfg
  25 SSV6X5X_CONF=/tmp/ssv6x5x-wifi.cfg
  26 COUNTRY_CODE=
  27  
  28 WIFI_DEV_CUR=`cat /proc/rockrobo/hwinfo | grep ^WIFI: | cut -d ':' -f 2`
  29  
17 30 channel=1
18 31  
19 32 debug_mode=0
20 33 clear_sevice=0
21 34 wifi_need_insmod=true
  35 wifi_driver_exist=false
22 36  
23 37 while getopts "dcn" name
24 38 do
46 skipped lines
71 85     sed -i "s/^channel=.*/channel=$channel/" $HOSTAPD_CONF
72 86 }
73 87  
74 wifi_init_conf() 88 wifi_adjust_ssid()
75 { 89 {
76         # hostapd conf  
77         echo "beacon_int=100" > ${HOSTAPD_CONF}  
78         echo "ssid=roborock-machine" >> ${HOSTAPD_CONF} 90     if [ -f $DEVICE_CONF ]; then
79         echo "interface=wlan0" >> ${HOSTAPD_CONF}  
80         echo "driver=nl80211" >> ${HOSTAPD_CONF} 91         prefix=`grep "^[[:space:]]*model[[:space:]]*=" $DEVICE_CONF | cut -d '=' -f2 | sed -e 's/\./-/g'`
81         echo "channel=6" >> ${HOSTAPD_CONF} 92     else
82         echo "ignore_broadcast_ssid=0" >> ${HOSTAPD_CONF} 93         prefix="noconfig"
83         echo "hw_mode=b" >> ${HOSTAPD_CONF} 94     fi
84   95     suffix=`echo $1 | tr '[a-z]' '[A-Z]'`
85         # dnsmasq conf 96     ssid_ap=$prefix"_miap"$suffix
86         echo "interface=wlan0" > ${DNSMASQ_CONF}  
87         echo "bind-interfaces" >> ${DNSMASQ_CONF}  
88         echo "except-interface=lo" >> ${DNSMASQ_CONF}  
89         echo "dhcp-range=192.168.8.10, 192.168.8.100, 6h" >> ${DNSMASQ_CONF} 97     sed -i "s/^ssid=.*/ssid=$ssid_ap/" $HOSTAPD_CONF
90 98 }
91 99  
92 wifi_ap_mode() 100 wifi_init_ap_conf()
93 { 101 {
94     # AP mode 102     # hostapd conf
95   103     local mac_cur=$1
96     if [ -f $DEVICE_CONF ]; then 104     echo "beacon_int=100" > ${HOSTAPD_CONF}
97         prefix=`grep "^[[:space:]]*model[[:space:]]*=" $DEVICE_CONF | cut -d '=' -f2 | sed -e 's/\./-/g'` 105     echo "ssid=roborock-machine" >> ${HOSTAPD_CONF}
98     else 106     echo "interface=wlan0" >> ${HOSTAPD_CONF}
99         prefix="noconfig" 107     echo "driver=nl80211" >> ${HOSTAPD_CONF}
100     fi 108     echo "channel=6" >> ${HOSTAPD_CONF}
101   109     echo "ignore_broadcast_ssid=0" >> ${HOSTAPD_CONF}
  110     echo "hw_mode=b" >> ${HOSTAPD_CONF}
  111  
  112     # dnsmasq conf
102     suffix=`echo $1 | tr '[a-z]' '[A-Z]'` 113     echo "interface=wlan0" > ${DNSMASQ_CONF}
103     ssid_ap=$prefix"_miap"$suffix 114     echo "bind-interfaces" >> ${DNSMASQ_CONF}
  115     echo "except-interface=lo" >> ${DNSMASQ_CONF}
104     sed -i "s/^ssid=.*/ssid=$ssid_ap/" $HOSTAPD_CONF 116     echo "dhcp-range=192.168.8.10, 192.168.8.100, 6h" >> ${DNSMASQ_CONF}
  117  
  118     wifi_adjust_channel
  119     wifi_adjust_ssid $mac_cur
  120 }
  121  
  122 wifi_ap_mode()
  123 {
  124     # AP mode
105 125     CMD="hostapd -B $HOSTAPD_CONF"
106 126     echo "set wifi ap mode"
107 127     if [ $debug_mode -eq 1 ];then
68 skipped lines
176 196     udhcpc -S -b -i wlan0 -h $STA_HOST_NAME
177 197     echo "set wifi sta mode"
178 198 }
  199  
179 prepare() 200 wifi_prepare()
180 201 {
181 202     set_led off
182 203     killall dnsmasq >/dev/null 2>&1
13 skipped lines
196 217         if [ "x$WIFIPLAN_PREFIX" = "x0x" -o "x$WIFIPLAN_PREFIX" = "x0X" ]; then
197 218         SET_CHANNEL_PLAN="0x$WIFIPLAN_SURFIX"
198 219         fi
  220         COUNTRY_CODE=`cat /mnt/default/roborock.conf |grep -i "^[[:space:]]*location[[:space:]]*=" |sed -e 's/^.*=[[:space:]]*//' |sed -e 's/[[:space:]]*$//'`
199 221     fi
200 222 }
201 223  
  224 wifi_insmod()
  225 {
  226     wifi_module=$1 
  227     has_insmod=`lsmod | grep -wc "^$wifi_module"`
  228     if [ $has_insmod -gt 0 ]; then
  229         rmmod $wifi_module -f
  230         rm /etc/udev/rules.d/70-persistent-net.rules -rf
  231     fi
  232     wifi_module_with_path=`find /lib/modules/ -name ${wifi_module}.ko`
  233     if [ -z "${wifi_module_with_path}" ]; then
  234         echo "can not find wifi modules: ${wifi_module}"
  235         return 1
  236     fi
  237     case ${wifi_module} in
  238         ${WIFI_MODULE_RTW})
  239             if [ -z "$SET_MAC" ]; then
  240                 if [ -z "$SET_CHANNEL_PLAN" ]; then
  241                     insmod ${wifi_module_with_path}
  242                 else
  243                     insmod ${wifi_module_with_path} rtw_channel_plan=$SET_CHANNEL_PLAN
  244                 fi
  245             else
  246                 if [ -z "$SET_CHANNEL_PLAN" ]; then
  247                     insmod ${wifi_module_with_path} rtw_initmac=$SET_MAC
  248                 else
29 skipped lines
  278             else
  279                 cp -a ${HI3881_DEFAULT_CONF} ${HI3881_CONF}
  280             fi
  281             if [ -e ${HI3881_CONF} ]; then
  282                 sed -i "/CFG_MAC/c\CFG_MAC=${SET_MAC};" ${HI3881_CONF}
  283             else
  284                 return 1
  285             fi
  286             has_ssid=0
  287             if [ -e $WIFI_CONFIG_FILE ]; then
  288                 has_ssid=`cat $WIFI_CONFIG_FILE | grep -v \^# | grep -wc ssid`
  289             fi
  290             if [ $has_ssid -gt 0 ]; then
  291                 insmod ${wifi_module_with_path} g_mode=0
  292             else 
  293                 insmod ${wifi_module_with_path} g_mode=1
  294             fi
  295             ;;
  296         *)
  297             return 2
  298     esac
  299     sleep 1
  300     return 0
  301 }
  302  
202 start() 303 wifi_start()
203 304 {
204 305     while $wifi_need_insmod ; do
205 306         if [ -z "$SET_MAC" ]; then
9 skipped lines
215 316         break;
216 317         fi
217 318         fi
218         has_insmod=`lsmod | grep -wc "^$wifi_module"` 319         wifi_dev_found=false
219         if [ $has_insmod -gt 0 ]; then  
220         rmmod $wifi_module -f  
221         rm /etc/udev/rules.d/70-persistent-net.rules -rf  
222         fi  
223         wifi_module_with_path=`find /lib/modules/ -name ${wifi_module}.ko` 320         for wifi_module in ${WIFI_MODULE_ARRAY[@]} ; do
224         if [ -z "${wifi_module_with_path}" ]; then 321             if [ x"${wifi_module}" = x"${WIFI_DEV_CUR}" ]; then
225         echo can not find wifi modules 322                 wifi_dev_found=true
226         return -1 323                 break
227         fi 324             fi
228         if [ -z "$SET_MAC" ]; then 325         done
229         if [ -z "$SET_CHANNEL_PLAN" ]; then 326         if $wifi_dev_found; then
230         insmod ${wifi_module_with_path} 327             wifi_insmod ${wifi_module}
231         else 328         else
232         insmod ${wifi_module_with_path} rtw_channel_plan=$SET_CHANNEL_PLAN 329             for wifi_module in ${WIFI_MODULE_ARRAY[@]} ; do
233         fi  
234         else  
235         if [ -z "$SET_CHANNEL_PLAN" ]; then  
236         insmod ${wifi_module_with_path} rtw_initmac=$SET_MAC 330                 wifi_insmod ${wifi_module}
  331                 if [ $? -ne 0 ]; then
  332                     continue
  333                 fi
  334                 ifconfig wlan0 >/dev/null 2>&1
  335                 if [ $? -eq 0 ]; then
  336                     break
237         else 337                 else
238         insmod ${wifi_module_with_path} rtw_initmac=$SET_MAC rtw_channel_plan=$SET_CHANNEL_PLAN 338                     rmmod ${wifi_module} -f
239         fi 339                 fi
240         fi 340             done
241         sleep 2 341         fi
242     done 342     done 
243 343     if [ -e $WIFI_CONFIG_FILE ]; then
244 344         has_ssid=`cat $WIFI_CONFIG_FILE | grep -v \^# | grep -wc ssid`
245 345         if [ $has_ssid -gt 0 ]; then
10 skipped lines
256 356     mac1=`echo ${macstring} | cut -d ':' -f 5`
257 357     mac2=`echo ${macstring} | cut -d ':' -f 6`
258 358     MAC=${mac1}${mac2}
259     wifi_init_conf 359     wifi_init_ap_conf $MAC
260     wifi_adjust_channel  
261     wifi_ap_mode $MAC 360     wifi_ap_mode
262 } 361 }
  362  
263 363 if [ ! -d ${WIFI_DIR} ]; then
264 364     mkdir -p ${WIFI_DIR}
265 365 fi
266 366  
  367 if [ x"${WIFI_DEV_CUR}" = x"${WIFI_MODULE_HI3881}" ]; then
  368     wifi_prepare
  369     rmmod ${WIFI_MODULE_HI3881} -f
  370     wifi_need_insmod=true
  371 fi
  372  
267 373 if [ $clear_sevice -eq 1 ]; then
268         prepare 374     wifi_prepare
269 375 else
270         #if wifi_need_insmod = false, it is called by wlanmgr, then 376     #if wifi_need_insmod = false, it is called by wlanmgr, then
271         #don't need to call prepare because wlanmgr had called "wifi_start.sh -cn" 377     #don't need to call wifi_prepare because wlanmgr had called "wifi_start.sh -cn"
272         if  $wifi_need_insmod ; then 378     if  $wifi_need_insmod ; then
273                 prepare 379         wifi_prepare
274         fi 380     fi
275 381 fi
276 382  
277 383 if [ $clear_sevice -eq 1 ]; then
278 384     if  $wifi_need_insmod ; then
  385         for wifi_module in ${WIFI_MODULE_ARRAY[@]} ; do
279         rmmod $wifi_module >/dev/null 2>&1 386         rmmod $wifi_module >/dev/null 2>&1
  387         done
280 388     fi
281 389     exit 0
282 390 fi
283 start 391 wifi_start
284 392  

   Text comparison Options  

Syntax colouring language used: Shell
Match character case: yes.
Match line endings: no.
Match spaces

At start of lines: yes,
In middle of lines: yes,
At end of lines: yes.
Blank lines as empty lines: no.
Activate comparison algorithm
At word level: yes,
At character level: no.


   Legend  

Unchanged lineExample of unchanged line
Modified lineExample of modified line
Added lineExample of added line
Removed lineExample of removed line
Ignored lineExample of ignored line