base-files, mac80211, broadcom-wl: use uci to populate wireless config
Previously, wifi detect simply dumped its generated wireless
configuration to STDOUT. A second step was needed to append
the configuration to /etc/config/wireless (or create it, if
it didn't exist).
With this patch, The wifi detection script will now use uci
to update the wireless configuration directly.
This patch also makes the initially created wifi-iface a
named section ('default_radio$X' for mac80211 and
'default_wl$X' for broadcom). With this change, uci will
not print the cfgHASH to STDOUT (which would now corrupt
the wireless configuration). It will also prevent adding
duplicated wifi interface configurations, if the wifi
configuration is run concurrently.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
			
			
This commit is contained in:
		 Christian Lamparter
					Christian Lamparter
				
			
				
					committed by
					
						 Felix Fietkau
						Felix Fietkau
					
				
			
			
				
	
			
			
			 Felix Fietkau
						Felix Fietkau
					
				
			
						parent
						
							ba3540db62
						
					
				
				
					commit
					5e35b4562f
				
			| @@ -41,11 +41,7 @@ boot() { | |||||||
| 	# allow wifi modules time to settle | 	# allow wifi modules time to settle | ||||||
| 	sleep 1 | 	sleep 1 | ||||||
|  |  | ||||||
| 	/sbin/wifi detect > /tmp/wireless.tmp | 	/sbin/wifi detect | ||||||
| 	[ -s /tmp/wireless.tmp ] && { |  | ||||||
| 		cat /tmp/wireless.tmp >> /etc/config/wireless |  | ||||||
| 	} |  | ||||||
| 	rm -f /tmp/wireless.tmp |  | ||||||
|  |  | ||||||
| 	/bin/config_generate | 	/bin/config_generate | ||||||
| 	uci_apply_defaults | 	uci_apply_defaults | ||||||
|   | |||||||
| @@ -456,22 +456,22 @@ detect_broadcom() { | |||||||
| 		config_get type wl${i} type | 		config_get type wl${i} type | ||||||
| 		[ "$type" = broadcom ] && continue | 		[ "$type" = broadcom ] && continue | ||||||
| 		channel=`wlc ifname wl${i} channel` | 		channel=`wlc ifname wl${i} channel` | ||||||
| 		cat <<EOF |  | ||||||
| config wifi-device  wl${i} |  | ||||||
| 	option type     broadcom |  | ||||||
| 	option channel  ${channel:-11} |  | ||||||
| 	option txantenna 3 |  | ||||||
| 	option rxantenna 3 |  | ||||||
| 	# REMOVE THIS LINE TO ENABLE WIFI: |  | ||||||
| 	option disabled 1 |  | ||||||
|  |  | ||||||
| config wifi-iface | 		uci -q batch <<-EOF | ||||||
| 	option device   wl${i} | 			set wireless.wl${i}=wifi-device | ||||||
| 	option network	lan | 			set wireless.wl${i}.type=broadcom | ||||||
| 	option mode     ap | 			set wireless.wl${i}.channel=${channel:-11} | ||||||
| 	option ssid     Lede${i#0} | 			set wireless.wl${i}.txantenna=3 | ||||||
| 	option encryption none | 			set wireless.wl${i}.rxantenna=3 | ||||||
|  | 			set wireless.wl${i}.disabled=1 | ||||||
|  |  | ||||||
|  | 			set wireless.default_wl${i}=wifi-iface | ||||||
|  | 			set wireless.default_wl${i}.device=wl${i} | ||||||
|  | 			set wireless.default_wl${i}.network=lan | ||||||
|  | 			set wireless.default_wl${i}.mode=ap | ||||||
|  | 			set wireless.default_wl${i}.ssid=Lede${i#0} | ||||||
|  | 			set wireless.default_wl${i}.encryption=none | ||||||
| EOF | EOF | ||||||
|  | 		uci -q commit wireless | ||||||
| 	done | 	done | ||||||
| } | } | ||||||
|   | |||||||
| @@ -92,7 +92,7 @@ detect_mac80211() { | |||||||
| 			htmode="VHT80" | 			htmode="VHT80" | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		[ -n $htmode ] && append ht_capab "	option htmode	$htmode" "$N" | 		[ -n $htmode ] && ht_capab="set wireless.radio${devidx}.htmode=$htmode" | ||||||
|  |  | ||||||
| 		if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then | 		if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then | ||||||
| 			path="$(readlink -f /sys/class/ieee80211/${dev}/device)" | 			path="$(readlink -f /sys/class/ieee80211/${dev}/device)" | ||||||
| @@ -104,30 +104,29 @@ detect_mac80211() { | |||||||
| 			case "$path" in | 			case "$path" in | ||||||
| 				platform*/pci*) path="${path##platform/}";; | 				platform*/pci*) path="${path##platform/}";; | ||||||
| 			esac | 			esac | ||||||
| 			dev_id="	option path	'$path'" | 			dev_id="set wireless.radio${devidx}.path='$path'" | ||||||
| 		else | 		else | ||||||
| 			dev_id="	option macaddr	$(cat /sys/class/ieee80211/${dev}/macaddress)" | 			dev_id="set wireless.radio${devidx}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)" | ||||||
| 		fi | 		fi | ||||||
|  |  | ||||||
| 		cat <<EOF | 		uci -q batch <<-EOF | ||||||
| config wifi-device  radio$devidx | 			set wireless.radio${devidx}=wifi-device | ||||||
| 	option type     mac80211 | 			set wireless.radio${devidx}.type=mac80211 | ||||||
| 	option channel  ${channel} | 			set wireless.radio${devidx}.channel=${channel} | ||||||
| 	option hwmode	11${mode_band} | 			set wireless.radio${devidx}.hwmode=11${mode_band} | ||||||
| $dev_id | 			${dev_id} | ||||||
| $ht_capab | 			${ht_capab} | ||||||
| 	# REMOVE THIS LINE TO ENABLE WIFI: | 			set wireless.radio${devidx}.disabled=1 | ||||||
| 	option disabled 1 |  | ||||||
|  |  | ||||||
| config wifi-iface |  | ||||||
| 	option device   radio$devidx |  | ||||||
| 	option network  lan |  | ||||||
| 	option mode     ap |  | ||||||
| 	option ssid     LEDE |  | ||||||
| 	option encryption none |  | ||||||
|  |  | ||||||
|  | 			set wireless.default_radio${devidx}=wifi-iface | ||||||
|  | 			set wireless.default_radio${devidx}.device=radio${devidx} | ||||||
|  | 			set wireless.default_radio${devidx}.network=lan | ||||||
|  | 			set wireless.default_radio${devidx}.mode=ap | ||||||
|  | 			set wireless.default_radio${devidx}.ssid=LEDE | ||||||
|  | 			set wireless.default_radio${devidx}.encryption=none | ||||||
| EOF | EOF | ||||||
|  | 		uci -q commit wireless | ||||||
|  |  | ||||||
| 		devidx=$(($devidx + 1)) | 		devidx=$(($devidx + 1)) | ||||||
| 	done | 	done | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user