File tree Expand file tree Collapse file tree 3 files changed +46
-3
lines changed
Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -306,8 +306,11 @@ def _get_wifi_interfaces(self):
306306 'frag_threshold' : 'frag'
307307 }
308308 for netjson_key , uci_key in wifi_options .items ():
309- if wireless .get (netjson_key ) is not None :
310- uci_wifi [uci_key ] = wireless [netjson_key ]
309+ value = wireless .get (netjson_key )
310+ if value is not None :
311+ # ignore if 0 (autogenerated UIs might use 0 as default value)
312+ if value > 0 :
313+ uci_wifi [uci_key ] = value
311314 del uci_wifi [netjson_key ]
312315 # determine encryption for wifi
313316 if uci_wifi .get ('encryption' ):
Original file line number Diff line number Diff line change 288288 "ack_distance" : {
289289 "type" : "integer" ,
290290 "title" : "ACK distance" ,
291- "minimum" : 1 ,
291+ "minimum" : 0 ,
292292 "propertyOrder" : 10 ,
293293 },
294294 "rts_threshold" : {
Original file line number Diff line number Diff line change @@ -918,5 +918,45 @@ def test_wds_ap(self):
918918 option network 'wlan0'
919919 option ssid 'MyWdsAp'
920920 option wds '1'
921+ """ )
922+ self .assertEqual (o .render (), expected )
923+
924+ def test_wifi_options_zero (self ):
925+ """
926+ ensure ack_distance, rts_threshold and frag_threshold
927+ are ignored if left empty
928+ """
929+ o = OpenWrt ({
930+ "interfaces" : [
931+ {
932+ "name" : "wlan0" ,
933+ "type" : "wireless" ,
934+ "wireless" : {
935+ "radio" : "radio0" ,
936+ "mode" : "access_point" ,
937+ "ssid" : "MyWifiAP" ,
938+ "wmm" : True ,
939+ "ack_distance" : 0 ,
940+ "rts_threshold" : 0 ,
941+ "frag_threshold" : 0
942+ }
943+ }
944+ ]
945+ })
946+ expected = self ._tabs ("""package network
947+
948+ config interface 'wlan0'
949+ option ifname 'wlan0'
950+ option proto 'none'
951+
952+ package wireless
953+
954+ config wifi-iface
955+ option device 'radio0'
956+ option ifname 'wlan0'
957+ option mode 'ap'
958+ option network 'wlan0'
959+ option ssid 'MyWifiAP'
960+ option wmm '1'
921961""" )
922962 self .assertEqual (o .render (), expected )
You can’t perform that action at this time.
0 commit comments