  mac80211_hostapd_setup_base() {
  	local phy="$1"
  	local ifname="$2"
-@@ -340,10 +342,43 @@
+@@ -340,10 +342,45 @@
  		[ -n "$ifname" ] || {
  			[ $i -gt 0 ] && ifname="wlan${phy#phy}-$i" || ifname="wlan${phy#phy}"
  		}

+					if [ "$encryption" = "true" ]; then 
+						config_get key "$vif" key "$(commotion_get_wpakey $ifname)"
+						encryption="psk2"
+					fi
+				else
+					config_get ssid "$vif" ssid

+				uci_set wireless "$vif" encryption "psk2"
+				config_set "$vif" key "$key"
+				uci_set wireless "$vif" key "$key"
+			elif ["$encryption" = "false" ]; then
+				encryption="none"
+			fi
+			export channel
+			iw dev "$ifname" set channel "$channel"
