Compared files  

Left
/fw/dreame.vacuum.p2041o/4.1.2_1107/xout/_root/usr/bin/wifi_setup.sh
Last modified2021-04-23 02:08:44
Size3.4 Kb (151 Lines)
EncodingLatin 1 - ANSI (CP1252) default
Right
/fw/dreame.vacuum.p2041/4.3.2_1108/xout/_root/usr/bin/wifi_setup.sh
Last modified2021-11-04 08:52:09
Size819 Bytes (45 Lines)
EncodingUnicode 8 bits (UTF-8) - without signature autodetected


   Comparison Statistics  

Detailed Statistics

All Changes
 BlocksLines
Unchanged921
Inserted00
Deleted245
Ignored15
Changed5104




   Comparison Details  

1 skipped line
2 2 #
3 3 # wifi_setup: setup wifi mode(ap or station)
4 4 # version: 0.0.1
5 # date: 2020/06/22 5 # date: 2021/09/02
6 # 6 # 说明:为了兼容启动配网脚本,重构wifi_setup.sh
  7 #      wifi_setup.sh覆盖wifi_setup工程中的wifi_setup.sh
7 8 # set -x
8 9  
9 10 source /usr/bin/config
10 source /usr/bin/getssid  
11    
12 LOG_FILE=/data/log/wifi.log  
13    
14 GATEWAY=192.168.5.1  
15 NETMASK=255.255.255.0  
16 AP_IF_NAME=wlan0  
17    
18 function get_ap_interface()  
19 {  
20     lsmod | grep hi3881  
21     if [ $? == 0 ]; then  
22         # wifi model hi3881 use ap0 for ap interface  
23         AP_IF_NAME=ap0  
24     else  
25         # others use wlan0 for ap interface (ex. 8189fs)  
26         AP_IF_NAME=wlan0  
27     fi  
28 }  
29 11  
30 12 function set_ap_mode()
31 13 {
32     echo `date` "start ${AP_IF_NAME} AP mode" >> ${LOG_FILE} 14     if [ x"$MIIO_NET_AUTO_PROVISION" == x1 ]; then
33    
34     # wifi light flash slowly in ap mode  
35     set_wifi_light.sh flash_slow  
36     avacmd clb '{"type":"clb","cmd":"report_network_connect_mode","mode":0}' &  
37    
38     # kill wifi relative program  
39     killall -9 hostapd dnsmasq > /dev/null 2>&1  
40     killall -9 wpa_supplicant udhcpc > /dev/null 2>&1  
41     killall -9 wifi_manager > /dev/null 2>&1  
42    
43     # clean up ip  
44     ipaddr flush ${AP_IF_NAME}  
45     sleep 0.5  
46    
47     # remove wifi_manager relative flag file  
48     rm -f /tmp/wifi_ctrl_*  
49     rm -f ${WIFI_CONNECT} ${WIFI_DISCONNECT}  
50    
51     # restart ap interface  
52     ifconfig ${AP_IF_NAME} down  
53     sleep 1  
54     ifconfig ${AP_IF_NAME} up  
55    
56     # get ssid name  
57     if [ -z "$1" ]; then 15         CHANNEL="${CHANNEL}" wifi_start.sh "SET_APSTA_MODE" "$1"
58         get_ssid  
59 16     else
60         SSID_NAME="$1" 17         CHANNEL="${CHANNEL}" wifi_start.sh "SET_AP_MODE" "$1"
61 18     fi
62     log "get ssid:$SSID_NAME"  
63    
64     # sed hostapd configure file use ap interface and ssid name  
65     sed -e "s/AP_IF_NAME/${AP_IF_NAME}/" -e "s/SSID_NAME/${SSID_NAME}/" /etc/wifi/hostapd.conf > /tmp/hostapd.conf  
66    
67     # start hostapd  
68     hostapd -B /tmp/hostapd.conf  
69     sleep 0.5  
70    
71     # set wlan0 gateway and netmask  
72     ifconfig ${AP_IF_NAME} ${GATEWAY} netmask ${NETMASK}  
73    
74     # sed dnsmasq configure file use ap interface  
75     sed "s/AP_IF_NAME/${AP_IF_NAME}/" /etc/wifi/dnsmasq.conf > /tmp/dnsmasq.conf  
76    
77     # start dnsmasq  
78     echo -n "" > /tmp/dnsmasq.leases  
79     dnsmasq -C /tmp/dnsmasq.conf -x /tmp/dnsmasq.pid  
80    
81     # notify ava now is ap mode  
82     avacmd msg_cvt '{"type":"msgCvt", "wifi":{"state":"ap"}}' &  
83    
84     # notify other process network ap state  
85     /usr/bin/network_hook.sh ap  
86    
87     echo `date` "finish ${AP_IF_NAME} AP ssid=${SSID_NAME}" >> ${LOG_FILE}  
88 19 }
89 20  
90 21 function set_sta_mode()
91 22 {
92     echo `date` "start wlan0 STATION mode" >> ${LOG_FILE}  
93    
94     # wifi light flash fast in ap mode  
95     set_wifi_light.sh flash_fast  
96     avacmd clb '{"type":"clb","cmd":"report_network_connect_mode","mode":1}' &  
97    
98     # kill wifi relative program  
99     killall -9 hostapd dnsmasq > /dev/null 2>&1  
100     killall -9 wpa_supplicant udhcpc > /dev/null 2>&1  
101     killall -9 wifi_manager > /dev/null 2>&1  
102    
103     # clean up ip  
104     ipaddr flush wlan0  
105     sleep 0.5  
106    
107     # stop ap0 if use wifi model hi3881  
108     if [ "${AP_IF_NAME}" == "ap0" ]; then  
109         ifconfig ap0 down  
110     fi  
111    
112     # restart wlan0  
113     ifconfig wlan0 down  
114     sleep 1  
115     ifconfig wlan0 up  
116    
117     # start wpa_supplicant  
118     /etc/init.d/wpa_supplicant.sh > /dev/null 2>&1  
119    
120     start wifi manager  
121     /etc/rc.d/wifi_manager.sh "$1" > /dev/null 2>&1 23     wifi_start.sh
122    
123     # notify ava now is station mode  
124     avacmd msg_cvt '{"type":"msgCvt", "wifi":{"state":"station"}}' &  
125    
126     # notify other process network sta state  
127     /usr/bin/network_hook.sh sta  
128    
129     echo `date` "finish wlan0 STATION mode" >> ${LOG_FILE}  
130 24 }
131 25  
132 main() 26 function set_apsta_mode()
133 { 27 {
134     # get ap interface node  
135     get_ap_interface  
136    
137     case "$1" in  
138         ap)  
139             set_ap_mode "$2"  
140             ;;  
141         sta)  
142             set_sta_mode "$2"  
143             ;;  
144         *)  
145             echo "set unknow mode $1" 28     CHANNEL="${CHANNEL}" wifi_start.sh "SET_APSTA_MODE" "$1"
146             ;;  
147     esac  
148 29 }
149 30  
150 main $@ 31 case "$1" in
  32     ap)
  33         set_ap_mode "$2"
  34         ;;
  35     sta)
  36         set_sta_mode
  37         ;;
  38     apsta)
  39         set_apsta_mode "$2"
  40         ;;
  41     *)
  42         echo "set unknow mode $1"
  43         ;;
  44 esac
151 45  

   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